/* ============================================================
   modal-shared.css  —  Edit Order Modal styles
   Used by index.html and orders.html
   ============================================================ */

.modal { display: none; position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.65); overflow-y: auto; }
.modal-content {
  background: white; margin: 30px auto; padding: 0;
  border-radius: 14px; width: 620px; max-width: calc(100% - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25); position: relative; overflow: hidden;
}
.modal-header {
  background: linear-gradient(135deg, #2c3e50, #3d5166);
  color: white; padding: 18px 22px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 1.1em; }
.modal-header small { opacity: 0.7; font-size: 0.8em; display: block; margin-top: 2px; }
.modal-close { background: none; border: none; color: white; font-size: 1.4em; cursor: pointer; opacity: 0.7; padding: 0 4px; line-height: 1; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 20px 22px; max-height: 72vh; overflow-y: auto; }
.modal-footer { padding: 14px 22px; border-top: 1px solid #eee; display: flex; gap: 8px; background: #fafbfc; flex-wrap: wrap; }

.form-section { margin-bottom: 18px; }
.form-section-title { font-size: 0.72em; font-weight: bold; text-transform: uppercase; letter-spacing: 0.06em; color: #aaa; margin-bottom: 10px; padding-bottom: 5px; border-bottom: 1px solid #eee; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 10px; }
.form-row.full  { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.78em; font-weight: 600; color: #555; text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1.5px solid #dde1e7; border-radius: 6px;
  font-size: 0.9em; font-family: inherit; color: #2c3e50; background: white;
  transition: 0.15s; width: 100%; box-sizing: border-box;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: #3498db; box-shadow: 0 0 0 3px rgba(52,152,219,0.12);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-readonly { padding: 8px 10px; background: #f4f6f8; border: 1.5px solid #eee; border-radius: 6px; font-size: 0.9em; color: #888; }
.field-balance  { font-size: 1.1em; font-weight: bold; }

.btn { padding: 10px 16px; border: none; border-radius: 7px; cursor: pointer; font-weight: bold; font-size: 0.88em; transition: 0.15s; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary   { background: #27ae60; color: white; flex: 1; }
.btn-primary:hover:not(:disabled)  { background: #219a52; }
.btn-secondary { background: #eaecee; color: #333; }
.btn-secondary:hover:not(:disabled) { background: #d5d8dc; }
.btn-print  { background: #f0f4ff; color: #2c5ebe; border: 1.5px solid #b8ccf7; }
.btn-print:hover  { background: #dce8ff; }
.btn-danger { background: #fde8e8; color: #c0392b; border: 1.5px solid #f5b8b8; }
.btn-danger:hover { background: #fbd5d5; }

.saving-overlay { display: none; position: absolute; inset: 0; background: rgba(255,255,255,0.9); border-radius: 14px; align-items: center; justify-content: center; flex-direction: column; gap: 12px; z-index: 10; }
.saving-overlay.active { display: flex; }
.spinner { width: 36px; height: 36px; border: 4px solid #e0e0e0; border-top-color: #27ae60; border-radius: 50%; animation: modal-spin 0.8s linear infinite; }
.saving-overlay p { color: #555; font-weight: bold; margin: 0; font-size: 0.95em; }
@keyframes modal-spin { to { transform: rotate(360deg); } }

/* Notes thread */
.notes-thread { max-height: 180px; overflow-y: auto; border: 1.5px solid #dde1e7; border-radius: 6px; padding: 10px; background: #fafbfc; margin-bottom: 8px; }
.note-item { padding: 8px 0; border-bottom: 1px solid #eee; }
.note-item:last-child { border-bottom: none; }
.note-meta { font-size: 0.72em; color: #aaa; margin-bottom: 3px; }
.note-text { font-size: 0.88em; color: #333; white-space: pre-wrap; }
.note-input-row { display: flex; gap: 8px; }
.note-input-row input { flex: 1; padding: 8px 10px; border: 1.5px solid #dde1e7; border-radius: 6px; font-size: 0.88em; font-family: inherit; outline: none; }
.note-input-row input:focus { border-color: #3498db; }
.note-add-btn { padding: 8px 14px; background: #3498db; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 0.85em; font-weight: 700; white-space: nowrap; }
.note-add-btn:hover { background: #2980b9; }

/* Status history */
.history-toggle { font-size: 0.78em; color: #3498db; cursor: pointer; background: none; border: none; padding: 0; margin-top: 4px; text-decoration: underline; }
.history-panel { display: none; border: 1.5px solid #dde1e7; border-radius: 6px; margin-top: 8px; overflow: hidden; }
.history-panel.open { display: block; }
.history-item { padding: 8px 12px; font-size: 0.8em; border-bottom: 1px solid #f0f0f0; display: flex; gap: 8px; align-items: center; }
.history-item:last-child { border-bottom: none; }
.h-from { color: #aaa; text-decoration: line-through; }
.h-arrow { color: #ccc; }
.h-to { font-weight: 700; color: #2c3e50; }
.h-meta { color: #aaa; margin-left: auto; white-space: nowrap; }

/* Payment records */
.payment-list { border: 1.5px solid #dde1e7; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.payment-item { padding: 8px 12px; font-size: 0.83em; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center; }
.payment-item:last-child { border-bottom: none; }
.p-type { font-weight: 700; color: #2c3e50; }
.p-amount { font-weight: 700; color: #27ae60; }
.p-meta { font-size: 0.85em; color: #aaa; }

/* Upload widget area */
.photo-upload-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.btn-upload { padding: 8px 14px; background: #3498db; color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 0.83em; font-weight: 700; white-space: nowrap; }
.btn-upload:hover { background: #2980b9; }
.photo-count { font-size: 0.78em; color: #888; }

/* Confirm dialog */
.confirm-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; align-items: center; justify-content: center; }
.confirm-overlay.active { display: flex; }
.confirm-box { background: white; border-radius: 12px; padding: 28px 28px 22px; max-width: 380px; width: calc(100% - 40px); box-shadow: 0 8px 32px rgba(0,0,0,0.3); text-align: center; }
.confirm-box h4 { font-size: 1.05em; margin-bottom: 8px; color: #2c3e50; }
.confirm-box p { font-size: 0.88em; color: #666; margin-bottom: 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.confirm-actions button { padding: 10px 22px; border-radius: 7px; border: none; cursor: pointer; font-weight: 700; font-size: 0.9em; }
.btn-confirm-yes { background: #e74c3c; color: white; }
.btn-confirm-yes:hover { background: #c0392b; }
.btn-confirm-no  { background: #eaecee; color: #333; }
.btn-confirm-no:hover  { background: #d5d8dc; }

@media (max-width: 640px) {
  .modal-content { margin: 8px auto; }
  .modal-body { max-height: 68vh; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.three { grid-template-columns: 1fr 1fr; }
  .modal-footer { gap: 6px; }
}
