/* ===== CSS VARIABLES (Light Theme Default) ===== */
:root {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-sidebar: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  --bg-sidebar-hover: rgba(255,255,255,0.05);
  --bg-sidebar-active: rgba(233,69,96,0.15);
  --text-primary: #1a1a2e;
  --text-secondary: #555;
  --text-muted: #999;
  --text-sidebar: #a0aec0;
  --text-sidebar-active: #ffffff;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --shadow: 0 2px 15px rgba(0,0,0,0.05);
  --accent: #e94560;
  --accent-light: rgba(233,69,96,0.15);
  --table-header-bg: #f8fafc;
  --table-row-hover: #f8fafc;
  --input-bg: #f1f5f9;
  --input-border: #e2e8f0;
  --badge-success-bg: #d1fae5;
  --badge-success-text: #065f46;
  --badge-danger-bg: #fee2e2;
  --badge-danger-text: #991b1b;
  --badge-warning-bg: #fef3c7;
  --badge-warning-text: #92400e;
  --btn-secondary-bg: #e2e8f0;
  --btn-secondary-text: #333;
  --modal-overlay: rgba(0,0,0,0.5);
  --toast-bg: #ffffff;
  --toast-text: #1a1a2e;
  --toast-text-secondary: #555;
}

/* Dark Theme */
body.dark-theme {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-sidebar: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-sidebar: #94a3b8;
  --text-sidebar-active: #ffffff;
  --border-color: #334155;
  --border-light: #1e293b;
  --shadow: 0 2px 15px rgba(0,0,0,0.3);
  --accent: #e94560;
  --accent-light: rgba(233,69,96,0.2);
  --table-header-bg: #1e293b;
  --table-row-hover: #1e293b;
  --input-bg: #334155;
  --input-border: #475569;
  --btn-secondary-bg: #334155;
  --btn-secondary-text: #e2e8f0;
  --modal-overlay: rgba(0,0,0,0.7);
  --toast-bg: #1e293b;
  --toast-text: #e2e8f0;
  --toast-text-secondary: #94a3b8;
}

/* ===== GLOBAL RESET ===== */
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background:var(--bg-primary); color:var(--text-primary); transition: background 0.3s, color 0.3s; }

/* ===== LAYOUT ===== */
.dashboard-container { display:flex; min-height:100vh; }
.sidebar { width:250px; background:var(--bg-sidebar); color:var(--text-sidebar); display:flex; flex-direction:column; transition:transform 0.3s ease; position:relative; z-index:100; }
.sidebar-header { padding:30px 25px; text-align:center; border-bottom:1px solid rgba(255,255,255,0.1); }
.sidebar-logo { width: 100px; height: auto; margin-bottom: 15px; border-radius: 50%; box-shadow: 0 5px 15px rgba(233,69,96,0.3); }
.sidebar-header h4 { color:var(--text-sidebar-active); }
.sidebar-nav { flex:1; padding:20px 0; }
.nav-item { display:flex; align-items:center; padding:14px 25px; color:var(--text-sidebar); text-decoration:none; transition:all 0.3s ease; gap:15px; font-weight:500; border-right:3px solid transparent; }
.nav-item i { width:20px; text-align:center; font-size:1.1rem; }
.nav-item:hover { background:var(--bg-sidebar-hover); color:var(--text-sidebar-active); }
.nav-item.active { background:var(--accent-light); color:var(--text-sidebar-active); border-right-color:var(--accent); }
.sidebar-footer { padding:20px 25px; border-top:1px solid rgba(255,255,255,0.1); }
.btn-logout { width:100%; padding:12px; background:rgba(255,255,255,0.05); color:var(--text-sidebar); border:1px solid rgba(255,255,255,0.1); border-radius:10px; cursor:pointer; font-size:0.95rem; font-weight:500; transition:all 0.3s ease; display:flex; align-items:center; justify-content:center; gap:10px; }
.btn-logout:hover { background:rgba(233,69,96,0.2); color:var(--accent); border-color:var(--accent); }

.main-content { flex:1; display:flex; flex-direction:column; overflow:hidden; }
.top-bar { background:var(--bg-secondary); padding:15px 25px; display:flex; align-items:center; gap:20px; box-shadow:var(--shadow); }
.menu-toggle { display:none; background:none; border:none; font-size:1.5rem; cursor:pointer; color:var(--text-primary); padding:5px; }
.search-box { display:flex; align-items:center; background:var(--input-bg); border-radius:12px; padding:8px 15px; gap:12px; flex:1; max-width:450px; }
.search-box i { color:var(--text-muted); font-size:1rem; }
.search-box input { border:none; background:none; flex:1; outline:none; font-size:0.95rem; color:var(--text-primary); }
.search-box input::placeholder { color:var(--text-muted); }
.user-info { display:flex; align-items:center; gap:12px; margin-right:auto; }
.user-info i { color:var(--accent); }
.user-details span { color:var(--text-primary); }
.user-details small { color:var(--text-muted); }

/* Theme Toggle Button */
.theme-toggle {
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-primary);
  transition: 0.3s;
  display: flex;
  align-items: center;
}
.theme-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.page-content { flex:1; padding:30px; overflow-y:auto; }
.page { display:none; }
.page.active { display:block; }
.page-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:30px; }
.page-header h2 { color:var(--text-primary); }
.stats-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:20px; margin-bottom:30px; }
.stat-card { background:var(--bg-secondary); padding:22px; border-radius:15px; display:flex; align-items:center; gap:18px; box-shadow:var(--shadow); transition:transform 0.3s ease; color:var(--text-primary); }
.stat-card:hover { transform:translateY(-3px); }
.stat-card i { font-size:2.2rem; color:var(--accent); }
.stat-card h5 { font-size:1.8rem; margin:0; }
.stat-card small { color:var(--text-secondary); }
.device-form { background:var(--bg-secondary); padding:25px; border-radius:15px; box-shadow:var(--shadow); margin-bottom:25px; }
.device-form label { color:var(--text-primary); }
.form-control, .form-select { background:var(--input-bg); border-color:var(--input-border); color:var(--text-primary); }
.form-control:focus, .form-select:focus { border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-light); }
.table-container { background:var(--bg-secondary); border-radius:15px; padding:5px; box-shadow:var(--shadow); overflow-x:auto; }
.table { width:100%; border-collapse:collapse; }
.table th { background:var(--table-header-bg); padding:14px 16px; text-align:right; font-weight:600; color:var(--text-primary); font-size:0.9rem; border-bottom:2px solid var(--border-color); }
.table td {
  padding:14px 16px;
  border-bottom:1px solid var(--border-light);
  font-size:0.9rem;
  color:var(--text-primary);
  background:var(--bg-secondary);  /* ← FIXED: follows theme */
}
.table tbody tr:hover { background:var(--table-row-hover); }

.badge { padding:6px 12px; border-radius:20px; font-size:0.8rem; font-weight:600; }
.badge-success { background:var(--badge-success-bg); color:var(--badge-success-text); }
.badge-danger { background:var(--badge-danger-bg); color:var(--badge-danger-text); }
.badge-warning { background:var(--badge-warning-bg); color:var(--badge-warning-text); }
.text-success { color:#10b981 !important; }
.text-warning { color:#f59e0b !important; }
/* Container for right-side items */
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

/* Theme toggle – clean icon button */
.theme-toggle {
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-primary);
  transition: 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.theme-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

/* User info pill */
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  padding: 6px 16px 6px 12px;
  border-radius: 40px;
  box-shadow: var(--shadow);
  transition: background 0.3s;
}
.user-info i {
  color: var(--accent);
  font-size: 2rem;
}
.user-details {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.user-details span:first-child {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.role-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent);
  display: inline-block;
  width: fit-content;
  margin-top: 2px;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
  background: var(--bg-secondary);
  padding: 6px 16px 6px 12px;
  border-radius: 40px;
  box-shadow: var(--shadow);
  transition: background 0.3s;
}
.user-info i {
  color: var(--accent);
  font-size: 2.2rem;
}
.user-details {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.user-details span:first-child {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.role-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent);
  display: inline-block;
  width: fit-content;
  margin-top: 2px;
}
.pagination { display:flex; justify-content:center; align-items:center; gap:6px; margin-top:20px; flex-wrap:wrap; }
.pagination button { background:var(--bg-secondary); border:1px solid var(--border-color); border-radius:8px; padding:8px 14px; cursor:pointer; font-size:0.9rem; color:var(--text-primary); min-width:40px; transition:0.2s; font-weight:500; }
.pagination button:hover:not(:disabled) { background:var(--accent-light); border-color:var(--accent); }
.pagination button.active { background:var(--accent); color:white; border-color:var(--accent); font-weight:bold; }
.pagination button:disabled { opacity:0.4; cursor:not-allowed; }
.pagination .ellipsis { border:none; background:transparent; color:var(--text-muted); cursor:default; pointer-events:none; min-width:auto; padding:8px 6px; }

.btn { padding:8px 16px; border-radius:8px; font-weight:600; transition:0.2s; }
.btn-primary { background:var(--accent); color:white; border:none; }
.btn-primary:hover { background:#c23152; }
.btn-secondary { background:var(--btn-secondary-bg); color:var(--btn-secondary-text); border:none; }
.btn-secondary:hover { background:var(--input-bg); }
.btn-success { background:#10b981; color:white; border:none; }
.btn-danger { background:#ef4444; color:white; border:none; }
.btn-warning { background:#f59e0b; color:white; border:none; }
.btn-outline-primary { background:transparent; color:var(--accent); border:2px solid var(--accent); }
.btn-outline-primary:hover { background:var(--accent); color:white; }
.btn-outline-danger { background:transparent; color:#ef4444; border:2px solid #ef4444; }
.btn-outline-danger:hover { background:#ef4444; color:white; }

/* Modal */
.modal-overlay {
  position: fixed; inset:0; background:var(--modal-overlay); z-index:100000;
  display:flex; align-items:center; justify-content:center; backdrop-filter:blur(4px);
}
.modal-box {
  background:var(--bg-secondary); border-radius:20px; padding:35px 30px 25px;
  text-align:center; max-width:400px; width:90%; box-shadow:0 25px 60px rgba(0,0,0,0.25);
  animation:modalFadeIn 0.1s ease; color:var(--text-primary);
}
.modal-icon { font-size:3rem; color:#f59e0b; margin-bottom:15px; }
.modal-title { font-size:1.3rem; font-weight:700; margin-bottom:10px; }
.modal-message { color:var(--text-secondary); margin-bottom:25px; font-size:0.95rem; }
.modal-actions { display:flex; justify-content:center; gap:15px; }
@keyframes modalFadeIn { from { opacity:0; transform:scale(0.9); } to { opacity:1; transform:scale(1); } }

@media (max-width:768px) {
  .sidebar { position:fixed; right:-280px; height:100vh; transition:right 0.3s ease; }
  .sidebar.active { right:0; }
  .menu-toggle { display:block; }
  .top-bar { flex-wrap:wrap; }
  .search-box { max-width:100%; order:3; }
  .page-content { padding:20px; }
  .stats-cards { grid-template-columns:1fr; }
}
/* ===== WATERMARK ===== */
.page-content {
  position: relative;
  z-index: 0;
}

.page-content::after {
  content: '';
  position: fixed;          /* stays in place when scrolling */
  top: 55%;
  left: 40%;
  transform: translate(-50%, -50%);
  width: 600px;             /* adjust size as needed */
  height: 600px;
  background-image: url('/watermarkImg.png');  /* path to your watermark image */
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.5;            /* very subtle – increase if you want more visible */
  pointer-events: none;     /* allows clicking through the watermark */
  z-index: -1;
}
/* ===== DASHBOARD FOOTER ===== */
.dashboard-footer {
  text-align: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  margin-top: auto;
}
.dashboard-footer strong {
  color: var(--accent);
  font-weight: 600;
}
.modern-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 8px 30px 8px 12px;
  font-size: 0.9rem;
  color: var(--text-primary);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%23666' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  transition: border 0.3s, box-shadow 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.modern-select:hover { border-color: var(--accent); }
.modern-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
/* ===== MOBILE SIDEBAR OVERLAY ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;                /* behind sidebar (100) */
  transition: opacity 0.3s;
}

/* Show overlay only on mobile when sidebar is active */
@media (max-width: 768px) {
  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }

  /* Ensure sidebar is above overlay */
  .sidebar {
    z-index: 100;
  }
}