/* Design System - Slate Premium Executive Dashboard */

:root {
  --primary: #2563EB; /* Blue 600 */
  --primary-hover: #1D4ED8;
  --primary-light: rgba(37, 99, 235, 0.08);
  
  --success: #10B981; /* Emerald 500 */
  --success-light: rgba(16, 185, 129, 0.08);
  
  --warning: #F59E0B; /* Amber 500 */
  --warning-light: rgba(245, 158, 11, 0.08);
  
  --danger: #EF4444; /* Red 500 */
  --danger-light: rgba(239, 68, 68, 0.08);
  
  --bg-canvas: #F8FAFC; /* Slate 50 */
  --bg-card: #FFFFFF;
  --border: #E2E8F0; /* Slate 200 */
  
  --text-main: #0F172A; /* Slate 900 */
  --text-muted: #475569; /* Slate 600 */
  --text-dim: #94A3B8; /* Slate 400 */
  
  --radius: 12px;
  --radius-sm: 8px;
  
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.03), 0 2px 4px -1px rgba(15, 23, 42, 0.02);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.04), 0 4px 6px -2px rgba(15, 23, 42, 0.02);
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Roboto', 'Segoe UI', -apple-system, sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
}

.brand-logo-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
}

/* APP LAYOUT STRUCTURE */
.app-layout {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* SIDEBAR STYLING */
.sidebar {
  width: 260px;
  background-color: #0F172A; /* Slate 900 - Dark mode sidebar */
  color: #F8FAFC;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1E293B;
  flex-shrink: 0;
  z-index: 100;
  transition: var(--transition);
  position: relative;
}

.sidebar-close-btn {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: #94A3B8;
  font-size: 1.8rem;
  cursor: pointer;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid #1E293B;
}

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

.brand-icon {
  font-size: 2rem;
}

.sidebar-brand h2 {
  font-family: 'Roboto', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar-brand p {
  font-size: 0.72rem;
  color: #94A3B8;
  font-weight: 500;
}

.sidebar-nav {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: #94A3B8;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
  transition: var(--transition);
  width: 100%;
}

.nav-item:hover {
  background-color: #1E293B;
  color: #F8FAFC;
}

.nav-item.active {
  background-color: var(--primary);
  color: #FFFFFF;
}

.nav-icon {
  font-size: 1.15rem;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid #1E293B;
}

.timestamp-text {
  font-size: 0.72rem;
  color: #64748B;
  margin-bottom: 8px;
}

.theme-info {
  font-size: 0.75rem;
  color: #94A3B8;
}

/* SIDEBAR OVERLAY MASK FOR MOBILE */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 90;
}

/* MAIN CONTENT WRAPPER */
.main-layout {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
  position: relative;
}

/* TOP FILTER BAR */
.top-bar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  gap: 20px;
}

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

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
}

.top-bar-title h1 {
  font-family: 'Roboto', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.top-bar-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

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

.filter-group label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.filter-control {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  min-width: 120px;
  transition: var(--transition);
}

.filter-control:focus {
  border-color: var(--primary);
}

.btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary {
  background-color: var(--bg-canvas);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--border);
  color: var(--text-main);
}

/* SYNC GOOGLE SHEET INTERFACES */
.sync-container {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: var(--bg-canvas);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-loading .sync-dot {
  background-color: var(--warning);
  animation: pulse 1.2s infinite ease-in-out;
}
.status-loading { color: #B45309; }

.status-success .sync-dot {
  background-color: var(--success);
}
.status-success { color: var(--success); }

.status-error .sync-dot {
  background-color: var(--danger);
  animation: blink 0.8s infinite steps(2);
}
.status-error { color: var(--danger); }

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0.5; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.btn-sync {
  background: var(--primary);
  color: #FFFFFF;
  padding: 6px 10px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-sync:hover {
  background: var(--primary-hover);
}

.btn-sync-icon {
  font-size: 0.85rem;
}

.sync-spinning {
  display: inline-block;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* MAIN PANEL CONTAINER */
.main-content {
  padding: 24px 32px;
  flex-grow: 1;
  overflow-y: auto;
  background-color: var(--bg-canvas);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 24px;
  animation: fadeIn 0.25s ease-out;
}

.tab-panel.active {
  display: flex;
}

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

/* KPI GRID LAYOUT */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

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

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

.kpi-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.kpi-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.95rem;
}

.icon-blue { background: rgba(37, 99, 235, 0.1); color: var(--primary); }
.icon-indigo { background: rgba(99, 102, 241, 0.1); color: #6366f1; }
.icon-green { background: var(--success-light); color: var(--success); }
.icon-red { background: var(--danger-light); color: var(--danger); }
.icon-orange { background: rgba(249, 115, 22, 0.1); color: #f97316; }

.kpi-value {
  font-family: 'Roboto', sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* Specific red alarm for overdue KPI */
.warning-kpi {
  border-color: rgba(239, 68, 68, 0.3);
  background-color: rgba(239, 68, 68, 0.01);
}

.warning-kpi .kpi-value {
  color: var(--danger);
}

/* GENERAL CARD PANEL PANEL */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.card-red-border {
  border-color: rgba(239, 68, 68, 0.35);
  background-color: rgba(239, 68, 68, 0.01);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  gap: 16px;
}

.card-title {
  font-family: 'Roboto', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* MIDDLE ROW GRIDS */
.visuals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 20px;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 200px;
  max-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* GAUGE CHART SPECIFICS */
.gauge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.gauge-value {
  font-family: 'Roboto', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  margin-top: -30px;
  z-index: 2;
}

.gauge-status {
  font-size: 0.8rem;
  font-weight: 700;
  color: #D97706;
  margin-top: 4px;
  background-color: #FEF3C7;
  padding: 4px 10px;
  border-radius: 20px;
}

/* HEATMAP MATRIX TABLE */
.matrix-wrapper {
  padding-top: 6px;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.matrix-table th {
  padding: 10px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.matrix-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: center;
}

.td-priority-high {
  font-weight: 700;
  color: var(--danger);
  background-color: var(--danger-light);
  width: 90px;
}

.td-priority-medium {
  font-weight: 700;
  color: var(--warning);
  background-color: var(--warning-light);
  width: 90px;
}

.td-alert-danger {
  background-color: rgba(239, 68, 68, 0.05);
}

.matrix-project-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 6px;
  background-color: #F1F5F9;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  margin: 4px;
  text-align: left;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

/* BOTTOM GRIDS */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.badge {
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-gray { background: #F1F5F9; color: var(--text-muted); }

/* DATA TABLES */
.table-responsive {
  overflow-x: auto;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 12px 16px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background-color: var(--bg-canvas);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-main);
  vertical-align: middle;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background-color: rgba(248, 250, 252, 0.8);
}

.td-alert-danger {
  background-color: rgba(239, 68, 68, 0.02);
}

.td-alert-warning {
  background-color: rgba(245, 158, 11, 0.02);
}

/* PROGRESS BAR RENDER */
.progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.progress-bar-bg {
  flex-grow: 1;
  height: 6px;
  background-color: #E2E8F0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
}

/* TAB 2: PROGRESS & GANTT */
.single-row-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.split-row-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
}

/* LIST SELECTABLE */
.list-selectable {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  max-height: 400px;
}

.selectable-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  background-color: var(--bg-card);
  text-align: left;
}

.selectable-item:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.selectable-item.active {
  border-color: var(--primary);
  background-color: var(--primary);
  color: #FFFFFF;
}

.selectable-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.selectable-item-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.selectable-item.active .selectable-item-sub {
  color: rgba(255, 255, 255, 0.8);
}

/* RISK TAB AGGREGATIONS */
.risk-summary-boxes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.risk-box {
  padding: 16px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
}

.risk-high { background-color: var(--danger-light); border-color: rgba(239, 68, 68, 0.2); }
.risk-med { background-color: var(--warning-light); border-color: rgba(245, 158, 11, 0.2); }
.risk-low { background-color: var(--success-light); border-color: rgba(16, 185, 129, 0.2); }

.risk-box-label { font-weight: 700; font-size: 0.82rem; }
.risk-box-value { font-family: 'Roboto', sans-serif; font-size: 1.45rem; font-weight: 700; }
.risk-high .risk-box-label, .risk-high .risk-box-value { color: var(--danger); }
.risk-med .risk-box-label, .risk-med .risk-box-value { color: #D97706; }
.risk-low .risk-box-label, .risk-low .risk-box-value { color: var(--success); }

.risk-governance-advice {
  margin-top: 8px;
  background-color: #F1F5F9;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.risk-governance-advice h4 {
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

/* RESPONSIVE DESIGN - MEDIA QUERIES */

@media (max-width: 1400px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 24px;
    gap: 12px;
  }
  .top-bar-right {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 1200px) {
  .visuals-grid {
    grid-template-columns: 1fr;
  }
  .split-row-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  /* Sidebar Mobile Overlay Activation */
  .sidebar {
    position: fixed;
    top: 0;
    left: -260px; /* Hidden off-canvas */
    height: 100vh;
    box-shadow: 10px 0 30px rgba(0,0,0,0.1);
  }
  
  .sidebar.open {
    left: 0; /* Slide in */
  }
  
  .sidebar-close-btn {
    display: block;
  }
  
  .mobile-menu-btn {
    display: block;
  }
  
  .sidebar.open + .sidebar-overlay {
    display: block;
  }
  
  .main-content {
    padding: 16px 20px;
  }
}

@media (max-width: 768px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .top-bar-right {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .top-bar-filters {
    flex-wrap: wrap;
    width: 100%;
  }
  .filter-group {
    flex-grow: 1;
  }
  .filter-control {
    width: 100%;
  }
  #btn-reset-filters {
    width: 100%;
    text-align: center;
  }
  .sync-container {
    width: 100%;
    justify-content: space-between;
  }
}

/* FHR TEXT LOGO BRAND STYLE */
.brand-logo-text {
  background: linear-gradient(135deg, #2563EB, #1D4ED8); /* Premium blue gradient */
  color: #FFFFFF;
  font-size: 1.25rem;
  font-weight: 900;
  min-width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* PROJECT DETAIL POPUP MODAL STYLING */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6); /* Slate 900 translucent overlay */
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal-content {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  transform: translateY(20px);
  transition: transform 0.25s/ease;
  overflow: hidden;
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-canvas);
}

.modal-header h3 {
  font-family: 'Roboto', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: var(--transition);
}

.modal-close-btn:hover {
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.detail-value {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-main);
}

.detail-value-full {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Hover effects for project list table rows */
#main-projects-tbody tr, #progress-projects-tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#main-projects-tbody tr:hover, #progress-projects-tbody tr:hover {
  background-color: var(--bg-canvas);
}


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