/* =========================
   Modern UI 2026 + Dark/Light + Mobile First
   - Clean spacing system
   - Better cards/buttons/forms
   - Smooth interactions
========================= */

:root{
  /* layout */
  --radius:16px;
  --radius-lg:20px;

  /* colors - light */
  --bg:#f5f7fb;
  --card:#ffffff;
  --card-2:#fbfcff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e5e7eb;

  /* brand */
  --primary:#2563eb;
  --primary-2:#3b82f6;
  --primary-hover:#1e40af;

  --danger:#dc2626;
  --success:#16a34a;
  --warning:#f59e0b;

  /* effects */
  --shadow:0 12px 28px rgba(2,6,23,.06);
  --shadow-2:0 18px 45px rgba(2,6,23,.10);
  --ring:0 0 0 4px rgba(37,99,235,.18);

  /* spacing */
  --gap:14px;

  /* typography */
  --font: system-ui,-apple-system,"Segoe UI",Arial,sans-serif;
}

[data-theme="dark"]{
  --bg:#070b14;
  --card:#0f172a;
  --card-2:#0b1220;
  --text:#eef2ff;
  --muted:#94a3b8;
  --border:#23314a;

  --primary:#3b82f6;
  --primary-2:#60a5fa;
  --primary-hover:#93c5fd;

  --danger:#ef4444;
  --success:#22c55e;
  --warning:#fbbf24;

  --shadow:0 16px 40px rgba(0,0,0,.45);
  --shadow-2:0 26px 65px rgba(0,0,0,.55);
  --ring:0 0 0 4px rgba(59,130,246,.22);
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  font-family:var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(37,99,235,.09), transparent 45%),
              radial-gradient(1000px 600px at 90% 0%, rgba(16,185,129,.07), transparent 50%),
              var(--bg);
  color:var(--text);
  margin:0;
  padding:16px;
  line-height:1.75;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}

.container{
  max-width:1100px;
  margin:0 auto;
  padding-top:64px; /* مساحة للزر الثابت */
}

/* typography */
h1,h2,h3{
  margin:0 0 12px;
  letter-spacing:-.02em;
}
h1{font-size:clamp(22px, 3vw, 32px); font-weight:900}
h2{font-size:clamp(18px, 2.2vw, 26px); font-weight:900}
h3{font-size:18px; font-weight:850}

p{margin:10px 0}

a{color:var(--primary);text-decoration:none}
a:hover{text-decoration:underline}

/* =========================
   Cards
========================= */
.card{
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border:1px solid color-mix(in oklab, var(--border), transparent 10%);
  border-radius:var(--radius-lg);
  padding:16px;
  margin:14px 0;
  box-shadow:var(--shadow);
  position:relative;
  overflow:hidden;
}

.card::before{
  content:"";
  position:absolute;
  inset:-1px;
  background: radial-gradient(900px 300px at 20% 0%, rgba(37,99,235,.10), transparent 60%);
  pointer-events:none;
  opacity:.8;
}

[data-theme="dark"] .card::before{
  opacity:.55;
}

.card > *{position:relative}

@media (min-width: 768px){
  body{padding:24px}
  .card{padding:20px}
}

/* =========================
   Forms
========================= */
label{
  display:block;
  margin-top:10px;
  font-weight:800;
  color:color-mix(in oklab, var(--text), var(--muted) 30%);
}

input,select,textarea{
  width:100%;
  padding:12px 12px;
  margin:8px 0 0;
  border:1px solid var(--border);
  border-radius:14px;
  background: color-mix(in oklab, var(--card), transparent 5%);
  color:var(--text);
  transition: box-shadow .2s ease, border-color .2s ease, transform .08s ease;
}

textarea{min-height:110px; resize:vertical}

input::placeholder, textarea::placeholder{color:var(--muted)}

input:focus,select:focus,textarea:focus{
  border-color:color-mix(in oklab, var(--primary), white 15%);
  outline:none;
  box-shadow:var(--ring);
}

input:active, textarea:active{transform:translateY(1px)}

input[disabled], select[disabled], textarea[disabled]{
  opacity:.65;
  cursor:not-allowed;
}

/* grid rows */
.row{
  display:grid;
  grid-template-columns: 1fr;
  gap:12px;
}
@media (min-width: 768px){
  .row.two{grid-template-columns:1fr 1fr}
  .row.three{grid-template-columns:1fr 1fr 1fr}
}

/* =========================
   Buttons
========================= */
.actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  align-items:center;
  margin-top:14px;
}

button, .btn-ghost, .btn-primary, .btn-danger{
  padding:12px 16px;
  border:0;
  border-radius:14px;
  cursor:pointer;
  font-weight:900;
  white-space:nowrap;
  transition: transform .08s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, opacity .2s ease;
}

button:active{transform:translateY(1px)}

.btn-primary{
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color:#fff;
  box-shadow: 0 10px 20px rgba(37,99,235,.18);
}
.btn-primary:hover{
  filter:brightness(1.03);
  box-shadow: 0 14px 28px rgba(37,99,235,.22);
}
.btn-primary:disabled{opacity:.6; cursor:not-allowed; box-shadow:none}

.btn-danger{
  background: linear-gradient(135deg, var(--danger), color-mix(in oklab, var(--danger), white 15%));
  color:#fff;
  box-shadow: 0 10px 20px rgba(220,38,38,.16);
}
.btn-danger:hover{filter:brightness(1.03)}
.btn-danger:disabled{opacity:.6; cursor:not-allowed; box-shadow:none}

.btn-ghost{
  background: color-mix(in oklab, var(--card), transparent 10%);
  border:1px solid var(--border);
  color:var(--text);
}
.btn-ghost:hover{
  border-color: color-mix(in oklab, var(--primary), var(--border) 40%);
  box-shadow: 0 10px 22px rgba(2,6,23,.08);
}

/* =========================
   Badges & Alerts
========================= */
.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  color:var(--muted);
  font-size:13px;
  font-weight:800;
  background: color-mix(in oklab, var(--card), transparent 12%);
}

.badge.ok{
  border-color: rgba(34,197,94,.35);
  color: var(--success);
}
.badge.err{
  border-color: rgba(239,68,68,.35);
  color: var(--danger);
}

.ok{color:var(--success);font-weight:900}
.err{color:var(--danger);font-weight:900}
.muted{color:var(--muted)}

.alert{
  border:1px solid var(--border);
  border-radius:16px;
  padding:12px 14px;
  background: color-mix(in oklab, var(--card), transparent 10%);
}
.alert.success{border-color:rgba(34,197,94,.25)}
.alert.danger{border-color:rgba(239,68,68,.25)}
.alert.warning{border-color:rgba(245,158,11,.25)}

hr{border:none;border-top:1px solid var(--border);margin:14px 0}

/* =========================
   Tabs
========================= */
.tabs{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin:12px 0;
}

.tab{
  padding:10px 14px;
  border-radius:999px;
  border:1px solid var(--border);
  background: color-mix(in oklab, var(--card), transparent 6%);
  color:var(--text);
  font-weight:900;
  transition: background .2s ease, border-color .2s ease, transform .08s ease;
}
.tab:hover{border-color: color-mix(in oklab, var(--primary), var(--border) 40%)}
.tab:active{transform:translateY(1px)}
.tab.active{
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color:#fff;
  box-shadow: 0 12px 26px rgba(37,99,235,.18);
}

/* =========================
   Table responsive
========================= */
.table-wrap{
  overflow:auto;
  border-radius:16px;
  border:1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--card);
}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width:860px;
  background: transparent;
}

th,td{
  padding:12px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
  text-align:right;
}

th{
  position:sticky;
  top:0;
  z-index:2;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  color:var(--muted);
  font-size:13px;
  font-weight:900;
}

tr:hover{background:rgba(2,6,23,.03)}
[data-theme="dark"] tr:hover{background:rgba(255,255,255,.04)}

/* =========================
   Mobile cards
========================= */
.mobile-cards{ display:none; }

@media (max-width: 767px){
  .table-wrap{ display:none !important; }

  .mobile-cards{
    display:grid;
    gap:14px;
  }

  .mobile-card{
    border:1px solid var(--border);
    border-radius:18px;
    padding:14px;
    background: linear-gradient(180deg, var(--card), var(--card-2));
    box-shadow:var(--shadow);
    overflow:hidden;
  }

  .kv{
    display:grid;
    grid-template-columns: 92px 1fr;
    gap:8px;
    font-size:14px;
    align-items:start;
  }

  .kv b{
    color:var(--muted);
    font-weight:900;
  }

  .mobile-card .actions{ margin-top:12px; }
  .mobile-card input,
  .mobile-card select,
  .mobile-card textarea{ margin-top:8px; }

  .mobile-card hr{ margin:12px 0; }
}

/* Long text safety */
.kv div, td{
  word-break: break-word;
  overflow-wrap:anywhere;
}

/* forms spacing inside cards */
form{ margin:0; }
form + form{ margin-top:12px; }

/* =========================
   Theme Toggle fixed
========================= */
.theme-toggle{
  position:fixed;
  top:14px;
  left:14px;
  z-index:999;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border:1px solid var(--border);
  padding:10px 14px;
  border-radius:999px;
  cursor:pointer;
  box-shadow:var(--shadow);
  font-size:14px;
  font-weight:900;
  transition: transform .08s ease, box-shadow .2s ease;
}
.theme-toggle:hover{box-shadow:var(--shadow-2)}
.theme-toggle:active{transform:translateY(1px)}

/* Small helper */
.small{font-size:13px;color:var(--muted)}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  *{transition:none !important; scroll-behavior:auto !important}
}



/* Info button (top right) */
.info-btn{
  position:fixed;
  top:14px;
  right:14px;
  z-index:999;
  background:var(--card);
  border:1px solid var(--border);
  padding:10px 14px;
  border-radius:999px;
  cursor:pointer;
  box-shadow:var(--shadow);
  font-size:14px;
}

/* Modal (Mobile-first bottom sheet) */
.modal{display:none}
.modal.open{display:block}

.modal-backdrop{
  position:fixed; inset:0;
  background:rgba(0,0,0,.55);
  z-index:1000;
}

.modal-sheet{
  position:fixed;
  z-index:1001;
  left:50%;
  bottom:14px;
  transform:translateX(-50%);
  width:min(620px, 92vw);
  background:var(--card);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow);
  overflow:hidden;
}

/* On larger screens, center it */
@media (min-width: 768px){
  .modal-sheet{
    top:50%;
    bottom:auto;
    transform:translate(-50%,-50%);
  }
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
}
.modal-header h3{margin:0;font-size:18px}

.modal-x{
  background:transparent;
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px 10px;
  cursor:pointer;
  color:var(--text);
}
.modal-x:hover{border-color:var(--primary)}

.modal-body{
  padding:14px 16px;
  line-height:1.8;
}

.modal-box{
  margin:12px 0;
  padding:12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(255,255,255,.04);
}

.modal-footer{
  padding:12px 16px;
  border-top:1px solid var(--border);
  display:flex;
  justify-content:flex-start;
  gap:10px;
}