/* ===================================
   BRITANNIA ADMIN PORTAL - MAIN STYLES
   =================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --brand-red:      #CC0000;
  --brand-red-dark: #A00000;
  --brand-red-light:#FFF0F0;
  --brand-orange:   #F26522;
  --brand-gold:     #F9A825;
  --white:          #FFFFFF;
  --gray-50:        #F8F9FA;
  --gray-100:       #F1F3F5;
  --gray-200:       #E9ECEF;
  --gray-300:       #DEE2E6;
  --gray-400:       #CED4DA;
  --gray-500:       #ADB5BD;
  --gray-600:       #6C757D;
  --gray-700:       #495057;
  --gray-800:       #343A40;
  --gray-900:       #212529;
  --green:          #28A745;
  --green-light:    #D4EDDA;
  --yellow:         #FFC107;
  --yellow-light:   #FFF3CD;
  --red-light:      #F8D7DA;
  --blue:           #007BFF;
  --blue-light:     #D1ECF1;
  --sidebar-width:  260px;
  --header-height:  64px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.12);
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --transition:     all .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ── LAYOUT ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed { width: 64px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-200);
  min-height: var(--header-height);
  background: var(--brand-red);
}

.sidebar-logo img { width: 100px; filter: brightness(0) invert(1); }
.sidebar-logo .logo-text {
  font-size: 11px;
  color: rgba(255,255,255,.85);
  font-weight: 500;
  white-space: nowrap;
}

.collapsed .sidebar-logo img { width: 32px; }
.collapsed .sidebar-logo .logo-text { display: none; }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--gray-500);
  padding: 10px 20px 4px;
}
.collapsed .nav-section-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--brand-red-light);
  color: var(--brand-red);
  border-left-color: var(--brand-red);
}

.nav-item.active {
  background: var(--brand-red-light);
  color: var(--brand-red);
  border-left-color: var(--brand-red);
  font-weight: 600;
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-item .nav-label { white-space: nowrap; }
.collapsed .nav-item .nav-label { display: none; }
.collapsed .nav-item { justify-content: center; padding: 12px; }
.collapsed .nav-item i { width: auto; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 10px;
}
.collapsed .sidebar-footer { justify-content: center; }
.sidebar-footer .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-red);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-footer .user-info { overflow: hidden; }
.sidebar-footer .user-name { font-size: 13px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-role { font-size: 11px; color: var(--gray-500); }
.collapsed .sidebar-footer .user-info { display: none; }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}
.main-content.expanded { margin-left: 64px; }

/* ── TOP BAR ── */
.topbar {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.btn-toggle {
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600); transition: var(--transition);
  font-size: 16px;
}
.btn-toggle:hover { background: var(--gray-100); color: var(--brand-red); }

.topbar-title { font-size: 17px; font-weight: 700; color: var(--gray-900); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-right .badge-plant {
  display: flex; align-items: center; gap: 6px;
  background: var(--brand-red-light);
  color: var(--brand-red);
  padding: 5px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}

.btn-logout {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--gray-300);
  color: var(--gray-600); padding: 6px 14px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: var(--transition);
}
.btn-logout:hover { border-color: var(--brand-red); color: var(--brand-red); background: var(--brand-red-light); }

/* ── PAGE CONTENT ── */
.page-content {
  padding: 24px;
  flex: 1;
}

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-header p { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}
.card-header h3 { font-size: 14px; font-weight: 700; color: var(--gray-900); }
.card-body { padding: 20px; }

/* ── STAT CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.red   { background: var(--brand-red-light); color: var(--brand-red); }
.stat-icon.green { background: var(--green-light);     color: var(--green); }
.stat-icon.orange{ background: #FFF3E0;                color: var(--brand-orange); }
.stat-icon.blue  { background: #E3F2FD;                color: var(--blue); }
.stat-icon.yellow{ background: var(--yellow-light);    color: #856404; }

.stat-value { font-size: 28px; font-weight: 800; color: var(--gray-900); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 2px; font-weight: 500; }
.stat-sub   { font-size: 11px; color: var(--gray-400); margin-top: 4px; }

/* ── TABLE ── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--gray-50);
  padding: 11px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 12px 14px;
  color: var(--gray-700);
  vertical-align: middle;
}

.td-sno { color: var(--gray-400); font-weight: 600; width: 44px; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-success   { background: var(--green-light);    color: #155724; }
.badge-warning   { background: var(--yellow-light);   color: #856404; }
.badge-danger    { background: var(--red-light);      color: #721C24; }
.badge-info      { background: var(--blue-light);     color: #0C5460; }
.badge-secondary { background: var(--gray-200);       color: var(--gray-700); }
.badge-daily     { background: #E3F2FD;               color: #1565C0; }
.badge-weekly    { background: #E8F5E9;               color: #2E7D32; }
.badge-monthly   { background: #F3E5F5;               color: #6A1B9A; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: var(--transition); text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--brand-red); color: white; }
.btn-primary:hover { background: var(--brand-red-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-success   { background: var(--green); color: white; }
.btn-success:hover { background: #218838; }
.btn-outline   { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--brand-red); color: var(--brand-red); background: var(--brand-red-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--gray-200); background: var(--white);
  color: var(--gray-600); font-size: 13px; transition: var(--transition);
}
.btn-icon:hover { border-color: var(--brand-red); color: var(--brand-red); background: var(--brand-red-light); }

/* ── FORM ELEMENTS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }

.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--gray-300); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--gray-800); background: var(--white);
  transition: var(--transition); font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--brand-red); box-shadow: 0 0 0 3px rgba(204,0,0,.1); }
.form-control::placeholder { color: var(--gray-400); }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236C757D' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

/* ── FILTER BAR ── */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.filter-bar .form-control { width: auto; min-width: 140px; }
.filter-bar .search-input { min-width: 220px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 780px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95) translateY(10px);
  transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal.modal-lg { max-width: 960px; }
.modal.modal-sm { max-width: 480px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; background: var(--white); z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-900); }

.modal-body { padding: 24px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
}

.btn-close {
  background: none; border: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500); font-size: 16px; transition: var(--transition);
}
.btn-close:hover { background: var(--gray-100); color: var(--gray-800); }

/* ── DETAIL VIEW (Task Details) ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.detail-item { }
.detail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500); margin-bottom: 4px; }
.detail-value { font-size: 14px; font-weight: 600; color: var(--gray-800); }

.question-table table thead th { background: var(--brand-red); color: white; border-bottom: none; font-size: 11px; }
.question-table table tbody tr:hover { background: var(--brand-red-light); }

.answer-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.answer-yes { color: var(--green); font-weight: 700; }
.answer-no  { color: var(--brand-red); font-weight: 700; }
.answer-val { font-weight: 600; color: var(--gray-800); }
.photo-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--blue-light); color: #0C5460;
  padding: 2px 8px; border-radius: 12px; font-size: 11px;
}

.section-header-row td {
  background: var(--gray-800) !important;
  color: white !important;
  font-weight: 700 !important;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 14px !important;
}

/* ── STATUS DOT ── */
.status-dot { display: inline-flex; align-items: center; gap: 5px; }
.status-dot::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.completed::before { background: var(--green); }
.status-dot.pending::before   { background: var(--yellow); }
.status-dot.deviation::before { background: var(--brand-red); }

/* ── CHART CONTAINER ── */
.chart-container { position: relative; height: 260px; }

/* ── PAGINATION ── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-top: 1px solid var(--gray-200);
  font-size: 12px; color: var(--gray-500);
}
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--gray-300); background: var(--white);
  cursor: pointer; font-size: 12px; transition: var(--transition);
  display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.page-btn:hover { border-color: var(--brand-red); color: var(--brand-red); }
.page-btn.active { background: var(--brand-red); border-color: var(--brand-red); color: white; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--gray-500);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; color: var(--gray-300); display: block; }
.empty-state p { font-size: 14px; font-weight: 500; }

/* ── DEVIATION SEVERITY ── */
.sev-high   { color: var(--brand-red); font-weight: 700; }
.sev-medium { color: var(--brand-orange); font-weight: 700; }
.sev-low    { color: var(--brand-gold); font-weight: 700; }

/* ── REPORT CARDS ── */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.report-grid .card { height: 100%; }

/* ── LOADING ── */
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand-red);
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { text-align: center; padding: 40px; }

/* ── TOAST ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--gray-900); color: white;
  padding: 12px 18px; border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500;
  animation: slideUp .3s ease;
  max-width: 320px;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--brand-red); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .report-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control { width: 100%; }
}

/* ── UTILITY ── */
.text-red    { color: var(--brand-red); }
.text-green  { color: var(--green); }
.text-muted  { color: var(--gray-500); }
.fw-700      { font-weight: 700; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.flex-wrap   { flex-wrap: wrap; }
.ms-auto     { margin-left: auto; }
.w-100       { width: 100%; }
.text-center { text-align: center; }
.no-wrap     { white-space: nowrap; }

/* ── PLANT OVERVIEW CARD ── */
.plant-ov-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.plant-ov-card:hover { box-shadow: var(--shadow-md); }
.plant-ov-header {
  background: var(--brand-red);
  color: white; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.plant-ov-header h4 { font-size: 15px; font-weight: 700; }
.plant-ov-body { padding: 16px 18px; }
.plant-stat-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.plant-stat-row:last-child { border-bottom: none; }
.plant-stat-label { color: var(--gray-500); }
.plant-stat-val   { font-weight: 700; color: var(--gray-800); }

/* ── REPORT EXPORT BTN ── */
.export-bar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 16px; }
