/* assets/css/portal.css
   Base styling for the portal (admin + app + public areas).
   Keep this file for PORTAL styling only — widget styling lives in
   /widget/loader.js (self-contained) and must stay separate since it's
   loaded on customer websites and must not leak portal styles there.

   THEME SYSTEM: every color used anywhere in this file should reference
   one of the CSS custom properties below, never a hardcoded hex value.
   Dark mode works by overriding these properties when <html> has
   data-theme="dark" (set by the small inline script in
   Admin/partials/admin-nav.php, persisted via localStorage under the
   key "admin_theme"). Adding a hardcoded color anywhere breaks dark mode
   for that element — always add a new variable instead. */

:root {
    --brand: #0d6efd;
    --brand-dark: #0b5ed7;
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e2e8f0;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning-bg: #fef9c3;
    --warning-text: #854d0e;
    --shadow: rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
    --brand: #3b82f6;
    --brand-dark: #2563eb;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-alt: #17233a;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --border: #334155;
    --danger: #f87171;
    --danger-bg: #451a1a;
    --danger-text: #fca5a5;
    --success: #4ade80;
    --success-bg: #14291c;
    --success-text: #86efac;
    --warning-bg: #3a2e0e;
    --warning-text: #fde68a;
    --shadow: rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-box {
    background: var(--surface);
    padding: 32px;
    border-radius: 10px;
    box-shadow: 0 4px 16px var(--shadow);
    width: 100%;
    max-width: 380px;
}

.auth-box h1 { font-size: 20px; margin-bottom: 16px; }

label { display: block; margin-bottom: 14px; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], textarea, select {
    width: 100%;
    padding: 9px 10px;
    margin-top: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}

button, .btn-primary {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
}
button:hover, .btn-primary:hover { background: var(--brand-dark); }

.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-approve { background: var(--success); color: #fff; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.btn-reject  { background: var(--danger); color: #fff; border: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; }

.status-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.status-active { background: var(--success-bg); color: var(--success-text); }
.status-pending { background: var(--warning-bg); color: var(--warning-text); }
.status-suspended { background: var(--danger-bg); color: var(--danger-text); }
.status-rejected { background: var(--surface-alt); color: var(--text-muted); }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-error   { background: var(--danger-bg); color: var(--danger-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }

/* ---------------------------------------------------------------
   Top nav (used by tenant /app and public-facing pages — NOT Admin,
   which uses the sidebar layout below instead)
   --------------------------------------------------------------- */
.portal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
}
.portal-nav-brand { font-weight: 600; }
.portal-nav-links a { margin-left: 16px; color: var(--text); text-decoration: none; font-size: 14px; }
.portal-nav-links a:hover { color: var(--brand); }

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin: 20px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; text-align: center; }
.stat-card span { display: block; font-size: 26px; font-weight: 700; color: var(--brand); }

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); margin-top: 12px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
.data-table th { background: var(--surface-alt); }
.actions form { margin-right: 4px; }

/* RTL support: applied via <html dir="rtl"> on Arabic-rendered pages */
html[dir="rtl"] .portal-nav-links a { margin-left: 0; margin-right: 16px; }
html[dir="rtl"] .data-table th, html[dir="rtl"] .data-table td { text-align: right; }

/* ---------------------------------------------------------------
   Admin sidebar layout
   Structure (unchanged in every Admin/*.php page — only this CSS
   changed, so no page markup needed editing):
     <body>
       <?php include partials/admin-nav.php; ?>   <-- outputs <nav class="admin-sidebar">
       <main class="container">...</main>
     </body>
   The sidebar is fixed-position; main is pushed over via margin.
   Scoped with the adjacent-sibling selector so this never affects
   tenant (.portal-nav) or public pages, which don't use .admin-sidebar.
   --------------------------------------------------------------- */
.admin-sidebar {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    width: 240px;
    height: 100vh;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.2s ease;
}

.admin-sidebar-brand {
    font-weight: 700;
    font-size: 15px;
    padding: 0 8px 4px;
}
.admin-sidebar-role {
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 8px 16px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.admin-sidebar-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.admin-sidebar-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    padding: 9px 10px;
    border-radius: 6px;
}
.admin-sidebar-links a:hover { background: var(--surface-alt); }
.admin-sidebar-links a.active { background: var(--brand); color: #fff; }

.admin-sidebar-section-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 14px 10px 4px;
}

.admin-sidebar-bottom {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.admin-sidebar-toggle-btn {
    display: none;
    position: fixed;
    top: 14px;
    inset-inline-start: 14px;
    z-index: 110;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    font-size: 18px;
}

.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
}

/* Push page content over to make room for the fixed sidebar, on any
   page where the sidebar immediately precedes a .container */
.admin-sidebar + main.container {
    margin-inline-start: 240px;
    max-width: none;
    padding-inline-start: 48px;
    padding-inline-end: 40px;
}

@media (max-width: 860px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    html[dir="rtl"] .admin-sidebar {
        transform: translateX(100%);
    }
    .admin-sidebar.admin-sidebar-open {
        transform: translateX(0);
    }
    .admin-sidebar-toggle-btn { display: flex; }
    .admin-sidebar-overlay.admin-sidebar-overlay-visible { display: block; }
    .admin-sidebar + main.container {
        margin-inline-start: 0;
        padding-inline-start: 24px;
        padding-inline-end: 24px;
        padding-top: 64px;
    }
}
