/**
 * MS Client Groups - Editorial Design System
 * Colors: brick #871622 primary, warm paper #F7F2EA, ink #171310
 * Typography: Playfair Display (serif headings) + Inter (sans body) + Amiri (Arabic)
 */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&family=Inter:wght@400;500;600;700&family=Amiri:wght@400;700&display=swap');

:root {
    /* Colors */
    --brick: #871622;
    --brick-2: #6d1119;
    --brick-3: #a91d2c;
    --paper: #F7F2EA;
    --paper-2: #EEE7D9;
    --ink: #171310;
    --ink-soft: #3d342f;
    --muted: #857a72;
    --line: #E4DBC9;
    --card: #FFFFFF;
    --success: #2d7a3e;
    --warning: #b8860b;
    --danger: #c0392b;
    --info: #2c5878;

    /* Fonts */
    --font-serif: 'Playfair Display', Georgia, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif, 'Apple Color Emoji', 'Segoe UI Symbol', 'Segoe UI Emoji', 'Noto Color Emoji', 'Noto Sans Symbols';
    --font-arabic: 'Amiri', 'Times New Roman', serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-pill: 999px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
body[dir="rtl"] { font-family: var(--font-arabic), var(--font-sans); }

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 700; color: var(--ink); margin: 0; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

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

/* ============ LOGIN ============ */
.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--paper) 0%, var(--paper-2) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-2xl);
    box-shadow: 0 20px 60px rgba(23, 19, 16, 0.08);
}
.login-brand { text-align: center; margin-bottom: var(--space-xl); }
.login-logo {
    width: 60px; height: 60px;
    background: var(--brick);
    color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif);
    font-weight: 800;
    font-size: 22px;
    margin: 0 auto var(--space-md);
}
.login-brand h1 { font-size: 22px; margin-bottom: 4px; }
.login-brand p { color: var(--muted); font-size: 13px; margin: 0; }
.login-form { display: flex; flex-direction: column; gap: var(--space-md); }
.login-footer {
    margin-top: var(--space-lg);
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    padding-top: var(--space-md);
}
.login-footer a { color: var(--muted); margin: 0 4px; }
.login-footer a.active { color: var(--brick); font-weight: 600; }

/* ============ FORMS ============ */
.form-group { margin-bottom: var(--space-md); }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.15s ease;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--brick);
    box-shadow: 0 0 0 3px rgba(135, 22, 34, 0.1);
}
.form-textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-md); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-sans);
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brick); color: white; }
.btn-primary:hover { background: var(--brick-2); color: white; }
.btn-outline { background: transparent; color: var(--brick); border-color: var(--brick); }
.btn-outline:hover { background: var(--brick); color: white; }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #a03024; color: white; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============ ALERTS ============ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid;
    margin-bottom: var(--space-md);
    font-size: 13px;
}
.alert-success { background: #eaf5ec; border-color: #b8dcc0; color: #1e5a2b; }
.alert-danger  { background: #fbeae7; border-color: #f0b8ae; color: #942318; }
.alert-warning { background: #fcf3d9; border-color: #ecd57e; color: #7d5c00; }
.alert-info    { background: #e6effa; border-color: #a8c4e6; color: #1c4468; }

/* ============ ADMIN SHELL ============ */
.admin-body { background: var(--paper); }
.admin-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
body[dir="rtl"] .admin-shell { grid-template-columns: 1fr 260px; }

.admin-sidebar {
    background: var(--ink);
    color: var(--paper);
    display: flex; flex-direction: column;
    padding: var(--space-lg) 0;
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
}
body[dir="rtl"] .admin-sidebar { grid-column: 2; grid-row: 1; }

.admin-sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 0 var(--space-lg) var(--space-lg);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: var(--space-md);
}
.admin-brand-mark {
    width: 40px; height: 40px;
    background: var(--brick);
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif);
    font-weight: 800;
    color: white;
}
.admin-brand-name { font-family: var(--font-serif); font-weight: 700; font-size: 15px; }
.admin-brand-sub { font-size: 11px; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.08em; }

.admin-nav { flex: 1; padding: 0 var(--space-md); }
.admin-nav-section {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
    color: rgba(255,255,255,0.4);
    padding: var(--space-md) 12px 6px;
    margin-top: var(--space-sm);
}
.admin-nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    color: rgba(255,255,255,0.75);
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 2px;
    transition: all 0.15s ease;
    text-decoration: none;
}
.admin-nav-item:hover { background: rgba(255,255,255,0.06); color: white; text-decoration: none; }
.admin-nav-item.active { background: var(--brick); color: white; }
.admin-nav-icon { font-size: 15px; width: 20px; text-align: center; opacity: 0.9; }

.admin-sidebar-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: var(--space-md);
}
.admin-logout {
    color: rgba(255,255,255,0.6); font-size: 12px;
    padding: 6px 8px; border-radius: 6px;
    display: inline-block;
}
.admin-logout:hover { background: rgba(255,255,255,0.05); color: white; text-decoration: none; }

/* ============ ADMIN MAIN ============ */
.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: var(--space-md) var(--space-xl);
    display: flex; align-items: center; gap: var(--space-md);
    position: sticky; top: 0; z-index: 50;
}
.admin-menu-toggle {
    display: none; background: none; border: none;
    font-size: 22px; color: var(--ink); cursor: pointer;
}
.admin-page-heading { flex: 1; min-width: 0; }
.admin-page-heading h1 { font-size: 20px; }
.admin-page-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }

.admin-topbar-right { display: flex; align-items: center; gap: var(--space-md); }
.admin-lang-toggle { display: flex; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 2px; }
.admin-lang-toggle a {
    padding: 4px 10px; font-size: 11px; font-weight: 600;
    border-radius: var(--radius-pill); color: var(--muted);
}
.admin-lang-toggle a.active { background: var(--brick); color: white; }
.admin-lang-toggle a:hover { text-decoration: none; }

.admin-user-chip { display: flex; align-items: center; gap: 10px; }
.admin-user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--brick); color: white;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif); font-weight: 700; font-size: 13px;
}
.admin-user-name { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.admin-user-role { font-size: 11px; color: var(--muted); }

.admin-content { padding: var(--space-xl); flex: 1; }

/* ============ CARDS ============ */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--line);
}
.card-header h2 { font-size: 18px; }
.card-header p { color: var(--muted); font-size: 12px; margin: 4px 0 0; }

/* ============ STAT GRID ============ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0;
    width: 4px; height: 100%;
    background: var(--brick);
}
body[dir="rtl"] .stat-card::before { left: auto; right: 0; }
.stat-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--muted); font-weight: 600;
}
.stat-value {
    font-family: var(--font-serif);
    font-weight: 700; font-size: 34px;
    color: var(--ink); margin: 6px 0 4px;
    line-height: 1;
}
.stat-sub { font-size: 12px; color: var(--muted); }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th, .data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
body[dir="rtl"] .data-table th, body[dir="rtl"] .data-table td { text-align: right; }
.data-table th {
    background: var(--paper);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}
.data-table tr:hover td { background: rgba(135, 22, 34, 0.02); }
.data-table td.actions { text-align: right; white-space: nowrap; }
body[dir="rtl"] .data-table td.actions { text-align: left; }
.data-table td.actions a, .data-table td.actions button {
    margin-left: 4px; font-size: 12px;
}

/* ============ BADGES ============ */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 8px;
    font-size: 11px; font-weight: 600;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-success { background: #eaf5ec; color: #1e5a2b; }
.badge-danger  { background: #fbeae7; color: #942318; }
.badge-warning { background: #fcf3d9; color: #7d5c00; }
.badge-info    { background: #e6effa; color: #1c4468; }
.badge-muted   { background: var(--paper-2); color: var(--muted); }

.label-chip {
    display: inline-flex; align-items: center;
    padding: 3px 9px;
    font-size: 11px; font-weight: 600;
    border-radius: var(--radius-pill);
    color: #fff;
}

/* ============ QUICK ACTIONS ============ */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-md); }
.quick-action {
    padding: var(--space-lg);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
    transition: all 0.15s ease;
    display: flex; flex-direction: column; gap: 4px;
}
.quick-action:hover { border-color: var(--brick); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(23,19,16,0.06); text-decoration: none; color: var(--ink); }
.quick-action strong { font-family: var(--font-serif); font-size: 16px; }
.quick-action span { color: var(--muted); font-size: 12px; }

/* ============ PAGE HEADER ROW ============ */
.page-actions {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}
.page-actions .actions-left, .page-actions .actions-right {
    display: flex; gap: 8px; align-items: center;
}

/* ============ HELPERS ============ */
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mono { font-family: 'Menlo', 'Courier New', monospace; font-size: 12px; }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .admin-shell { grid-template-columns: 1fr; }
    body[dir="rtl"] .admin-shell { grid-template-columns: 1fr; }
    .admin-sidebar {
        position: fixed; left: -280px; top: 0; width: 280px; z-index: 100;
        transition: left 0.2s ease;
    }
    body[dir="rtl"] .admin-sidebar { left: auto; right: -280px; transition: right 0.2s ease; }
    body.sidebar-open .admin-sidebar { left: 0; }
    body[dir="rtl"].sidebar-open .admin-sidebar { right: 0; }
    .admin-menu-toggle { display: block; }
    .admin-content { padding: var(--space-md); }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .admin-topbar { padding: var(--space-md); }
    .admin-user-chip > div { display: none; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 24px; }
}
