/* =========================
   1. GLOBAL VARIABLES & RESET
   ========================= */
:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --line: #e2e8f0;
  
  /* Colors */
  --pri: #2563eb;
  --pri-dark: #1e40af;
  --pri-light: #eff6ff;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Sidebar Theme (Admin & Agent) */
  --sidebar-bg: linear-gradient(145deg, #1e3a8a 0%, #2563eb 100%);
  --sidebar-text: #ffffff;
  --sidebar-active: #ffffff;
  --sidebar-active-text: #1e40af;

  /* Effects */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius: 12px;
  --trans: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  font-size: 14px;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; padding: 0; margin: 0; }

/* =========================
   2. LAYOUT WRAPPER
   ========================= */
.wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%; 
  overflow-x: hidden;
}

/* =========================
   3. SIDEBAR
   ========================= */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0,0,0,0.1);
}

.sidebar .brand {
  height: var(--topbar-h);
  display: flex; align-items: center; padding: 0 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-weight: 700; font-size: 1.1rem; gap: 12px;
}
.sidebar .brand .logo {
  width: 32px; height: 32px; background: rgba(255,255,255,0.2);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.sidebar .nav { padding: 20px 12px; flex: 1; overflow-y: auto; }
.sidebar .nav::-webkit-scrollbar { width: 8px; }
.sidebar .nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 10px; }

.sidebar .heading {
  padding: 16px 12px 8px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; color: rgba(255,255,255,0.5); margin-top: 5px;
}
.sidebar .nav li { margin-bottom: 4px; }
.sidebar .nav li a {
  display: flex; align-items: center; padding: 10px 14px; border-radius: 8px;
  color: rgba(255,255,255,0.85); font-weight: 500; transition: var(--trans); gap: 12px;
}
.sidebar .nav li a:hover { background: rgba(255,255,255,0.1); color: #fff; transform: translateX(4px); }
.sidebar .nav li.active a {
  background: var(--sidebar-active); color: var(--sidebar-active-text);
  font-weight: 700; box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.sidebar .logout {
    margin-top: auto; padding: 20px; border-top: 1px solid rgba(255,255,255,0.1); 
}
.sidebar .logout a { color: #fca5a5; display:flex; align-items:center; gap:10px; padding:10px; border-radius:8px; transition:0.2s; }
.sidebar .logout a:hover { background: rgba(239, 68, 68, 0.1); color: #fff; }

/* =========================
   4. MAIN CONTENT
   ========================= */
.main-content {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  min-height: 100vh;
}
.main { flex: 1; width: 100%; display: flex; flex-direction: column; }
.content-body { padding: 32px; width: 100%; flex: 1; }

/* =========================
   5. TOPBAR (Admin & Agent)
   ========================= */
.topbar {
  height: var(--topbar-h); background: var(--card-bg);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 32px;
  position: sticky; top: 0; z-index: 40; width: 100%;
}
.btn-toggle {
  display: none; background: none; border: none; font-size: 22px;
  color: var(--text-muted); cursor: pointer; padding: 8px;
}
.topbar .page-title { font-size: 1.25rem; font-weight: 800; }

.user-profile {
  display: flex; align-items: center; gap: 12px; padding: 6px 12px;
  border-radius: 50px; border: 1px solid transparent; cursor: pointer;
}
.user-profile:hover { background: var(--bg); border-color: var(--line); }
.user-profile .avatar {
  width: 36px; height: 36px; background: var(--pri-light); color: var(--pri);
  border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800;
}

/* =========================
   6. COMPONENTS (Cards & Footer)
   ========================= */
.card, .stat-card, .guide-card {
  background: var(--card-bg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.card-header {
    padding: 20px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    font-size: 15px;
    margin: -24px -24px 20px -24px; /* Compensate for card padding */
    background: #ffffff;
    border-radius: var(--radius) var(--radius) 0 0;
}

.footer {
  margin-top: auto; text-align: center; padding: 26px 18px;
  color: var(--text-muted); font-size: 0.85rem; border-top: 1px solid var(--line);
}

/* Alerts */
.alert { padding: 16px; border-radius: var(--radius); margin-bottom: 24px; font-weight: 500; }
.alert.ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert.err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 20px; border-radius: 8px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; transition: var(--trans);
    font-size: 13px; gap: 8px; text-decoration: none;
}
.btn.primary, .btn-primary { background: var(--pri); color: #fff; }
.btn.primary:hover { background: var(--pri-dark); box-shadow: 0 4px 12px rgba(37,99,235,0.2); }
.btn.outline { background: transparent; border-color: var(--line); color: var(--text-main); }
.btn.outline:hover { background: var(--bg); border-color: var(--text-muted); }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text-main); font-size: 13px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], select, textarea {
    width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px;
    font-family: inherit; font-size: 14px; color: var(--text-main); transition: var(--trans);
    background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--pri); outline: none; box-shadow: 0 0 0 3px var(--pri-light); }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { 
    text-align: left; padding: 16px; background: #f8fafc; 
    color: var(--text-muted); font-weight: 600; text-transform: uppercase; 
    font-size: 11px; letter-spacing: 0.5px; border-bottom: 1px solid var(--line); 
}
td { padding: 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* Status Badges */
span[style*="background"] { display: inline-block; white-space: nowrap; }

/* =========================
   7. DASHBOARD GRID & STATS
   ========================= */
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px; margin-bottom: 32px;
}
.stat-box {
    background: var(--card-bg); padding: 24px; border-radius: var(--radius);
    border: 1px solid var(--line); box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; justify-content: center;
    position: relative; overflow: hidden;
}
/* Border Top Color */
.stat-box[style*="border-top"] { border-top-width: 4px !important; }

.stat-title {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-main); line-height: 1; }

.text-green { color: var(--success); }
.text-blue { color: var(--pri); }
.text-red { color: var(--danger); }
.text-orange { color: var(--warning); }

/* =========================
   8. LOGIN PAGE (.login-box)
   ========================= */
.login-box {
    background: var(--card-bg); padding: 40px; border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%; max-width: 400px; margin: 0 auto; border: 1px solid var(--line);
}

/* =========================
   9. MODALS
   ========================= */
#ticketModal, #payoutModal, #compPayModal {
    backdrop-filter: blur(4px);
}

/* =========================
   10. MOBILE RESPONSIVE
   ========================= */
@media (max-width: 980px) {
  .btn-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%); transition: transform 0.3s; z-index: 60;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 10px 0 50px rgba(0,0,0,0.3); }
  .overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 55; display: none; backdrop-filter: blur(2px);
  }
  .overlay.active { display: block; }
  .content-body { padding: 20px; }
  .topbar { padding: 0 16px; }
  
  .stat-grid { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 -20px; width: calc(100% + 40px); padding: 0 20px; }
}