/* ============================================================
   Bokan Technologies - Dark Professional Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --primary: var(--tenant-primary, #00d4aa);
    --secondary: var(--tenant-secondary, #4da6ff);
    --accent-purple: #a78bfa;
    --accent-orange: #fb923c;
    --accent-red: #ef4444;
    --accent-green: #22c55e;
    --accent-yellow: #eab308;

    --bg-darkest: #060911;
    --bg-darker: #0a0e17;
    --bg-dark: #111827;
    --bg-card: #1a2234;
    --bg-card-hover: #1f2a40;
    --bg-input: #0f1729;
    --bg-sidebar: #0b1120;

    --border: #1e293b;
    --border-light: #2a3a52;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dark: #334155;

    --sidebar-width: 260px;
    --topbar-height: 64px;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px rgba(0, 212, 170, 0.15);

    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --transition: 0.2s ease;
}

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg-darker);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--secondary); }

/* ---- LAYOUT ---- */
.app-wrapper { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.sidebar-brand img {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}
.sidebar-brand h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

.nav-section { padding: 0 16px; margin-bottom: 4px; }
.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 12px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    margin: 2px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
    transition: all var(--transition);
    gap: 12px;
    cursor: pointer;
}
.nav-item i { width: 20px; text-align: center; font-size: 1rem; opacity: 0.7; }
.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}
.nav-item:hover i { opacity: 1; }
.nav-item.active {
    background: rgba(0, 212, 170, 0.1);
    color: var(--primary);
    font-weight: 500;
}
.nav-item.active i { opacity: 1; color: var(--primary); }

.nav-badge {
    margin-left: auto;
    background: var(--accent-red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}
.sidebar-user:hover { background: var(--bg-card); }
.sidebar-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem; color: #fff;
    flex-shrink: 0;
}
.sidebar-user-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.7rem; color: var(--text-muted); }

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

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-left h2 { font-size: 1.15rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
}

/* Notification bell */
.notification-bell {
    position: relative;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 8px;
    transition: color var(--transition);
}
.notification-bell:hover { color: var(--text-primary); }
.notification-badge {
    position: absolute;
    top: 2px; right: 2px;
    background: var(--accent-red);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-dark);
}

/* Content area */
.content-area {
    flex: 1;
    padding: 24px;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* Stat cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-1px); box-shadow: var(--shadow); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-icon.green { background: rgba(0,212,170,0.12); color: var(--primary); }
.stat-icon.blue { background: rgba(77,166,255,0.12); color: var(--secondary); }
.stat-icon.purple { background: rgba(167,139,250,0.12); color: var(--accent-purple); }
.stat-icon.orange { background: rgba(251,146,60,0.12); color: var(--accent-orange); }
.stat-icon.red { background: rgba(239,68,68,0.12); color: var(--accent-red); }
.stat-info { flex: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-family: var(--font-mono); }
.stat-change { font-size: 0.75rem; margin-top: 4px; }
.stat-change.up { color: var(--accent-green); }
.stat-change.down { color: var(--accent-red); }

/* ---- TABLES ---- */
.table-responsive { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-secondary);
    vertical-align: middle;
}
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---- BADGES / STATUS ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.02em;
}
.badge-success { background: rgba(34,197,94,0.12); color: #22c55e; }
.badge-warning { background: rgba(234,179,8,0.12); color: #eab308; }
.badge-danger { background: rgba(239,68,68,0.12); color: #ef4444; }
.badge-info { background: rgba(77,166,255,0.12); color: #4da6ff; }
.badge-secondary { background: rgba(148,163,184,0.12); color: #94a3b8; }
.badge-primary { background: rgba(0,212,170,0.12); color: var(--primary); }
.badge-purple { background: rgba(167,139,250,0.12); color: var(--accent-purple); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-body);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn i { font-size: 0.9em; }

.btn-primary {
    background: var(--primary);
    color: #0a0e17;
    border-color: var(--primary);
}
.btn-primary:hover { background: #00eabc; color: #0a0e17; box-shadow: 0 0 20px rgba(0,212,170,0.3); }

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-light);
}
.btn-secondary:hover { background: var(--bg-card); color: var(--text-primary); border-color: var(--text-muted); }

.btn-danger {
    background: rgba(239,68,68,0.12);
    color: var(--accent-red);
    border-color: rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-icon { padding: 8px; min-width: 36px; justify-content: center; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-body);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,212,170,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control.is-invalid { border-color: var(--accent-red); }
.invalid-feedback { font-size: 0.78rem; color: var(--accent-red); margin-top: 4px; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    accent-color: var(--primary);
    width: 16px; height: 16px;
}

.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

/* ---- ALERTS ---- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid;
}
.alert-success { background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.2); color: #22c55e; }
.alert-danger { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); color: #ef4444; }
.alert-warning { background: rgba(234,179,8,0.08); border-color: rgba(234,179,8,0.2); color: #eab308; }
.alert-info { background: rgba(77,166,255,0.08); border-color: rgba(77,166,255,0.2); color: #4da6ff; }
.alert .btn-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    font-size: 1.1rem;
}

/* ---- MODALS ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.2rem; cursor: pointer;
}
.modal-body { padding: 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- PAGINATION ---- */
.pagination { display: flex; gap: 4px; list-style: none; }
.page-item .page-link {
    display: flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px;
    padding: 0 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.82rem;
    transition: all var(--transition);
    text-decoration: none;
}
.page-item .page-link:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.page-item.active .page-link { background: var(--primary); color: var(--bg-darker); border-color: var(--primary); font-weight: 600; }
.page-item.disabled .page-link { opacity: 0.4; cursor: default; }

/* ---- LOGIN PAGE ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-darkest);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(0,212,170,0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(77,166,255,0.06) 0%, transparent 50%);
    padding: 20px;
}
.login-box {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    box-shadow: var(--shadow-lg);
}
.login-brand {
    text-align: center;
    margin-bottom: 32px;
}
.login-brand img { width: 56px; height: 56px; margin-bottom: 12px; border-radius: var(--radius); }
.login-brand h1 { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); }
.login-brand p { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ---- TOAST NOTIFICATIONS ---- */
.toast-container {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    min-width: 300px;
    border: 1px solid;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- UTILITY ---- */
.text-primary-color { color: var(--primary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.font-mono { font-family: var(--font-mono); }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-end { text-align: right; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.3; }
.empty-state h4 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.88rem; max-width: 400px; margin: 0 auto 20px; }

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    top: 100%; right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 6px;
    z-index: 500;
    display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
}
.dropdown-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ---- RESPONSIVE ---- */
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 992px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .content-area { padding: 16px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: 100%; }
    .topbar { padding: 0 16px; }
}

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- LOADING ---- */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(6,9,17,0.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 5000;
}
