/* ---------------------------------------------------------
   UI THEME (Only visuals)
   - Responsive (PC + Mobile)
   - Does NOT change any Jinja variables, route names, or form names.
--------------------------------------------------------- */

:root{
  --bg: #0b1220;
  --bg-2: #0e1a33;
  --surface: #ffffff;
  --surface-2: rgba(255,255,255,.92);
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15,23,42,.10);

  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;

  --shadow: 0 18px 50px rgba(2,6,23,.12);
  --shadow-sm: 0 10px 28px rgba(2,6,23,.10);
  --radius: 18px;

  --sidebar-w: 288px;
}

*{ box-sizing: border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 10% 10%, rgba(37,99,235,.22), transparent 60%),
    radial-gradient(900px 600px at 90% 0%, rgba(22,163,74,.14), transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

/* Bootstrap adjustments (visual only) */
.text-muted{ color: var(--muted) !important; }
.btn{ border-radius: 14px; padding:.55rem .9rem; font-weight: 700; }
.btn-primary{ background: var(--primary); border-color: var(--primary); }
.btn-primary:hover{ background: var(--primary-2); border-color: var(--primary-2); }
.btn-success{ background: var(--success); border-color: var(--success); }
.btn-outline-primary{ border-color: rgba(37,99,235,.35); color: var(--primary); }
.btn-outline-primary:hover{ background: rgba(37,99,235,.10); color: var(--primary-2); }
.form-control, .form-select{
  border-radius: 14px;
  border-color: rgba(15,23,42,.14);
  padding: .6rem .85rem;
}
.form-control:focus, .form-select:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 .25rem rgba(37,99,235,.16);
}
.card{
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm);
}
.card .card-body{ padding: 18px; }
.alert{
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 24px rgba(2,6,23,.08);
}

/* Layout shell */
.app-shell{
  display:flex;
  min-height:100vh;
}

/* Mobile toggle checkbox */
.nav-toggle{
  position:absolute;
  left:-9999px;
  width:1px; height:1px;
}

/* Sidebar */
.sidebar{
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  padding: 16px 14px;
  color: rgba(255,255,255,.92);
  background:
    linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
  border-right: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(14px);
  position: sticky;
  top:0;
  height:100vh;
  display:flex;
  flex-direction:column;
  gap: 12px;
}

.sidebar-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 8px 6px 10px 6px;
}

.brand{ display:flex; align-items:center; gap: 10px; }
.brand-icon{
  width: 42px; height: 42px;
  border-radius: 14px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 10px 20px rgba(0,0,0,.14);
}
.brand-title{ font-weight: 800; letter-spacing: .2px; }
.brand-sub{ font-size:.85rem; color: rgba(255,255,255,.70); margin-top:2px; }

.sidebar-close{
  display:none;
  cursor:pointer;
  user-select:none;
  width: 38px; height: 38px;
  border-radius: 12px;
  align-items:center; justify-content:center;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
}

.sidebar-nav{
  display:flex;
  flex-direction:column;
  gap: 6px;
  padding: 2px 4px;
}

.sidebar a{
  text-decoration:none;
  color: rgba(255,255,255,.92);
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.sidebar a span{ font-weight: 700; }
.sidebar a:hover{
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.14);
  transform: translateY(-1px);
}
.sidebar a:active{ transform: translateY(0); }

.sidebar-footer{
  margin-top:auto;
  padding: 8px 4px 2px 4px;
}
.sidebar a.logout{
  background: rgba(220,38,38,.12);
  border-color: rgba(220,38,38,.22);
}
.sidebar a.logout:hover{
  background: rgba(220,38,38,.18);
  border-color: rgba(220,38,38,.30);
}

/* Main area */
.main{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width: 0;
}
.topbar{
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 14px 16px;
  background: rgba(255,255,255,.10);
  border-bottom: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(14px);
}
.topbar-left{
  display:flex;
  align-items:center;
  gap: 12px;
}
.topbar-title{
  color: rgba(255,255,255,.90);
  font-weight: 800;
  letter-spacing: .2px;
}

.nav-open{
  display:none;
  cursor:pointer;
  user-select:none;
  width: 42px; height: 42px;
  border-radius: 14px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.14);
  align-items:center; justify-content:center;
}
.burger{
  width: 18px; height: 2px;
  background: rgba(255,255,255,.92);
  position: relative;
  display:block;
  border-radius: 2px;
}
.burger::before, .burger::after{
  content:"";
  position:absolute;
  left:0;
  width: 18px;
  height: 2px;
  background: rgba(255,255,255,.92);
  border-radius:2px;
}
.burger::before{ top:-6px; }
.burger::after{ top:6px; }

.content{
  padding: 18px;
}

/* Page surfaces */
.content > .container,
.content > .container-fluid{
  padding-left: 0;
  padding-right: 0;
}

/* Tables: keep readable, allow horizontal scroll on mobile */
.table{
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(15,23,42,.10);
}
.table thead th{
  background: rgba(2,6,23,.04);
  color: rgba(15,23,42,.86);
  font-weight: 800;
  border-bottom-color: rgba(15,23,42,.10) !important;
}
.table td, .table th{
  vertical-align: middle;
  border-color: rgba(15,23,42,.08) !important;
}
.table-striped>tbody>tr:nth-of-type(odd)>*{ background: rgba(2,6,23,.02); }

/* Badges */
.badge{
  border-radius: 999px;
  padding: .4rem .6rem;
  font-weight: 800;
}

/* Auth pages */
.auth-page{
  background:
    radial-gradient(1000px 600px at 20% 10%, rgba(37,99,235,.18), transparent 60%),
    radial-gradient(800px 520px at 85% 0%, rgba(22,163,74,.14), transparent 55%),
    linear-gradient(180deg, #0b1220, #0e1a33);
}
.auth-page .card{
  border: 1px solid rgba(255,255,255,.14) !important;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 22px 60px rgba(2,6,23,.26);
}
.auth-page h3{
  font-weight: 900;
  letter-spacing: .2px;
}

/* Mobile / Tablet */
@media (max-width: 992px){
  .sidebar{
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-105%);
    transition: transform .18s ease;
    z-index: 50;
    box-shadow: 0 30px 80px rgba(0,0,0,.35);
  }
  .nav-open{ display:flex; }
  .sidebar-close{ display:flex; }
  .sidebar-overlay{
    position: fixed;
    inset: 0;
    background: rgba(2,6,23,.55);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease;
  }

  /* When toggled */
  .nav-toggle:checked ~ .sidebar{ transform: translateX(0); }
  .nav-toggle:checked ~ .sidebar-overlay{
    opacity: 1;
    pointer-events: auto;
  }

  .topbar{ padding: 12px 12px; }
  .content{ padding: 12px; }

  /* Tables on small screens */
  .table{
    display:block;
    width:100%;
    overflow-x:auto;
    white-space: nowrap;
  }
}

/* Small phones */
@media (max-width: 420px){
  .brand-sub{ display:none; }
  .content{ padding: 10px; }
}
