/* styles.css */
:root {
  --primary: #1e3a8a;
  --primary-hover: #172554;
  --primary-light: #eff6ff;
  --accent: #2563eb;
  --success: #16a34a;
  --danger: #dc2626;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

body {
  background-color: #f1f5f9;
  color: var(--gray-800);
  min-height: 100vh;
}

/* Navbar */
.app-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  color: white;
  padding: 1rem 1.5rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-content {
  max-width: 1500px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem;
  border-radius: 0.5rem;
  font-size: 1.5rem;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand p {
  font-size: 0.8rem;
  opacity: 0.9;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Layout */
.main-container {
  max-width: 1550px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 1150px) {
  .main-container {
    grid-template-columns: 500px 1fr;
  }
}

/* Panels */
.panel {
  background: white;
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 1rem 1.25rem;
  background-color: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-body {
  padding: 1.25rem;
  overflow-y: auto;
}

/* Accordion sections */
.accordion-item {
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: all 0.2s ease;
}

.accordion-header {
  padding: 0.75rem 1rem;
  background-color: var(--gray-50);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-700);
  user-select: none;
}

.accordion-header:hover {
  background-color: var(--gray-100);
}

.accordion-header .acc-icon {
  transition: transform 0.2s ease;
}

.accordion-item.active .accordion-header .acc-icon {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding: 1rem;
  background-color: white;
  border-top: 1px solid var(--gray-200);
}

.accordion-item.active .accordion-content {
  display: block;
}

/* Form controls */
.form-group {
  margin-bottom: 0.85rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--gray-300);
  border-radius: 0.375rem;
  font-size: 0.85rem;
  color: var(--gray-900);
  background-color: white;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-help {
  font-size: 0.72rem;
  color: var(--gray-600);
  margin-top: 0.2rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary);
}

.btn-success {
  background-color: var(--success);
  color: white;
}
.btn-success:hover {
  background-color: #15803d;
}

.btn-outline {
  background-color: white;
  border-color: var(--gray-300);
  color: var(--gray-700);
}
.btn-outline:hover {
  background-color: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* Quick schedule pill buttons */
.days-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.day-chip {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 1rem;
  border: 1px solid var(--gray-300);
  background: white;
  cursor: pointer;
  user-select: none;
}

.day-chip.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Table styles */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  max-height: 480px;
  position: relative;
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.table-custom th {
  background-color: var(--gray-100);
  padding: 0.5rem 0.6rem;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 5;
}

.table-custom td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--gray-200);
  vertical-align: middle;
}

.table-custom tr:hover {
  background-color: var(--gray-50);
}

.table-custom tr.row-inactive {
  opacity: 0.5;
  background-color: #fafafa;
}

.table-custom input[type="time"] {
  padding: 0.25rem 0.4rem;
  font-size: 0.78rem;
  width: 95px;
}

.table-custom input[type="number"] {
  padding: 0.25rem 0.4rem;
  font-size: 0.78rem;
  width: 60px;
}

/* Totals summary card */
.summary-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  color: white;
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
  box-shadow: var(--shadow);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.summary-item {
  display: flex;
  flex-direction: column;
}

.summary-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.summary-value {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.summary-words {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 0.8rem;
  font-style: italic;
  opacity: 0.95;
}

/* Preview Tabs */
.tabs-nav {
  display: flex;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.25rem 0.5rem 0 0.5rem;
  gap: 0.25rem;
}

.tab-btn {
  padding: 0.6rem 1.1rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gray-600);
  border-radius: 0.375rem 0.375rem 0 0;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--gray-900);
  background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
  background: white;
  color: var(--accent);
  border-top: 3px solid var(--accent);
  box-shadow: 0 -2px 5px rgba(0,0,0,0.02);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* Document Paper Preview (Letter Size Feel) */
.paper-viewport {
  background-color: #64748b;
  padding: 1.5rem;
  overflow: auto;
  display: flex;
  justify-content: center;
  border-radius: 0 0 0.75rem 0.75rem;
  min-height: 850px;
}

.paper-sheet {
  background: white;
  width: 216mm; /* Letter width */
  min-height: 279mm; /* Letter height */
  padding: 25mm 25mm 20mm 25mm;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  box-sizing: border-box;
  color: #000;
  font-family: Arial, Helvetica, sans-serif;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* EXACT STYLES FOR THE ATTACHED PDF (Cuenta de Cobro / Documento Soporte) */
.soporte-doc {
  line-height: 1.4;
  font-size: 11pt;
  color: #000;
  box-sizing: border-box;
  width: 100%;
}

.soporte-header-date {
  font-size: 11pt;
  margin-bottom: 2rem;
  text-align: left;
}

.soporte-title {
  text-align: center;
  font-weight: bold;
  font-size: 11.5pt;
  margin-bottom: 1.8rem;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.soporte-title .consecutivo-red {
  color: #dc2626;
  font-weight: bold;
}

.soporte-debtor {
  text-align: center;
  font-weight: bold;
  font-size: 11.5pt;
  margin-bottom: 1.3rem;
  line-height: 1.3;
}

.soporte-debe-a {
  text-align: center;
  font-weight: bold;
  font-size: 11.5pt;
  margin-bottom: 1.3rem;
  letter-spacing: 0.05em;
}

.soporte-beneficiary {
  text-align: center;
  font-weight: bold;
  font-size: 11.5pt;
  margin-bottom: 1.8rem;
  line-height: 1.35;
}

.soporte-concept-paragraph {
  text-align: justify;
  font-size: 11pt;
  margin-bottom: 1.8rem;
  line-height: 1.5;
}

.soporte-bank-paragraph {
  text-align: justify;
  font-size: 11pt;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.soporte-bank-paragraph .red-highlight {
  color: #dc2626;
}

.soporte-closing {
  font-size: 11pt;
  margin-bottom: 1rem;
}

.soporte-signature-container {
  margin-bottom: 1.8rem;
  position: relative;
  min-height: 80px;
}

.signature-img {
  max-height: 65px;
  max-width: 220px;
  display: block;
  margin-bottom: -12px;
}

.soporte-signer-info {
  font-size: 11pt;
  line-height: 1.35;
}

.soporte-signer-info .signer-name {
  font-weight: normal;
}

.soporte-retention-box {
  margin-top: auto; /* Empujar al fondo */
  font-size: 7.2pt;
  line-height: 1.35;
  text-align: justify;
  border-top: 1px solid #d1d5db;
  padding-top: 0.5rem;
}

.soporte-retention-box strong {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 7.2pt;
}

/* Detailed Hours Report Styles */
.report-doc {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 9pt;
  color: #1e293b;
  box-sizing: border-box;
  width: 100%;
}

.report-header {
  border-bottom: 2px solid #1e3a8a;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.report-title h2 {
  font-size: 13pt;
  color: #1e3a8a;
  font-weight: 700;
  text-transform: uppercase;
}

.report-title p {
  color: #64748b;
  font-size: 8pt;
}

.report-badge {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 0.35rem 0.75rem;
  border-radius: 0.375rem;
  text-align: right;
  font-size: 8pt;
}

.report-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.8rem 1rem;
  margin-bottom: 1.2rem;
}

.report-meta-grid .meta-col p {
  margin-bottom: 0.25rem;
  font-size: 8.5pt;
}

.report-meta-grid strong {
  color: #334155;
}

.report-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.report-kpi {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 0.6rem;
  border-radius: 0.375rem;
  text-align: center;
}

.report-kpi .kpi-label {
  font-size: 7pt;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
}

.report-kpi .kpi-num {
  font-size: 11pt;
  font-weight: bold;
  color: #0f172a;
  margin-top: 0.1rem;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 8pt;
}

.report-table th {
  background-color: #1e3a8a;
  color: white;
  padding: 0.45rem 0.5rem;
  text-align: left;
  font-weight: 600;
}

.report-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.report-table tr:nth-child(even) {
  background-color: #f8fafc;
}

.report-table tr.inactive-day {
  color: #94a3b8;
  background-color: #fff;
}

.report-table tfoot td {
  background-color: #f1f5f9;
  font-weight: bold;
  border-top: 2px solid #1e3a8a;
  border-bottom: none;
  font-size: 8.5pt;
}

.report-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-top: 2rem;
}

.sig-box {
  border-top: 1px solid #334155;
  padding-top: 0.4rem;
  font-size: 8pt;
}

/* Signature Canvas Modal / Controls */
.signature-pad-container {
  border: 1px dashed var(--gray-300);
  border-radius: 0.375rem;
  background-color: #fafafa;
  position: relative;
  margin-bottom: 0.5rem;
}

canvas#sigCanvas {
  display: block;
  width: 100%;
  height: 120px;
  cursor: crosshair;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background-color: var(--gray-900);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.25s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.report-table thead {
  display: table-header-group;
}

.report-table tfoot {
  display: table-footer-group;
}

.report-table tr {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

.report-meta-grid, 
.report-kpis, 
.report-signatures, 
.soporte-signature-container, 
.soporte-retention-box {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
}

/* Print CSS */
@media print {
  @page {
    size: letter portrait;
    margin: 12mm 15mm 12mm 15mm;
  }

  *, *:before, *:after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .app-header,
  .panel:first-child,
  .tabs-nav,
  .panel-header,
  .toast,
  button {
    display: none !important;
  }

  .main-container {
    display: block !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .panel {
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .paper-viewport {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    display: block !important;
    min-height: auto !important;
  }

  .paper-sheet {
    box-shadow: none !important;
    margin: 0 auto !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
  }

  /* Only print the active tab */
  .tab-pane:not(.active) {
    display: none !important;
  }

  .tab-pane.active {
    display: block !important;
  }
}
