/* Premium Stylesheet for Tech & Telecom Statistics Dashboard */
/* Supports Light/Dark Mode and features Noto Sans Lao + Inter typography */

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

:root {
  /* Common variables */
  --font-family: 'Inter', 'Noto Sans Lao', sans-serif;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.12);

  /* Default theme: Dark Tech Mode */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --card-bg: rgba(17, 24, 39, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-primary: #06b6d4;      /* Cyan-500 */
  --accent-secondary: #3b82f6;    /* Blue-500 */
  --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --accent-light: rgba(6, 182, 212, 0.15);
  --success: #10b981;             /* Emerald-500 */
  --success-light: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;             /* Amber-500 */
  --danger: #ef4444;              /* Red-500 */
  
  --sidebar-width: 280px;
  --header-height: 70px;
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f3f4f6;
  --bg-secondary: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(0, 0, 0, 0.06);
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --accent-primary: #0284c7;      /* Sky-600 */
  --accent-secondary: #2563eb;    /* Blue-600 */
  --accent-gradient: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  --accent-light: rgba(2, 132, 199, 0.1);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.06);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* 1. App Layout */
.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-normal), background-color var(--transition-normal), border-color var(--transition-normal);
}

.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--card-border);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--accent-gradient);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  list-style: none;
}

.menu-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 12px 6px 12px;
}

.menu-item {
  margin-bottom: 4px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.menu-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  transition: transform var(--transition-fast);
}

.menu-link:hover {
  background-color: var(--accent-light);
  color: var(--accent-primary);
}

.menu-link:hover i {
  transform: translateX(2px);
}

.menu-item.active .menu-link {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.2);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--card-border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  transition: margin-left var(--transition-normal);
}

/* Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 90;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-title-area h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-title-area p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

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

/* Role Selector Styles */
.role-badge {
  background-color: var(--bg-primary);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.role-badge:hover {
  border-color: var(--accent-primary);
  background-color: var(--accent-light);
}

.role-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
}

.role-dot.data-entry {
  background-color: var(--warning);
}

.role-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.role-dropdown {
  position: relative;
}

.role-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: none;
  z-index: 120;
  animation: slideDown 0.2s ease;
}

.role-menu.show {
  display: block;
}

.role-option {
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.role-option:hover {
  background-color: var(--accent-light);
}

.role-option-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.role-option-desc {
  font-size: 10px;
  color: var(--text-muted);
}

/* Theme Toggle Button */
.btn-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-primary);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 16px;
}

.btn-circle:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  transform: scale(1.05);
}

/* Page Contents Container */
.page-container {
  padding: 20px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height));
}

/* 2. Visual Cards & Grid System */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.card {
  background-color: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(6, 182, 212, 0.3);
}

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

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.card-icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--border-radius-sm);
  background-color: var(--accent-light);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-accent-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-gradient);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

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

.chart-card {
  height: 300px;
  max-height: 35vh;
  display: flex;
  flex-direction: column;
}

.chart-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chart-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

/* District Filtering Panel */
.filter-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary);
  border: 1px solid var(--card-border);
  padding: 16px 24px;
  border-radius: var(--border-radius-md);
  flex-wrap: wrap;
  gap: 16px;
}

.filter-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-selects {
  display: flex;
  gap: 12px;
}

select, input, textarea {
  background-color: var(--bg-primary);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-family);
  font-size: 14px;
  outline: none;
  transition: all var(--transition-fast);
}

select:focus, input:focus, textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* 3. Tables & Matrices */
.matrix-card {
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 360px);
  min-height: 280px;
  margin-top: 12px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--card-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-primary);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] tr:hover td {
  background-color: rgba(0, 0, 0, 0.01);
}

/* Styled District Badges */
.district-badge {
  background-color: var(--accent-light);
  color: var(--accent-primary);
  padding: 4px 10px;
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

/* 4. Form Designs for Data Entry */
.form-container {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

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

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

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-group.full-width {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .form-group.full-width {
    grid-column: span 1;
  }
}

.btn {
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.2);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--bg-primary);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: none;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--card-border);
  padding-top: 20px;
  margin-top: 10px;
}

/* Alert Boxes */
.alert {
  padding: 16px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid transparent;
}

.alert-success {
  background-color: var(--success-light);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}

.alert-info {
  background-color: var(--accent-light);
  color: var(--accent-primary);
  border-color: rgba(6, 182, 212, 0.2);
}

/* Backup and Sync Panel */
.sync-panel {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.hidden-file-input {
  display: none;
}

/* Mobile Sidebar Menu Button */
.menu-toggle {
  display: none;
}

@media (max-width: 768px) {
  body {
    height: auto;
    overflow-y: auto;
  }

  .main-content {
    height: auto;
    overflow-y: auto;
  }

  .page-container {
    padding: 16px;
    max-height: none;
    overflow-y: visible;
  }

  .chart-card {
    height: 340px;
    max-height: none;
  }

  .table-responsive {
    max-height: none;
  }

  .menu-toggle {
    display: flex;
  }
  
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .app-header {
    padding: 0 16px;
  }
}

/* Keyframe Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.tab-content {
  animation: fadeIn 0.4s ease-in-out;
}

.district-selector-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 10px 0;
  margin-bottom: 8px;
  width: 100%;
  position: sticky;
  top: -20px;
  background-color: var(--bg-primary);
  z-index: 20;
  flex-shrink: 0;
}

/* District Grid View styles */
.district-grid-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.district-card {
  cursor: pointer;
  border-left: 4px solid var(--text-muted);
}

.district-card:hover {
  border-left-color: var(--accent-primary);
}

.district-card.active {
  border-left-color: var(--accent-primary);
  background-color: var(--accent-light);
}

.district-card-header {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.district-card-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Action Plan timeline list */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 16px;
}

.timeline-item {
  display: flex;
  gap: 16px;
}

.timeline-dot-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--accent-primary);
  box-shadow: 0 0 0 4px var(--accent-light);
}

.timeline-line {
  flex: 1;
  width: 2px;
  background-color: var(--card-border);
  min-height: 40px;
  margin-top: 6px;
}

.timeline-item:last-child .timeline-line {
  display: none;
}

.timeline-content {
  flex: 1;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  padding: 14px 18px;
}

[data-theme="light"] .timeline-content {
  background-color: rgba(0, 0, 0, 0.01);
}

.timeline-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
}

.timeline-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

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

/* 5. Login Modal Styles */
.login-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

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

.login-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-lg);
  width: 90%;
  max-width: 400px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.login-header {
  text-align: center;
  margin-bottom: 20px;
}

.login-lock-icon {
  font-size: 28px;
  color: var(--warning);
  background-color: rgba(245, 158, 11, 0.1);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px auto;
}

.login-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.login-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-error {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
