/* ===== Thuydien Admin Theme ===== */
:root {
  --sidebar-width: 240px;
  --topbar-height: 58px;
  --primary: #0d6efd;
  --sidebar-bg: linear-gradient(160deg, #0a1f44 0%, #1565c0 60%, #1976d2 100%);
  --sidebar-text: rgba(255,255,255,0.85);
  --sidebar-active: rgba(255,255,255,0.18);
  --card-radius: 12px;
}

/* Reset & base */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SIDEBAR USER INFO ===== */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  margin: 8px 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
}
.su-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.95rem; color: #fff; flex-shrink: 0;
}
.su-info { overflow: hidden; }
.su-name { font-size: 0.82rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { font-size: 0.7rem; color: rgba(255,255,255,0.55); }
.sidebar.collapsed .sidebar-user { display: none; }

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1030;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
  box-shadow: 3px 0 12px rgba(0,0,0,0.2);
}

.sidebar.collapsed { width: 68px; }

.sidebar-brand {
  display: flex;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 20px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  white-space: nowrap;
  gap: 10px;
}
.sidebar-brand .brand-icon {
  font-size: 1.4rem;
  min-width: 28px;
  text-align: center;
  color: #64b5f6;
}
.sidebar.collapsed .brand-text { display: none; }

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

.sidebar-section {
  padding: 8px 20px 4px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  font-weight: 600;
  white-space: nowrap;
}
.sidebar.collapsed .sidebar-section { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  border-radius: 0;
  transition: all 0.18s;
  white-space: nowrap;
  position: relative;
}
.nav-item i {
  min-width: 20px;
  font-size: 1rem;
  text-align: center;
  opacity: 0.8;
}
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.nav-item:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left: 3px solid #64b5f6;
}
.nav-item.active i { opacity: 1; color: #64b5f6; }

/* Tooltip for collapsed sidebar */
.sidebar.collapsed .nav-item:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 72px;
  background: #1e3a5f;
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 9999;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}
.main-content.expanded { margin-left: 68px; }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
  flex: 1;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.sidebar-toggle { color: #64748b; border: none; }
.sidebar-toggle:hover { color: var(--primary); }

/* ===== CONTENT WRAPPER ===== */
.content-wrapper {
  padding: 24px;
  max-width: 1400px;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h4 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

/* ===== STAT CARDS ===== */
.stat-card {
  border-radius: var(--card-radius) !important;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid #e9f0fa !important;
  cursor: default;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(13,110,253,0.13) !important;
}
.stat-card .card-body { padding: 18px 20px; }

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.1;
}
.stat-value small { font-size: 0.8rem; font-weight: 500; }

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 4px;
}

/* ===== CARDS ===== */
.card {
  border-radius: var(--card-radius) !important;
  border: 1px solid #e9f0fa !important;
}
.card-header {
  background: #fff !important;
  border-bottom: 1px solid #e9f0fa !important;
  padding: 14px 18px !important;
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
  font-weight: 600;
}

/* ===== DATA TABLE ===== */
.table-responsive { border-radius: 0 0 var(--card-radius) var(--card-radius); }
.table { margin: 0; font-size: 0.86rem; }
.table thead th {
  background: #f8fafc;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
  padding: 10px 14px;
  white-space: nowrap;
}
.table tbody td { padding: 9px 14px; vertical-align: middle; color: #334155; }
.table tbody tr:hover { background: #f0f7ff; }
.table-striped tbody tr:nth-child(even) { background: #fafbfe; }

/* ===== RECENT LIST ===== */
.recent-item {
  font-size: 0.83rem;
  transition: background 0.15s;
}
.recent-item:hover { background: #f8f9fa; }
.recent-item:last-child { border-bottom: 0 !important; }

/* ===== WATER LEVEL BADGES ===== */
.badge-rain-none   { background: #6c757d !important; }
.badge-rain-light  { background: #0dcaf0 !important; }
.badge-rain-medium { background: #198754 !important; }
.badge-rain-heavy  { background: #ffc107 !important; color: #000 !important; }
.badge-rain-storm  { background: #dc3545 !important; }

/* Status dot */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s infinite;
}
.status-dot.online { background: #22c55e; }
@keyframes pulse-dot {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a1f44 0%, #1565c0 50%, #42a5f5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: 18px !important;
  border: 0 !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35) !important;
  overflow: hidden;
}
.login-header {
  background: linear-gradient(135deg, #1565c0, #1976d2);
  padding: 32px 30px 24px;
  text-align: center;
  color: #fff;
}
.login-header .logo-icon {
  width: 68px; height: 68px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 12px;
  backdrop-filter: blur(10px);
}
.login-body { padding: 28px 30px; background: #fff; }
.login-body .form-label { font-size: 0.83rem; font-weight: 600; color: #475569; }
.login-body .form-control {
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  padding: 10px 14px;
  font-size: 0.93rem;
  transition: all 0.2s;
}
.login-body .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}
.btn-login {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  background: linear-gradient(90deg, #1565c0, #1976d2);
  border: 0;
  letter-spacing: 0.3px;
}
.btn-login:hover {
  background: linear-gradient(90deg, #0d47a1, #1565c0);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(21,101,192,0.4);
}

/* ===== FILTER CONTROLS ===== */
.filter-card { border-radius: var(--card-radius) !important; }
.filter-card .card-body { padding: 16px 20px; }

/* ===== CHART CANVAS ===== */
#waterChart { height: 280px !important; }

/* ===== LOADING SPINNER ===== */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* ===== PAGINATION ===== */
.pagination .page-link { border-radius: 8px !important; margin: 0 2px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    width: var(--sidebar-width);
  }
  .main-content { margin-left: 0; }
  .content-wrapper { padding: 16px; }
  .stat-value { font-size: 1.5rem; }
}
