/* =============================================
   REMISIONES v2 – Soluciones Élite
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #ffffff;
  --bg2:      #f7f7f5;
  --bg3:      #efefeb;
  --border:   #d8d8d0;
  --border2:  #c4c4bc;
  --text:     #1a1a18;
  --text2:    #666660;
  --text3:    #999992;
  --dark:     #1a1a2e;
  --dark2:    #16213e;
  --red:      #c0392b;
  --red-bg:   #fdf0ee;
  --red-b:    #e8a89f;
  --green:    #3b6d11;
  --green-bg: #eaf3de;
  --blue:     #185fa5;
  --blue-bg:  #e6f1fb;
  --orange:   #b94600;
  --radius:   10px;
  --rsm:      6px;
  --shadow:   0 1px 5px rgba(0,0,0,0.08);
}

body {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.app { max-width: 1040px; margin: 0 auto; padding: 14px 12px 48px; }

/* ---- TOP BAR ---- */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap; gap: 10px;
}
.top-brand { display: flex; align-items: center; gap: 10px; }
.brand-text {
  font-size: 19px; font-weight: 900; font-style: italic;
  letter-spacing: -1px; line-height: 1.1; color: var(--text);
}
.brand-text span { font-size: 11px; font-weight: 400; font-style: normal; display: block; }
.divider { width: 1px; height: 30px; background: var(--border); }
.app-title { font-size: 16px; font-weight: 500; }
.top-actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* ---- BUTTONS ---- */
.btn {
  padding: 7px 14px; border-radius: var(--rsm);
  border: 1px solid var(--border2); background: var(--bg);
  font-size: 13px; cursor: pointer; color: var(--text);
  font-family: inherit; transition: background .15s;
}
.btn:hover { background: var(--bg3); }
.btn-primary { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn-primary:hover { background: var(--dark2); }
.btn-empresa { color: var(--orange); border-color: #e8a870; font-weight: 600; }
.btn-empresa:hover { background: #fdf3ec; }
.btn-print { color: var(--green); border-color: #97c459; }
.btn-print:hover { background: var(--green-bg); }
.btn-danger { color: var(--red); border-color: var(--red-b); }
.btn-danger:hover { background: var(--red-bg); }
.btn-edit { color: var(--blue); border-color: #85b7eb; }
.btn-edit:hover { background: var(--blue-bg); }
.btn-save-client { color: #7b5ea7; border-color: #c4a8e0; }
.btn-save-client:hover { background: #f4eeff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---- VIEWS ---- */
.list-view, .form-view, .print-view { display: none; }
.list-view.active, .form-view.active, .print-view.active { display: block; }

/* ---- LIST ---- */
.table-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.list-table thead tr { background: var(--dark); color: #fff; }
.list-table th { padding: 10px 11px; text-align: left; font-weight: 500; font-size: 12px; }
.list-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
.list-table tbody tr:last-child { border-bottom: none; }
.list-table tbody tr:hover { background: var(--bg2); }
.list-table td { padding: 9px 11px; }
.badge-ok { display:inline-block; padding:2px 9px; border-radius:20px; font-size:11px; font-weight:600; background:var(--green-bg); color:var(--green); }
.no-firma { color: var(--text3); font-size: 12px; }
.actions-cell { display: flex; gap: 5px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; margin-bottom: 14px; }

/* ---- FORM CARD ---- */
.form-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}

/* FORM HEADER */
.form-header {
  background: var(--dark); color: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.fh-logo { display: flex; align-items: center; min-width: 130px; }
.fh-brand {
  font-size: 21px; font-weight: 900; font-style: italic;
  letter-spacing: -1px; line-height: 1.1; color: #fff;
}
.fh-brand span { font-size: 11px; font-weight: 300; font-style: normal; display: block; color: #aaa; }
.fh-contact { flex: 1; font-size: 10px; color: #bbb; line-height: 1.8; min-width: 160px; }
.fh-ubicacion { font-size: 10px; color: #bbb; line-height: 1.8; min-width: 140px; }
.fh-title { text-align: right; margin-left: auto; }
.remision-title-text {
  font-family: 'Times New Roman', Times, serif;
  font-size: 28px; font-weight: 900; letter-spacing: 1px; color: #fff;
}
.remision-num-badge {
  margin-top: 5px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  padding: 3px 10px;
  display: inline-block;
  min-width: 90px;
  text-align: center;
}
.remision-num-badge span {
  font-family: 'Times New Roman', Times, serif;
  font-size: 20px; font-weight: 900; color: #e74c3c;
  letter-spacing: 1px;
}

/* CLIENT BAR */
.client-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.client-bar-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.client-bar-actions { display: flex; gap: 6px; margin-left: auto; }

/* FORM FIELDS */
.form-grid-4 { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; border-bottom: 1px solid var(--border); }
.form-grid-2 { display: grid; grid-template-columns: 3fr 1fr; border-bottom: 1px solid var(--border); }
.field { padding: 8px 12px; border-right: 1px solid var(--border); min-height: 52px; }
.field.no-right { border-right: none; }
.field label { display: block; font-size: 10px; color: var(--text3); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .4px; }
.field input, .field textarea { width: 100%; border: none; background: transparent; font-size: 13px; color: var(--text); outline: none; font-family: inherit; resize: none; }
.field input:focus { border-bottom: 1.5px solid var(--dark); }

/* ITEMS */
.items-header { display: grid; grid-template-columns: 90px 1fr; background: var(--dark); color: #fff; }
.ih-cant { padding: 7px 12px; font-size: 12px; font-weight: 600; border-right: 1px solid #444; }
.ih-desc { padding: 7px 12px; font-size: 12px; font-weight: 600; }
.item-row { display: grid; grid-template-columns: 90px 1fr; border-bottom: 1px solid var(--border); }
.item-row:last-child { border-bottom: none; }
.cant-cell { border-right: 1px solid var(--border); background: var(--bg2); }
.item-row input { width: 100%; border: none; background: transparent; padding: 8px 12px; font-size: 13px; color: var(--text); outline: none; font-family: inherit; }
.item-row input:focus { background: #fffde7; }

/* BOTTOM */
.bottom-section { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); }
.bottom-left { border-right: 1px solid var(--border); padding: 12px 14px; }
.bottom-right { padding: 12px 14px; }
.totals-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: var(--rsm); overflow: hidden; margin-bottom: 10px; }
.tot-cell { padding: 7px 10px; border-right: 1px solid var(--border); }
.tot-cell.no-right { border-right: none; }
.tot-cell label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text3); margin-bottom: 3px; }
.tot-cell input { width: 100%; border: none; background: transparent; font-size: 14px; outline: none; font-family: inherit; color: var(--text); }
.obs-area label { font-size: 11px; color: var(--text3); }
.obs-area textarea { width: 100%; border: none; border-bottom: 1px dashed var(--border2); background: transparent; font-size: 12px; margin-top: 4px; resize: none; outline: none; color: var(--text); font-family: inherit; }
.sig-main-label { display: block; font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.nombre-recibe-input { width: 100%; border: none; border-bottom: 1px solid var(--border2); background: transparent; padding: 4px 0; font-size: 13px; margin-bottom: 8px; outline: none; color: var(--text); font-family: inherit; }
.nombre-recibe-input:focus { border-bottom-color: var(--dark); }
.sig-canvas-wrap { border: 1px solid var(--border2); border-radius: var(--rsm); background: var(--bg2); overflow: hidden; }
#sigCanvas { display: block; touch-action: none; cursor: crosshair; }
.sig-btns { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.sig-status { font-size: 11px; color: var(--green); }

/* FORM ACTIONS */
.form-actions {
  padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border); background: var(--bg2); flex-wrap: wrap;
}

/* PRINT VIEW */
.print-actions { display: flex; gap: 8px; margin-bottom: 14px; }
#printArea {
  background: #fff; color: #000;
  padding: 24px; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  font-family: Arial, Helvetica, sans-serif; font-size: 12px;
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal-box {
  background: var(--bg); border-radius: 12px; width: 100%; max-width: 560px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18); overflow: hidden;
}
.modal-box-sm { max-width: 420px; }
.modal-header {
  background: var(--dark); color: #fff;
  padding: 14px 18px; display: flex; align-items: center;
}
.modal-header h2 { font-size: 16px; font-weight: 500; flex: 1; margin: 0; }
.modal-close { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1; opacity: .7; }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 18px; }
.modal-section { margin-bottom: 20px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text3); margin-bottom: 10px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg2); }

/* LOGO EN MODAL */
.logo-preview-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.logo-preview-box {
  width: 130px; height: 70px; border: 1px dashed var(--border2);
  border-radius: var(--rsm); display: flex; align-items: center; justify-content: center;
  background: var(--bg2); overflow: hidden; flex-shrink: 0;
}
.logo-preview-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-empty-text { font-size: 11px; color: var(--text3); }
.logo-controls { display: flex; flex-direction: column; gap: 6px; }
.logo-size-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text2); }
.logo-size-row input[type=range] { flex: 1; cursor: pointer; }

/* MODAL FIELDS */
.modal-fields { display: flex; flex-direction: column; gap: 10px; }
.mf-row label { display: block; font-size: 11px; color: var(--text3); margin-bottom: 3px; }
.mf-row input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border2);
  border-radius: var(--rsm); font-size: 13px; font-family: inherit;
  color: var(--text); background: var(--bg); outline: none;
}
.mf-row input:focus { border-color: var(--dark); }
.mf-two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* CLIENTES LIST */
.cliente-item {
  display: flex; align-items: center; padding: 10px 16px;
  border-bottom: 1px solid var(--border); gap: 10px;
  cursor: pointer; transition: background .1s;
}
.cliente-item:hover { background: var(--bg2); }
.cliente-item:last-child { border-bottom: none; }
.cliente-info { flex: 1; }
.cliente-name { font-size: 13px; font-weight: 600; }
.cliente-sub { font-size: 11px; color: var(--text3); }
.cliente-del { background: none; border: none; cursor: pointer; color: var(--red); font-size: 15px; padding: 2px 6px; border-radius: 4px; opacity: .6; }
.cliente-del:hover { opacity: 1; background: var(--red-bg); }

/* RESPONSIVE */
@media (max-width: 640px) {
  .form-grid-4 { grid-template-columns: 1fr 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .bottom-section { grid-template-columns: 1fr; }
  .bottom-left { border-right: none; border-bottom: 1px solid var(--border); }
  .mf-two { grid-template-columns: 1fr; }
}

/* PRINT MEDIA */
@media print {
  body { background: #fff; padding: 0; }
  .top-bar, .print-actions, .no-print { display: none !important; }
  .list-view, .form-view { display: none !important; }
  .print-view { display: block !important; }
  #printArea { border: none; padding: 0; box-shadow: none; border-radius: 0; }
  .app { padding: 0; }
}
