/* =========================================================
   YaCloud Admin – Unified Design System
   ========================================================= */

/* ──────────────────────────────────────────────────────────
   1. Design Tokens
   ────────────────────────────────────────────────────────── */
:root {
    --sidebar-bg: #0f172a;
    --sidebar-width: 220px;
    --sidebar-hover: rgba(255, 255, 255, 0.07);
    --sidebar-active: rgba(99, 179, 237, 0.18);
    --sidebar-active-color: #63b3ed;
    --sidebar-text: #94a3b8;
    --sidebar-brand: #e2e8f0;
    --content-bg: #f8fafc;
    --topbar-bg: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, .05), 0 2px 4px rgba(0, 0, 0, .04);
    --radius-card: 10px;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

/* ──────────────────────────────────────────────────────────
   2. Base Reset
   ────────────────────────────────────────────────────────── */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--content-bg);
    color: #1e293b;
    font-size: 14px;
}

/* ──────────────────────────────────────────────────────────
   3. Sidebar
   ────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 20px 20px;
    color: var(--sidebar-brand);
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .3px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 8px;
}

.sidebar-brand i {
    font-size: 20px;
    color: var(--sidebar-active-color);
}

.sidebar-brand:hover {
    color: #fff;
}

.sidebar-section {
    padding: 6px 12px 2px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #475569;
    margin-top: 8px;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0 8px;
}

.sidebar-nav li {
    margin: 2px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s, color .15s;
}

.sidebar-nav a i {
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #cbd5e1;
}

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-color);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 7px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    transition: background .15s, color .15s;
}

.sidebar-footer a:hover {
    background: var(--sidebar-hover);
    color: #f87171;
}

/* ──────────────────────────────────────────────────────────
   4. Main Wrapper
   ────────────────────────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ──────────────────────────────────────────────────────────
   5. Topbar
   ────────────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0 28px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 8px;
    color: #475569;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
}

.topbar-user:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.topbar-user i.bi-person-circle {
    font-size: 22px;
    color: #94a3b8;
}

.topbar-user .bi-chevron-down {
    font-size: 11px;
}

/* Sidebar toggle – hidden on desktop, shown on mobile */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #475569;
    cursor: pointer;
    font-size: 18px;
    transition: background .15s;
}

.sidebar-toggle:hover {
    background: #f1f5f9;
}

/* ──────────────────────────────────────────────────────────
   6. Page Content
   ────────────────────────────────────────────────────────── */
.page-content {
    padding: 28px;
    flex: 1;
}

/* ──────────────────────────────────────────────────────────
   7. Cards & Tables
   ────────────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    background: #fff;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.table {
    font-size: 13.5px;
    margin: 0;
}

.table thead th {
    font-weight: 500;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    padding: 10px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 11px 16px;
    vertical-align: middle;
    border-color: #f1f5f9;
}

.table tbody tr:hover td {
    background: #f8fafc;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.action-buttons .btn {
    padding: 3px 9px;
    font-size: 12px;
}

/* ──────────────────────────────────────────────────────────
   8. Dropdown
   ────────────────────────────────────────────────────────── */
.dropdown-menu {
    font-size: 13px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: 8px;
}

/* ──────────────────────────────────────────────────────────
   9. Status Indicators
   ────────────────────────────────────────────────────────── */
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-active {
    background: #22c55e;
}

.status-inactive {
    background: #f59e0b;
}

.status-suspended {
    background: #ef4444;
}

/* ──────────────────────────────────────────────────────────
   10. Shared Component Patterns
   ────────────────────────────────────────────────────────── */

/* Page header row */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h4,
.page-header .page-title {
    margin-bottom: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
}

/* Status row – label + value pattern */
.status-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.875rem;
}

.status-row.center {
    align-items: center;
}

.status-label {
    flex-shrink: 0;
    width: 120px;
    color: #64748b;
    font-size: 0.875rem;
    padding-top: 2px;
}

/* ──────────────────────────────────────────────────────────
   11. Badge Polish
   ────────────────────────────────────────────────────────── */
.badge {
    font-weight: 500;
    letter-spacing: .2px;
}

.badge-xs {
    font-size: 10px;
}

/* ──────────────────────────────────────────────────────────
   12. Code / Mono
   ────────────────────────────────────────────────────────── */
code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: .85em;
    color: #0f172a;
}

/* ──────────────────────────────────────────────────────────
   13. Log / Output Panel
   ────────────────────────────────────────────────────────── */
.log-panel {
    background: #0f172a;
    color: #e2e8f0;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.75em;
    line-height: 1.55;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: var(--font-mono);
    margin-bottom: 0;
}

/* ──────────────────────────────────────────────────────────
   14. Inline Save Message
   ────────────────────────────────────────────────────────── */
.save-msg {
    font-size: 0.825rem;
    margin-top: 0.375rem;
}

.save-msg.ok {
    color: #16a34a;
}

.save-msg.err {
    color: #dc2626;
}

/* ──────────────────────────────────────────────────────────
   15. Table State Rows (loading / empty / error)
   ────────────────────────────────────────────────────────── */
.table-state-row td {
    padding: 2rem 1rem !important;
    text-align: center !important;
    vertical-align: middle !important;
}

/* ──────────────────────────────────────────────────────────
   16. Misc Utilities
   ────────────────────────────────────────────────────────── */
.header-search {
    max-width: 280px;
}

/* ──────────────────────────────────────────────────────────
   17. Auth Pages (Login / Must-Change-Password)
   ────────────────────────────────────────────────────────── */
.auth-bg {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, .18);
    padding: 40px 40px 36px;
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.auth-brand i {
    color: #3b82f6;
    font-size: 24px;
}

.auth-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 24px;
}

.auth-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.875rem;
    color: #b91c1c;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-notice {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.875rem;
    color: #92400e;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.auth-notice i {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ──────────────────────────────────────────────────────────
   18. Mobile Sidebar Overlay
   ────────────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 199;
}

/* ──────────────────────────────────────────────────────────
   19. Responsive – Mobile
   ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px;
    }

    .page-content {
        padding: 16px;
    }

    .sidebar-toggle {
        display: flex;
    }

    .table-responsive-x {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}
