/* ===========================================================
   Academy CRM - Design tokens
   Palette: white / orange / purple / yellow / red
   =========================================================== */
:root {
  --c-white: #ffffff;
  --c-bg: #f7f6fb;
  --c-purple: #5b3a9c;
  --c-purple-dark: #422b73;
  --c-purple-soft: #efe9fb;
  --c-orange: #f2712b;
  --c-orange-soft: #fdeadd;
  --c-yellow: #f4b400;
  --c-yellow-soft: #fdf3d8;
  --c-red: #e8483a;
  --c-red-soft: #fbe4e1;
  --c-text: #251c3a;
  --c-text-muted: #7a7290;
  --c-border: #e7e3f2;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(91, 58, 156, .08);
  --font: 'Vazirmatn', 'IRANSans', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

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

.sidebar {
  width: 250px;
  background: linear-gradient(180deg, var(--c-purple) 0%, var(--c-purple-dark) 100%);
  color: #fff;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidebar .brand { font-size: 19px; font-weight: 800; margin-bottom: 30px; display:flex; align-items:center; gap:10px;}
.sidebar .brand .dot{
  width:10px;height:10px;border-radius:50%;background:#2ecc71;display:inline-block;
  box-shadow: 0 0 0 rgba(46,204,113,.6);
  animation: dot-pulse 1.6s infinite;
}
@keyframes dot-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(46,204,113,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(46,204,113,0); }
  100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  color: rgba(255,255,255,.85); font-size: 14.5px; margin-bottom: 4px;
  transition: background .15s ease;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); }
.sidebar nav a.active { background: var(--c-orange); color: #fff; font-weight: 700; }
.sidebar .logout { margin-top: 30px; display:block; color: var(--c-red); opacity:.9; font-size:13px;}

.main { flex: 1; padding: 26px 32px; max-width: 100%; overflow-x: hidden; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; gap: 10px;
}
.topbar h1 { font-size: 21px; margin: 0; }
.topbar .admin-chip {
  background: var(--c-white); border: 1px solid var(--c-border);
  padding: 8px 14px; border-radius: 30px; font-size: 13px; color: var(--c-text-muted);
  white-space: nowrap;
}

/* Hamburger button - hidden on desktop */
.menu-toggle {
  display: none;
  flex-direction: column; justify-content: center; gap: 4px;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1.5px solid var(--c-border); background: var(--c-white);
  cursor: pointer; flex-shrink: 0; padding: 0;
}
.menu-toggle span { display:block; width: 20px; height: 2px; margin: 0 auto; background: var(--c-purple); border-radius: 2px; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(37,28,58,.45); z-index: 90;
}
.sidebar-overlay.open { display: block; }

/* ---------- Cards / stat grid ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--c-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--c-border);
  padding: 20px;
}

.stat-card { padding: 18px 20px; }
.stat-card .label { color: var(--c-text-muted); font-size: 13px; margin-bottom: 8px;}
.stat-card .value { font-size: 26px; font-weight: 800; overflow-wrap: break-word; word-break: break-word; }
.stat-card.orange { border-top: 3px solid var(--c-orange); }
.stat-card.purple { border-top: 3px solid var(--c-purple); }
.stat-card.yellow { border-top: 3px solid var(--c-yellow); }
.stat-card.red { border-top: 3px solid var(--c-red); }

.section-title { font-size: 16px; font-weight: 800; margin: 28px 0 14px; }

/* ---------- Table ---------- */
table.data { width: 100%; border-collapse: collapse; background: var(--c-white); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { padding: 12px 14px; text-align: right; font-size: 13.5px; border-bottom: 1px solid var(--c-border); }
table.data th { background: var(--c-purple-soft); color: var(--c-purple-dark); font-weight: 700; }
table.data tr:hover td { background: #faf9fd; }

.badge { display:inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge.active { background: #e3f7ea; color: #1c8a49; }
.badge.expired { background: var(--c-red-soft); color: var(--c-red); }
.badge.pending { background: var(--c-yellow-soft); color: #8a6800; }
.badge.renewed { background: #e3f7ea; color: #1c8a49; }
.badge.not_renewed { background: var(--c-red-soft); color: var(--c-red); }
.badge.payment_extension { background: var(--c-yellow-soft); color: #8a6800; }
.badge.no_cooperation { background: #eee; color: #555; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13.5px; margin-bottom: 6px; font-weight: 600; color: var(--c-text); }
input[type=text], input[type=password], input[type=tel], select, textarea {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--c-border);
  font-family: var(--font); font-size: 14px; background: var(--c-white); color: var(--c-text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-purple); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content:center;
  padding: 10px 18px; border-radius: 10px; border: none; cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 700; transition: transform .1s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--c-orange); color: #fff; }
.btn-primary:hover { opacity: .92; }
.btn-purple { background: var(--c-purple); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--c-border); color: var(--c-text); }
.btn-red { background: var(--c-red); color: #fff; }
.btn-yellow { background: var(--c-yellow); color: #453400; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }

.search-box { position: relative; margin-bottom: 18px; }
.search-box input { padding-right: 38px; }
.search-box .icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--c-text-muted); }

.modal-bg {
  display: none; position: fixed; inset: 0; background: rgba(37,28,58,.45);
  align-items: center; justify-content: center; z-index: 50;
}
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 26px; width: 420px; max-width: 92vw; box-shadow: var(--shadow); }
.modal h3 { margin-top: 0; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; }
.alert-error { background: var(--c-red-soft); color: var(--c-red); }
.alert-success { background: #e3f7ea; color: #1c8a49; }

.login-wrap {
  min-height: 100vh; display:flex; align-items:center; justify-content:center;
  background: radial-gradient(circle at 30% 20%, var(--c-purple-soft), var(--c-bg) 60%);
}
.login-card { width: 380px; max-width: 92vw; background:#fff; border-radius: 18px; box-shadow: var(--shadow); padding: 36px 30px;}
.login-card .brand-mark { text-align:center; margin-bottom: 22px; }
.login-card .brand-mark .dot { width:14px;height:14px;border-radius:50%;background:var(--c-orange); display:inline-block; margin-left:6px;}
.login-card h2 { text-align:center; margin: 0 0 26px; font-size: 20px;}

/* ===========================================================
   Mobile layout (<= 900px): off-canvas drawer sidebar
   =========================================================== */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }

  .menu-toggle { display: flex; }

  .sidebar {
    position: fixed; top: 0; right: 0; height: 100%; width: 260px;
    max-width: 82vw; z-index: 100;
    transform: translateX(100%);
    transition: transform .25s ease;
    display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;
    box-shadow: -10px 0 30px rgba(0,0,0,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar nav { display: flex; flex-direction: column; overflow-x: visible; margin-top: 10px; }
  .sidebar .brand { margin-bottom: 6px; }
  .sidebar .logout { margin-top: auto; }

  .topbar { position: sticky; top: 0; z-index: 20; background: var(--c-bg); padding: 12px 0; margin: -12px 0 18px; }
  .topbar h1 { font-size: 17px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .admin-chip { display: none; }

  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .main { padding: 14px; }
}

@media (max-width: 520px) {
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .stat-card .value { font-size: 22px; }
  .login-card { padding: 28px 20px; }
}

/* ---------- Responsive "card" tables for small screens ---------- */
@media (max-width: 720px) {
  table.data, table.data thead, table.data tbody, table.data th, table.data td, table.data tr {
    display: block;
  }
  table.data { white-space: normal; box-shadow: none; background: transparent; }
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.data tr {
    background: var(--c-white); border: 1px solid var(--c-border); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden;
  }
  table.data td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--c-border); font-size: 13px;
  }
  table.data td:last-child { border-bottom: none; }
  table.data td::before {
    content: attr(data-label);
    font-weight: 700; color: var(--c-purple-dark); font-size: 12px; flex-shrink: 0;
  }
  table.data td:empty,
  table.data td[colspan]::before { content: none; }
  table.data td[colspan] { justify-content: center; text-align: center; }
}
