/* ==========================================================================
   TATA POWER-DDL JSA & LMRA CHECKLIST STYLES
   Mobile-First, Zero-Overflow, High-Contrast Field Usability Design
   ========================================================================== */

:root {
  --tp-blue-dark: #003666;
  --tp-blue: #00508f;
  --tp-blue-light: #e8f1f8;
  --tp-yellow: #f5a623;
  --tp-yellow-light: #fff8e8;
  --tp-red: #d32f2f;
  --tp-red-light: #ffebee;
  --tp-green: #2e7d32;
  --tp-green-light: #e8f5e9;
  --bg-page: #f0f3f8;
  --bg-card: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border-color: #cbd5e1;
  --border-light: #e2e8f0;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Devanagari", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.45;
  font-size: 14px;
}

/* Base Container */
.app-container {
  width: 100%;
  max-width: 850px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* Header */
.app-header {
  background: linear-gradient(135deg, var(--tp-blue-dark) 0%, var(--tp-blue) 100%);
  color: #ffffff;
  padding: 12px 14px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-badge {
  background: #ffffff;
  color: var(--tp-blue);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.brand-titles h1 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

.brand-titles span {
  font-size: 11px;
  color: #cbd5e1;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 11px;
  color: #fff;
  cursor: pointer;
}

.user-badge span.dot {
  width: 7px;
  height: 7px;
  background-color: #4ade80;
  border-radius: 50%;
  display: inline-block;
}

/* Nav Tabs */
.app-nav {
  display: flex;
  background: #ffffff;
  border-bottom: 2px solid var(--border-light);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.app-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  flex: 1;
  min-width: 80px;
  text-align: center;
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.2s ease;
}

.nav-tab.active {
  color: var(--tp-blue);
  border-bottom-color: var(--tp-blue);
  background: var(--tp-blue-light);
}

.nav-tab-icon {
  font-size: 16px;
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 12px 14px 80px 14px;
}

/* Golden Safety Banner */
.safety-banner {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  border-left: 5px solid var(--tp-yellow);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 14px;
}

.safety-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.safety-tag {
  background: #b45309;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.ppe-icons-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0;
  text-align: center;
}

.ppe-icon-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 6px 2px;
  box-shadow: var(--shadow-sm);
}

.ppe-icon-box .icon {
  font-size: 20px;
  display: block;
}

.ppe-icon-box .text {
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  line-height: 1.1;
  margin-top: 2px;
}

.safety-rule-notice {
  font-size: 11px;
  font-weight: 700;
  color: var(--tp-red);
  text-align: center;
  margin-top: 4px;
}

/* Sections & Cards */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
}

.card-header {
  background: #f8fafc;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--tp-blue-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #475569;
}
.badge-tag.primary { background: var(--tp-blue-light); color: var(--tp-blue); }
.badge-tag.danger { background: var(--tp-red-light); color: var(--tp-red); }

.card-body {
  padding: 12px;
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group.col-span-2 {
  grid-column: span 2;
}
@media (max-width: 480px) {
  .form-group.col-span-2 {
    grid-column: span 1;
  }
}

.form-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-label .sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #1e293b;
  background: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--tp-blue);
  box-shadow: 0 0 0 3px rgba(0, 80, 143, 0.15);
}

.form-textarea {
  resize: vertical;
  min-height: 55px;
}

/* Compact Checklist Item */
.check-item {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 10px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s;
}

.check-item:last-child {
  margin-bottom: 0;
}

.check-item.answered-yes {
  border-left: 4px solid var(--tp-green);
  background: #fbfdfb;
}

.check-item.answered-no {
  border-left: 4px solid var(--tp-red);
  background: #fdfafa;
}

.check-item.answered-na {
  border-left: 4px solid #94a3b8;
  background: #f8fafc;
}

.check-item-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.check-num {
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.check-text {
  font-size: 12.5px;
  color: #1e293b;
  flex: 1;
  line-height: 1.4;
}

.check-text .subtext {
  font-size: 11px;
  color: var(--text-secondary);
  display: block;
  margin-top: 3px;
}

/* 3-State Toggle Group */
.toggle-group {
  display: flex;
  gap: 6px;
  width: 100%;
}

.toggle-btn {
  flex: 1;
  padding: 7px 4px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
  user-select: none;
}

.toggle-btn.btn-yes:hover, .toggle-btn.btn-yes.active {
  background: var(--tp-green);
  border-color: var(--tp-green);
  color: #ffffff;
}

.toggle-btn.btn-no:hover, .toggle-btn.btn-no.active {
  background: var(--tp-red);
  border-color: var(--tp-red);
  color: #ffffff;
}

.toggle-btn.btn-na:hover, .toggle-btn.btn-na.active {
  background: #64748b;
  border-color: #64748b;
  color: #ffffff;
}

/* Action Required Box when 'No' is selected */
.action-box {
  background: #fff5f5;
  border: 1px dashed var(--tp-red);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 11px;
  color: #991b1b;
  display: none;
  animation: fadeIn 0.2s ease;
}

.action-box.show {
  display: block;
}

.action-box strong {
  display: block;
  margin-bottom: 2px;
}

/* Risky / Hazards Dynamic Table */
.risk-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  margin-bottom: 8px;
  align-items: center;
}

@media (max-width: 480px) {
  .risk-row {
    grid-template-columns: 1fr;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px;
  }
}

.btn-icon {
  background: none;
  border: none;
  color: var(--tp-red);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Digital Signature Box */
.signature-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: #ffffff;
  margin-bottom: 10px;
}

.signature-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--tp-blue-dark);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.signature-canvas {
  width: 100%;
  height: 100px;
  background: #fafafa;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  touch-action: none;
  cursor: crosshair;
}

.signature-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.btn-xs {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: #f1f5f9;
  cursor: pointer;
}

/* Multi-Pole Inspection Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  min-width: 500px;
}

.custom-table th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  padding: 8px 6px;
  border: 1px solid var(--border-light);
  text-align: left;
}

.custom-table td {
  padding: 6px;
  border: 1px solid var(--border-light);
  background: #ffffff;
}

/* Fixed Bottom Submit Bar */
.bottom-submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  padding: 10px 14px;
  box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 90;
  max-width: 850px;
  margin: 0 auto;
}

.btn-primary {
  background: linear-gradient(135deg, var(--tp-blue) 0%, var(--tp-blue-dark) 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  cursor: pointer;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 3px 8px rgba(0, 80, 143, 0.3);
  transition: transform 0.1s, opacity 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  cursor: pointer;
}

/* History / Records List */
.records-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.record-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--tp-blue);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.record-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.record-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.record-jsa {
  font-weight: 700;
  font-size: 13px;
  color: var(--tp-blue-dark);
}

.record-date {
  font-size: 11px;
  color: var(--text-muted);
}

.record-location {
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #ffffff;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

.modal-header {
  background: var(--tp-blue-dark);
  color: #ffffff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 14px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
}

.modal-body {
  padding: 14px;
  overflow-y: auto;
  font-size: 12.5px;
}

/* Login Card */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 400px;
  padding: 24px 20px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-brand-icon {
  width: 56px;
  height: 56px;
  background: var(--tp-blue-light);
  color: var(--tp-blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 12px auto;
}

.login-card h2 {
  font-size: 18px;
  color: var(--tp-blue-dark);
  margin-bottom: 4px;
}

.login-card p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

/* Reference Guidelines Cards */
.outage-rule-card {
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--tp-yellow);
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: #fffdfa;
}
.outage-rule-card strong {
  color: #b45309;
  font-size: 12px;
  display: block;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Print Layout - Formatted like the physical paper booklet */
@media print {
  body {
    background: #ffffff !important;
    font-size: 11px !important;
    color: #000000 !important;
  }
  .app-header, .app-nav, .bottom-submit-bar, .btn-icon, .btn-xs, .records-filter {
    display: none !important;
  }
  .app-container {
    box-shadow: none !important;
    max-width: 100% !important;
  }
  .form-card {
    border: 1px solid #94a3b8 !important;
    box-shadow: none !important;
    margin-bottom: 10px !important;
    page-break-inside: avoid;
  }
  .toggle-btn {
    border: 1px solid #000000 !important;
  }
  .toggle-btn.active {
    background: #e2e8f0 !important;
    color: #000000 !important;
    font-weight: bold !important;
  }
}
