/* =========================================================================
   TATA POWER-DDL Walk-in Complaint Register Stylesheet
   - Exact Replica of Physical Register (Page 075, Zone C 120 MGP)
   - Mobile-Friendly Viewport Responsive Design (Dual View: Cards + Sheet)
   - A4 Landscape Unclipped Print & High-Res PDF Styling
   ========================================================================= */

:root {
  --tp-blue: #0a1e42;
  --tp-navy: #1e3a8a;
  --tp-cyan: #00a4e4;
  --tp-accent: #0284c7;
  --tp-success: #16a34a;
  --tp-danger: #dc2626;
  --tp-warning: #f59e0b;
  --bg-main: #f1f5f9;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #cbd5e1;
  --radius: 12px;
  --shadow: 0 4px 16px -2px rgba(10, 30, 66, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Noto Sans Devanagari', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 60px;
  overflow-x: hidden;
}

/* ---------------------------------------------------------------------------
   Header Navigation
   --------------------------------------------------------------------------- */
.app-header {
  background: linear-gradient(135deg, #0a1e42 0%, #1e3a8a 100%);
  color: #fff;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(10, 30, 66, 0.25);
  border-bottom: 3px solid #00a4e4;
}

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

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-circle {
  width: 44px;
  height: 44px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #0a1e42;
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  flex-shrink: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-tag {
  background: #00a4e4;
  color: #0a1e42;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
}

.brand-sub {
  font-size: 12px;
  color: #93c5fd;
  margin-top: 2px;
  line-height: 1.3;
}

.header-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.meta-pill {
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
   Container & Layout
   --------------------------------------------------------------------------- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 12px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--tp-blue);
  flex-wrap: wrap;
  gap: 6px;
}

/* ---------------------------------------------------------------------------
   Top Shift Summary Grid (Responsive)
   --------------------------------------------------------------------------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}

.summary-val {
  font-size: 26px;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 4px;
}

.summary-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ---------------------------------------------------------------------------
   Form Elements & Voice Mic
   --------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 5px;
}

.input-text {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px; /* >= 16px or 15px prevents mobile safari auto-zoom issues */
  color: var(--text-main);
  background: #fff;
  transition: all 0.2s ease;
}

.input-text:focus {
  outline: none;
  border-color: var(--tp-cyan);
  box-shadow: 0 0 0 3px rgba(0, 164, 228, 0.15);
}

.input-with-mic {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.input-with-mic .input-text {
  flex: 1;
}

.mic-btn {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: #0284c7;
  border-radius: 8px;
  width: 44px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.mic-btn:hover {
  background: #e0f2fe;
  border-color: #0284c7;
}

.mic-btn.listening {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #ef4444 !important;
  animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.quick-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.chip-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: #e2e8f0;
}

.chip-btn.selected {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
}

/* Action Buttons */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-pdf {
  background: linear-gradient(135deg, #15803d 0%, #16a34a 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}
.btn-pdf:hover {
  background: linear-gradient(135deg, #166534 0%, #15803d 100%);
  transform: translateY(-1px);
}

.btn-print {
  background: linear-gradient(135deg, #0a1e42 0%, #1e3a8a 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(10, 30, 66, 0.25);
}
.btn-print:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

/* ---------------------------------------------------------------------------
   View Switcher Bar (Mobile Friendly)
   --------------------------------------------------------------------------- */
.view-toggle-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
}

.toggle-tab {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #475569;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toggle-tab.active {
  background: #fff;
  color: #0a1e42;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Scroll helper indicator on mobile */
.scroll-indicator-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eff6ff;
  color: #1e40af;
  border: 1px dashed #93c5fd;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  margin-bottom: 10px;
}

/* ---------------------------------------------------------------------------
   EXACT REPLICA OF PHYSICAL REGISTER SHEET (TATA POWER-DDL PAGE 075)
   --------------------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.register-container {
  background: #fff;
  border: 2px solid #000;
  padding: 16px;
  color: #000;
  min-width: 1100px; /* Maintains physical ledger structure on screen without collapsing */
}

.register-header {
  text-align: center;
  border-bottom: 2px solid #000;
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.reg-title-en {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #000;
  font-family: 'Arial Black', Impact, sans-serif;
}

.reg-sub-en {
  font-size: 12px;
  font-weight: 700;
  color: #000;
}

.reg-title-hi {
  font-size: 18px;
  font-weight: 900;
  margin-top: 4px;
  color: #000;
}

.reg-meta-row {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 6px;
  border-top: 1px solid #000;
  font-size: 12.5px;
  font-weight: 700;
  color: #000;
  flex-wrap: wrap;
  gap: 8px;
}

/* Exact Register Table Layout */
.register-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
  color: #000;
}

.register-table th, .register-table td {
  border: 1px solid #000;
  padding: 6px 4px;
  text-align: center;
  vertical-align: middle;
  word-break: break-word;
}

.register-table th {
  background: #f1f5f9;
  font-weight: 800;
  font-size: 10px;
  line-height: 1.25;
}

.register-table tr:hover td {
  background-color: #f8fafc;
}

/* Status Badges */
.status-pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-resolved {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.status-pending {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

/* Bottom Shift-wise Summary Box */
.shift-summary-box {
  margin-top: 14px;
  border: 1.5px solid #000;
  padding: 10px;
  background: #fff;
  page-break-inside: avoid;
}

.shift-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 6px;
}

.shift-summary-table th, .shift-summary-table td {
  border: 1px solid #000;
  padding: 6px 4px;
  text-align: center;
}

.shift-summary-table th {
  background: #f8fafc;
  font-weight: 800;
  font-size: 10px;
}

.signatures-row {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 10px;
  border-top: 1px dashed #000;
  font-size: 12px;
  font-weight: 700;
  page-break-inside: avoid;
}

.derc-footer-note {
  margin-top: 10px;
  font-size: 9.5px;
  color: #475569;
  font-style: italic;
  line-height: 1.3;
  text-align: left;
}

/* ---------------------------------------------------------------------------
   Mobile Card View (Clean layout on phones)
   --------------------------------------------------------------------------- */
.mobile-cards-container {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.complaint-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  border-left: 5px solid #0a1e42;
}

.complaint-card.resolved {
  border-left-color: #16a34a;
}

.complaint-card.pending {
  border-left-color: #f59e0b;
}

.complaint-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.complaint-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  margin: 8px 0;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 30, 66, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #64748b;
  line-height: 1;
}

/* Floating Voice Banner */
.voice-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0a1e42;
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 700;
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  border: 2px solid #00a4e4;
  width: 90%;
  max-width: 400px;
  justify-content: space-between;
}

.voice-banner.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-5px);
}

/* ---------------------------------------------------------------------------
   RESPONSIVE MEDIA QUERIES (Small Screens & Mobile Viewport)
   --------------------------------------------------------------------------- */
@media screen and (max-width: 768px) {
  .app-header {
    padding: 10px 12px;
  }
  .brand-title {
    font-size: 16px;
  }
  .brand-logo-circle {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
  .header-meta {
    width: 100%;
    justify-content: space-between;
  }
  .meta-pill {
    font-size: 11px;
    padding: 4px 8px;
  }
  .container {
    padding: 10px 8px;
  }
  
  /* Top summary becomes a 2/3-column responsive grid */
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .summary-grid .summary-card:last-child {
    grid-column: 1 / -1;
  }
  .summary-val {
    font-size: 22px;
  }
  .summary-lbl {
    font-size: 10.5px;
  }

  /* View switchers become visible on mobile */
  .view-toggle-bar {
    width: 100%;
    display: flex;
  }
  .toggle-tab {
    flex: 1;
    justify-content: center;
    font-size: 12px;
    padding: 8px 6px;
  }

  /* Show mobile cards when in cards view */
  body.view-cards .mobile-cards-container {
    display: flex;
  }
  body.view-cards .table-responsive {
    display: none;
  }
  body.view-cards .scroll-indicator-banner {
    display: none;
  }
}

/* ---------------------------------------------------------------------------
   DITTO PRINT STYLESHEET (A4 Landscape, Exact 1:1 Replica, No Clipping)
   --------------------------------------------------------------------------- */
@page {
  size: A4 landscape;
  margin: 5mm 4mm;
}

@media print {
  *, *:before, *:after {
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  html, body {
    width: 100% !important;
    height: auto !important;
    background: #fff !important;
    color: #000 !important;
    font-size: 8.5pt !important;
    line-height: 1.25 !important;
    padding: 0 !important;
    margin: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Strictly hide everything except the exact physical register container */
  .app-header,
  .summary-grid,
  #complaintFormCard,
  .filter-card,
  .view-toggle-bar,
  .mobile-cards-container,
  .scroll-indicator-banner,
  .modal-overlay,
  .voice-banner,
  .btn-no-print {
    display: none !important;
  }

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

  .table-responsive {
    overflow: visible !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
  }

  .register-container {
    display: block !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    border: 1.5px solid #000 !important;
    padding: 6px !important;
    margin: 0 !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .register-header {
    border-bottom: 1.5px solid #000 !important;
    padding-bottom: 6px !important;
    margin-bottom: 6px !important;
  }

  .reg-title-en {
    font-size: 14pt !important;
  }

  .reg-title-hi {
    font-size: 12pt !important;
  }

  .reg-sub-en {
    font-size: 8pt !important;
  }

  .reg-meta-row {
    font-size: 8pt !important;
    margin-top: 4px !important;
    padding-top: 3px !important;
    border-top: 1px solid #000 !important;
  }

  /* Table styling for exact A4 sheet without clipping */
  .register-table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 7.5pt !important;
    line-height: 1.2 !important;
  }

  .register-table th, .register-table td {
    border: 1px solid #000 !important;
    padding: 3px 2px !important;
    text-align: center !important;
    vertical-align: middle !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }

  .register-table th {
    background: #e2e8f0 !important;
    font-weight: 800 !important;
    font-size: 7pt !important;
    line-height: 1.2 !important;
  }

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

  /* Shift summary box */
  .shift-summary-box {
    border: 1.5px solid #000 !important;
    margin-top: 6px !important;
    padding: 4px !important;
    page-break-inside: avoid !important;
    background: #fff !important;
  }

  .shift-summary-table {
    width: 100% !important;
    font-size: 7pt !important;
    border-collapse: collapse !important;
  }

  .shift-summary-table th, .shift-summary-table td {
    border: 1px solid #000 !important;
    padding: 2.5px 2px !important;
  }

  .shift-summary-table th {
    background: #f1f5f9 !important;
    font-weight: 800 !important;
  }

  .signatures-row {
    margin-top: 8px !important;
    padding-top: 4px !important;
    border-top: 1px dashed #000 !important;
    font-size: 7.5pt !important;
    page-break-inside: avoid !important;
  }

  .derc-footer-note {
    display: block !important;
    margin-top: 4px !important;
    font-size: 6pt !important;
    color: #111 !important;
  }
}
