/* ══════════════════════════════════════════════════════
   License Portal — Dark Theme + Full Mobile Support
   ══════════════════════════════════════════════════════ */

:root {
  --bg:          #0d1117;
  --bg-card:     #161b22;
  --bg-elevated: #1c2128;
  --bg-hover:    #21262d;
  --accent:      #00d4aa;
  --accent-dim:  #00d4aa22;
  --text:        #e6edf3;
  --text-dim:    #8b949e;
  --border:      #30363d;
  --border-light:#3d444d;
  --success:     #3fb950;
  --danger:      #f85149;
  --warning:     #d29922;
  --info:        #388bfd;
  --radius:      10px;
  --shadow:      0 4px 16px rgba(0,0,0,0.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}
.navbar-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.3px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: auto;
}
.navbar-back {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  margin-right: auto;
}
.navbar-back:hover { color: var(--text); text-decoration: none; }

/* Hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px 10px;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 12px;
}
.nav-toggle:hover { color: var(--text); border-color: var(--accent); }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.navbar-user {
  color: var(--text-dim);
  font-size: 12px;
  white-space: nowrap;
}

/* ── Container ── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px;
}
.container-narrow { max-width: 680px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none !important;
}
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: 10px; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

.btn-primary  { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { background: #00bfa0; border-color: #00bfa0; }
.btn-secondary{ background: var(--bg-elevated); color: var(--text); border-color: var(--border-light); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger   { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-dim); border-color: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-full     { width: 100%; justify-content: center; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Formulare ── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.label-hint { font-weight: 400; color: var(--text-dim); font-size: 12px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control::placeholder { color: var(--text-dim); }
.font-mono { font-family: 'Consolas', 'Courier New', monospace; letter-spacing: 1px; }
.field-hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 6px;
  flex-wrap: wrap;
}
.card > form { padding: 20px; }

/* ── Feature Checkboxen ── */
.feat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.feat-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.feat-check:hover { border-color: var(--border-light); }
.feat-check.checked { border-color: var(--accent); background: var(--accent-dim); }
.feat-check input[type=checkbox] { display: none; }
.feat-check-icon { font-size: 18px; }
.feat-check-text { flex: 1; font-size: 13px; font-weight: 600; }
.feat-check-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg-hover);
  color: var(--text-dim);
}
.feat-check.checked .feat-check-badge { background: var(--accent); color: #000; }

/* ── Stats ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: center;
}
.stat-number {
  font-size: 30px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 5px;
}
.stat-label { font-size: 12px; color: var(--text-dim); font-weight: 600; }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.search-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  min-width: 200px;
  flex-wrap: wrap;
}
.search-input { max-width: 360px; }

/* ── Tabelle ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  padding: 10px 13px;
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.td-muted { color: var(--text-dim); }
.td-nowrap { white-space: nowrap; }
.td-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline; }
.feat-cell { white-space: nowrap; }

/* ── Code Tags ── */
.code-tag {
  display: inline-block;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  padding: 3px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.code-tag:hover { background: var(--bg-hover); border-color: var(--accent); }
.key-tag { color: var(--accent); letter-spacing: 1px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: #3fb95022; color: var(--success); border: 1px solid #3fb95044; }
.badge-danger  { background: #f8514922; color: var(--danger);  border: 1px solid #f8514944; }
.badge-warning { background: #d2992222; color: var(--warning); border: 1px solid #d2992244; }
.badge-info    { background: #388bfd22; color: var(--info);    border: 1px solid #388bfd44; }

/* ── Feature Icons (in table) ── */
.feat-icon { font-size: 16px; opacity: 1; }
.feat-icon.off { opacity: 0.2; filter: grayscale(1); }

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-success { background: #3fb95015; border-color: #3fb95040; color: var(--success); }
.alert-danger  { background: #f8514915; border-color: #f8514940; color: var(--danger); }
.alert-warning { background: #d2992215; border-color: #d2992240; color: var(--warning); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-dim);
}
.empty-icon { font-size: 48px; margin-bottom: 14px; }

/* ── Page Header ── */
.page-header { margin-bottom: 18px; }
.page-title  { font-size: 20px; font-weight: 800; color: var(--text); }

/* ── Auth Pages ── */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at 20% 50%, #00d4aa0a 0%, transparent 60%), var(--bg);
  padding: 16px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}
.auth-logo   { font-size: 44px; text-align: center; margin-bottom: 10px; }
.auth-title  { font-size: 20px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.auth-sub    { color: var(--text-dim); text-align: center; font-size: 13px; margin-bottom: 22px; }

/* ── Success Card ── */
.success-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 24px;
  text-align: center;
}
.success-icon  { font-size: 52px; margin-bottom: 12px; }
.success-title { font-size: 19px; font-weight: 800; margin-bottom: 20px; }
.success-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 20px;
  margin-bottom: 16px;
}
.success-hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
}
.info-grid { text-align: left; }
.info-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.info-row:last-child { border-bottom: none; }
.info-label {
  min-width: 86px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  flex-shrink: 0;
}
.info-value { font-weight: 600; word-break: break-all; }

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Tablet  ≤ 900px
   ══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Mobile  ≤ 640px
   ══════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* Navbar */
  .navbar {
    padding: 0 14px;
    height: 52px;
    flex-wrap: nowrap;
  }
  .navbar-brand { font-size: 14px; }
  .nav-toggle { display: flex; }

  .navbar-right {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px 16px;
    gap: 8px;
    z-index: 199;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  }
  .navbar-right.open { display: flex; }
  .navbar-right .btn { justify-content: center; padding: 11px; font-size: 13px; }
  .navbar-user { text-align: center; padding: 4px 0; font-size: 13px; }

  /* Container */
  .container { padding: 14px 12px; }

  /* Stats */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
  .stat-number { font-size: 24px; }

  /* Toolbar */
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .search-form { flex-wrap: nowrap; }
  .search-input { max-width: 100%; }
  .toolbar > .btn { width: 100%; justify-content: center; }

  /* Page header */
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px;
  }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Form */
  .feat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; justify-content: center; }
  .auth-card { padding: 26px 18px; }

  /* Buttons in card header */
  .card-header { flex-direction: column; align-items: flex-start; }

  /* ── جداول الهاتف: تحويل الصفوف إلى بطاقات ── */
  .table-wrap { overflow-x: visible; }

  .table thead { display: none; }

  .table tbody tr {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 4px 0;
  }
  .table tbody tr:hover { background: var(--bg-elevated); }
  .table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
  .table tbody tr td:last-child { border-bottom: none !important; }

  .table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    gap: 10px;
  }

  .table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 80px;
  }

  /* أعمدة الأرقام والأكواد */
  .code-tag { font-size: 11px; padding: 2px 6px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

  /* عمود الأكشن */
  .td-actions { justify-content: flex-end; }
  .td-actions::before { flex: 1; }

  /* إخفاء بعض الأعمدة الثانوية */
  .td-hide-mobile { display: none !important; }

  /* Success card */
  .success-card { padding: 22px 16px; }
  .success-actions { flex-direction: column; }
  .success-actions .btn { width: 100%; justify-content: center; }
  .info-label { min-width: 70px; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — Small Mobile  ≤ 380px
   ══════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .feat-grid { grid-template-columns: 1fr; }
  .navbar-brand { font-size: 13px; }
}
