/* K4 Cards Admin — Light modern theme */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
    --k4-primary: #2563eb;
    --k4-primary-soft: #eff6ff;
    --k4-success: #10b981;
    --k4-warning: #f59e0b;
    --k4-danger: #ef4444;
    --k4-info: #06b6d4;
    --k4-bg: #f1f5f9;
    --k4-surface: #ffffff;
    --k4-border: #e2e8f0;
    --k4-text: #0f172a;
    --k4-muted: #64748b;
    --k4-sidebar-w: 268px;
    --k4-radius: 14px;
    --k4-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
    --k4-shadow-hover: 0 8px 24px rgba(37, 99, 235, 0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
    background: var(--k4-bg);
    color: var(--k4-text);
    min-height: 100vh;
}

/* Sidebar — light */
.k4-sidebar {
    width: var(--k4-sidebar-w);
    min-height: 100vh;
    background: var(--k4-surface);
    border-left: 1px solid var(--k4-border);
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.k4-brand {
    padding: 1.25rem 1.35rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-bottom: 1px solid var(--k4-border);
}

.k4-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--k4-primary), #6366f1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.k4-brand-text { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.k4-brand-sub { font-size: 0.72rem; color: var(--k4-muted); }

.k4-nav { flex: 1; padding: 0.75rem 0.65rem; overflow-y: auto; }

.k4-nav-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--k4-muted);
    padding: 0.75rem 0.85rem 0.35rem;
}

.k4-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 2px;
    border-radius: 10px;
    color: #475569;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.2s ease;
}

.k4-nav a i { font-size: 1.15rem; width: 1.35rem; text-align: center; }

.k4-nav a:hover {
    background: var(--k4-primary-soft);
    color: var(--k4-primary);
    transform: translateX(-2px);
}

.k4-nav a.active {
    background: linear-gradient(90deg, var(--k4-primary-soft), transparent);
    color: var(--k4-primary);
    font-weight: 600;
    border-right: 3px solid var(--k4-primary);
}

.k4-nav-badge {
    margin-right: auto;
    background: var(--k4-danger);
    color: #fff;
    font-size: 0.65rem;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.k4-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--k4-border);
}

.k4-user-chip {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem;
    margin-bottom: 0.65rem;
    border-radius: 10px;
    background: var(--k4-bg);
}

.k4-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, var(--k4-primary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

/* Main + Topbar */
.k4-main { margin-right: var(--k4-sidebar-w); min-height: 100vh; }

.k4-topbar {
    background: var(--k4-surface);
    border-bottom: 1px solid var(--k4-border);
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.k4-topbar-title { font-weight: 700; font-size: 1.15rem; margin: 0; }
.k4-topbar-meta { font-size: 0.82rem; color: var(--k4-muted); }

.k4-content { padding: 1.5rem; animation: fadeInUp 0.45s ease; }

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stat cards */
.k4-stat {
    background: var(--k4-surface);
    border-radius: var(--k4-radius);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--k4-shadow);
    border: 1px solid var(--k4-border);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: fadeInUp 0.5s ease backwards;
    height: 100%;
}

.k4-stat:hover {
    transform: translateY(-4px);
    box-shadow: var(--k4-shadow-hover);
}

.k4-stat:nth-child(1) { animation-delay: 0.05s; }
.k4-stat:nth-child(2) { animation-delay: 0.1s; }
.k4-stat:nth-child(3) { animation-delay: 0.15s; }
.k4-stat:nth-child(4) { animation-delay: 0.2s; }

.k4-stat-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.k4-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.k4-stat-icon.blue { background: #dbeafe; color: var(--k4-primary); }
.k4-stat-icon.green { background: #d1fae5; color: var(--k4-success); }
.k4-stat-icon.amber { background: #fef3c7; color: var(--k4-warning); }
.k4-stat-icon.cyan { background: #cffafe; color: var(--k4-info); }
.k4-stat-icon.rose { background: #ffe4e6; color: #e11d48; }
.k4-stat-icon.violet { background: #ede9fe; color: #7c3aed; }

.k4-stat-label { font-size: 0.82rem; color: var(--k4-muted); font-weight: 500; }
.k4-stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1.2; }
.k4-stat-foot { font-size: 0.75rem; color: var(--k4-muted); margin-top: 0.35rem; }

/* Panels */
.k4-panel {
    background: var(--k4-surface);
    border-radius: var(--k4-radius);
    border: 1px solid var(--k4-border);
    box-shadow: var(--k4-shadow);
    overflow: hidden;
    animation: fadeInUp 0.55s ease backwards;
}

.k4-panel-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--k4-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.k4-panel-body { padding: 0; }

.k4-panel .table { margin: 0; }
.k4-panel .table thead th {
    background: #f8fafc;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--k4-muted);
    border-bottom: 1px solid var(--k4-border);
    padding: 0.75rem 1rem;
}

.k4-panel .table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    font-size: 0.9rem;
}

.k4-panel .table tbody tr {
    transition: background 0.15s ease;
}

.k4-panel .table tbody tr:hover { background: #f8fafc; }

/* Quick actions */
.k4-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.k4-quick a {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    background: var(--k4-surface);
    border: 1px solid var(--k4-border);
    border-radius: 999px;
    color: var(--k4-text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--k4-shadow);
}

.k4-quick a:hover {
    border-color: var(--k4-primary);
    color: var(--k4-primary);
    background: var(--k4-primary-soft);
    transform: translateY(-2px);
}

/* Tenant cards */
.k4-tenant-card {
    background: var(--k4-surface);
    border-radius: var(--k4-radius);
    border: 1px solid var(--k4-border);
    padding: 1.25rem;
    transition: all 0.25s ease;
    height: 100%;
}

.k4-tenant-card:hover {
    border-color: var(--k4-primary);
    box-shadow: var(--k4-shadow-hover);
}

/* Alerts */
.k4-alert-wrap .alert {
    border-radius: 12px;
    border: none;
    animation: fadeInUp 0.3s ease;
}

/* Login */
.k4-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #f1f5f9 50%, #e0e7ff 100%);
    padding: 1.5rem;
}

.k4-login-card {
    width: 100%;
    max-width: 420px;
    background: var(--k4-surface);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.1);
    padding: 2rem;
    animation: fadeInUp 0.5s ease;
}

/* Mobile */
.k4-menu-toggle { display: none; }

@media (max-width: 992px) {
    .k4-sidebar { transform: translateX(100%); }
    .k4-sidebar.open { transform: translateX(0); box-shadow: -8px 0 30px rgba(0,0,0,0.1); }
    .k4-main { margin-right: 0; }
    .k4-menu-toggle { display: inline-flex; }
    .k4-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,0.4);
        z-index: 1030;
    }
    .k4-overlay.show { display: block; }
}

/* Live dot */
.k4-live {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: var(--k4-success);
    font-weight: 500;
}

.k4-live::before {
    content: '';
    width: 7px;
    height: 7px;
    background: var(--k4-success);
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* Legacy Bootstrap cards → unified theme */
.table-card {
    background: var(--k4-surface);
    border: 1px solid var(--k4-border) !important;
    border-radius: var(--k4-radius) !important;
    box-shadow: var(--k4-shadow);
    overflow: hidden;
    animation: fadeInUp 0.45s ease backwards;
}

.table-card > .card-header,
.table-card .card-header {
    background: #f8fafc !important;
    border-bottom: 1px solid var(--k4-border);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.table-card .table thead th {
    background: #f8fafc;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--k4-muted);
    border-bottom: 1px solid var(--k4-border);
}

.table-card .table tbody tr { transition: background 0.15s ease; }
.table-card .table tbody tr:hover { background: #f8fafc; }

.stat-card {
    background: var(--k4-surface);
    border: 1px solid var(--k4-border) !important;
    border-radius: var(--k4-radius) !important;
    box-shadow: var(--k4-shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: fadeInUp 0.5s ease backwards;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--k4-shadow-hover);
}

.stat-card .value { font-size: 1.65rem; font-weight: 700; }

/* Filters & forms */
.k4-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    background: var(--k4-surface);
    border: 1px solid var(--k4-border);
    border-radius: var(--k4-radius);
    box-shadow: var(--k4-shadow);
}

.k4-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.k4-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--k4-muted);
}

.k4-empty i { font-size: 2.5rem; opacity: 0.35; display: block; margin-bottom: 0.75rem; }

.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--k4-border);
}

.form-control:focus, .form-select:focus {
    border-color: var(--k4-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn-primary {
    background: var(--k4-primary);
    border-color: var(--k4-primary);
    border-radius: 10px;
}

.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.k4-tenant-card .k4-metric {
    text-align: center;
    padding: 0.5rem;
    border-radius: 10px;
    background: var(--k4-bg);
}

.k4-tenant-card .k4-metric-val { font-size: 1.25rem; font-weight: 700; }
.k4-tenant-card .k4-metric-lbl { font-size: 0.72rem; color: var(--k4-muted); }
