/* =================================================================
   Navy Dark Theme — Global Stylesheet
   Replaces cyberpunk-global.css
   Version: 2.0.0
   ================================================================= */

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

/* =================================================================
   CSS VARIABLES
   ================================================================= */
:root {
    --bg-base:        #0e1422;
    --bg-surface:     #131c2e;
    --bg-card:        #1a2540;
    --bg-elevated:    #1e2d4a;
    --bg-hover:       #203052;
    --bg-active:      #1e3460;

    --border:         #253350;
    --border-light:   #2e3d60;
    --border-focus:   #0077ed;

    --accent:         #0077ed;
    --accent-hover:   #0088ff;
    --accent-dim:     rgba(0,119,237,0.15);
    --accent-glow:    rgba(0,119,237,0.25);

    --success:        #30d158;
    --success-dim:    rgba(48,209,88,0.15);
    --warning:        #ff9f0a;
    --warning-dim:    rgba(255,159,10,0.15);
    --danger:         #ff453a;
    --danger-dim:     rgba(255,69,58,0.15);
    --info:           #32abe6;
    --info-dim:       rgba(50,171,230,0.15);

    --text:           #dce8f5;
    --text-muted:     #7a93b4;
    --text-dim:       #4a6070;

    --sidebar-w:           280px;
    --sidebar-collapsed-w: 60px;
    --radius:         10px;
    --radius-sm:      6px;
    --radius-lg:      14px;

    --transition:     0.18s ease;
    --shadow-sm:      0 1px 4px rgba(0,0,0,0.3);
    --shadow:         0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg:      0 8px 32px rgba(0,0,0,0.5);
}

/* =================================================================
   BASE
   ================================================================= */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-base);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    transition: margin-left var(--transition);
}

.content-wrapper {
    flex: 1;
    padding: 1.75rem 2rem;
    max-width: 1440px;
}

/* =================================================================
   SIDEBAR
   ================================================================= */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    transition: width 0.25s cubic-bezier(0.4,0,0.2,1), transform var(--transition);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    margin-bottom: 0;
}

.sidebar-brand:hover {
    color: var(--accent-hover);
}

.brand-icon {
    width: 34px;
    height: 34px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.brand-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

/* User Profile Card */
.user-profile-card {
    margin: 0.75rem 0 0;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 1px;
}

/* Sidebar Search */
.sidebar-search {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.search-wrapper {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.8rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.55rem 0.75rem 0.55rem 2.1rem;
    font-size: 0.82rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input::placeholder {
    color: var(--text-dim);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0 1rem;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 0.25rem;
}

.nav-section-title {
    font-size: 0.67rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    padding: 0.85rem 1.25rem 0.3rem;
}

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

/* =================================================================
   NAV ITEM FADE-IN ON LOAD
   ================================================================= */
@keyframes navItemSlideIn {
    from {
        opacity: 0;
        transform: translateX(-18px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.nav-item {
    margin: 0;
    animation: navItemSlideIn 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.nav-section:nth-child(1) .nav-item:nth-child(1)  { animation-delay: 0.04s; }
.nav-section:nth-child(1) .nav-item:nth-child(2)  { animation-delay: 0.09s; }
.nav-section:nth-child(1) .nav-item:nth-child(3)  { animation-delay: 0.14s; }
.nav-section:nth-child(1) .nav-item:nth-child(4)  { animation-delay: 0.19s; }
.nav-section:nth-child(1) .nav-item:nth-child(5)  { animation-delay: 0.24s; }
.nav-section:nth-child(1) .nav-item:nth-child(6)  { animation-delay: 0.29s; }
.nav-section:nth-child(2) .nav-item:nth-child(1)  { animation-delay: 0.30s; }
.nav-section:nth-child(2) .nav-item:nth-child(2)  { animation-delay: 0.35s; }
.nav-section:nth-child(2) .nav-item:nth-child(3)  { animation-delay: 0.40s; }
.nav-section:nth-child(3) .nav-item:nth-child(1)  { animation-delay: 0.44s; }
.nav-section:nth-child(3) .nav-item:nth-child(2)  { animation-delay: 0.49s; }
.nav-section:nth-child(4) .nav-item:nth-child(1)  { animation-delay: 0.52s; }
.nav-section:nth-child(5) .nav-item:nth-child(1)  { animation-delay: 0.55s; }
.nav-section:nth-child(5) .nav-item:nth-child(2)  { animation-delay: 0.60s; }
.nav-section:nth-child(5) .nav-item:nth-child(3)  { animation-delay: 0.64s; }
.nav-section:nth-child(5) .nav-item:nth-child(4)  { animation-delay: 0.68s; }
.nav-section:nth-child(6) .nav-item:nth-child(1)  { animation-delay: 0.70s; }
.nav-section:nth-child(6) .nav-item:nth-child(2)  { animation-delay: 0.75s; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 450;
    border-radius: 0;
    transition:
        background 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
        color 0.18s ease,
        transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
        padding-left 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    border: none;
    background: transparent;
    width: 100%;
    will-change: transform;
}

.nav-link:hover {
    background: rgba(255, 153, 0, 0.08);
    color: #ff9900;
    transform: translateX(5px);
    padding-left: 1.45rem;
}

.nav-link.active {
    background: rgba(255, 153, 0, 0.13);
    color: #ff9900;
    font-weight: 600;
    transform: translateX(4px);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 10%;
    height: 80%;
    width: 3px;
    background: #ff9900;
    border-radius: 0 3px 3px 0;
    box-shadow: 0 0 8px rgba(255, 153, 0, 0.5);
}

.nav-link-icon {
    width: 20px;
    text-align: center;
    font-size: 0.875rem;
    flex-shrink: 0;
    opacity: 0.75;
}

.nav-link.active .nav-link-icon {
    opacity: 1;
}

/* =================================================================
   NAV ICON — colorful per route
   ================================================================= */
.nav-icon {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
    transform: scale(1.18);
    filter: drop-shadow(0 0 6px currentColor);
}

/* Dashboard — blue */
a[href="/dashboard"] .nav-icon { color: #4a9eff; }
/* Organizations — cyan */
a[href="/organizations"] .nav-icon { color: #00d8d8; }
/* Projects — green */
a[href="/projects"] .nav-icon { color: #30d158; }
/* Workspaces — purple */
a[href="/workspaces"] .nav-icon { color: #bf5af2; }
/* Tasks — yellow */
a[href="/tasks"] .nav-icon { color: #ffd60a; }
/* Groups — orange */
a[href="/groups"] .nav-icon { color: #ff6b2b; }
/* Changes — teal */
a[href="/changes"] .nav-icon { color: #64d2ff; }
/* Files — amber */
a[href="/files"] .nav-icon { color: #ff9f0a; }
/* Users — pink */
a[href="/users"] .nav-icon { color: #ff375f; }
/* Roles — indigo */
a[href="/roles"] .nav-icon { color: #5e5ce6; }
/* Notifications — coral */
a[href="/notifications"] .nav-icon { color: #ff6060; }
/* Reports — emerald */
a[href="/reports"] .nav-icon { color: #32d74b; }
/* AI Chat — magenta */
a[href="/ai-chat"] .nav-icon { color: #ff2d55; }
/* Docs — sky */
a[href="/docs"] .nav-icon { color: #0a84ff; }
/* Settings — slate */
a[href="/settings"] .nav-icon { color: #8e8e93; }
/* Security — red */
a[href="/security"] .nav-icon { color: #ff3b30; }
/* Logs — orange */
a[href="/logs"] .nav-icon { color: #ff9500; }
/* Backups — teal */
a[href="/backups"] .nav-icon { color: #5ac8fa; }
/* Profile — lavender */
a[href="/profile"] .nav-icon { color: #c77dff; }
/* Logout — red-dim */
a[href="/logout"] .nav-icon { color: #ff453a; }

/* Active: icon inherits accent orange instead of route color */
.nav-link.active .nav-icon {
    color: #ff9900 !important;
}

.nav-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 20px;
    background: var(--accent);
    color: #fff;
    line-height: 1.4;
    flex-shrink: 0;
}

.nav-badge.badge-warning {
    background: var(--warning);
    color: #000;
}

.nav-badge.badge-success {
    background: var(--success);
    color: #000;
}

.nav-badge.badge-danger {
    background: var(--danger);
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

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

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1060;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background var(--transition);
}

.mobile-menu-toggle:hover {
    background: var(--bg-hover);
}

/* =================================================================
   BREADCRUMB
   ================================================================= */
.breadcrumb-nav {
    padding: 0.65rem 0 1rem;
    margin-bottom: 0;
}

.breadcrumb {
    background: transparent;
    padding: 0;
    margin: 0;
    font-size: 0.8rem;
}

.breadcrumb-item {
    color: var(--text-muted);
}

.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.breadcrumb-item a:hover {
    color: var(--accent-hover);
}

.breadcrumb-item.active {
    color: var(--text);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-dim);
}

/* =================================================================
   FLASH MESSAGES
   ================================================================= */
.flash-message {
    border-radius: var(--radius);
    border: 1px solid transparent;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: alertSlideIn 0.25s ease-out;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.flash-message.alert-success,
.alert-success {
    background: var(--success-dim);
    border-color: var(--success);
    color: var(--success);
}

.flash-message.alert-danger,
.alert-danger {
    background: var(--danger-dim);
    border-color: var(--danger);
    color: var(--danger);
}

.flash-message.alert-warning,
.alert-warning {
    background: var(--warning-dim);
    border-color: var(--warning);
    color: var(--warning);
}

.flash-message.alert-info,
.alert-info {
    background: var(--info-dim);
    border-color: var(--info);
    color: var(--info);
}

.alert {
    border-radius: var(--radius);
    border-width: 1px;
    font-size: 0.875rem;
}

.btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.6;
}
.btn-close:hover {
    opacity: 1;
}

/* =================================================================
   TOAST NOTIFICATIONS
   ================================================================= */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    min-width: 300px;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    pointer-events: all;
    animation: toastIn 0.25s ease-out;
    position: relative;
    overflow: hidden;
}

.toast.hide {
    animation: toastOut 0.22s ease-in forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}

.toast-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-error   .toast-icon { color: var(--danger); }
.toast.toast-warning .toast-icon { color: var(--warning); }
.toast.toast-info    .toast-icon { color: var(--info); }

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-word;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0;
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: color var(--transition);
}
.toast-close:hover {
    color: var(--text);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 0 var(--radius-sm);
    animation: toastProgress linear;
    transform-origin: left;
}

@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

/* =================================================================
   LOADING OVERLAY
   ================================================================= */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14,20,34,0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-spinner svg.ldr-svg {
    width: 140px;
    height: 140px;
    display: block;
    overflow: visible; /* filtry glow wychodzą poza viewBox */
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    animation: loadingTextPulse 1.8s ease-in-out infinite;
}

@keyframes loadingTextPulse {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 1; }
}

/* =================================================================
   CARDS
   ================================================================= */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
    padding: 0.75rem 1.25rem;
}

/* =================================================================
   BUTTONS
   ================================================================= */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

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

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #000;
}
.btn-success:hover {
    background: #28c450;
    border-color: #28c450;
    color: #000;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #e03a30;
    border-color: #e03a30;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #000;
}
.btn-warning:hover {
    background: #e08800;
    border-color: #e08800;
    color: #000;
}

.btn-outline-primary {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
}
.btn-outline-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
    border-radius: var(--radius);
}

/* =================================================================
   FORMS
   ================================================================= */
.form-control,
.form-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control::placeholder {
    color: var(--text-dim);
}

.form-control:focus,
.form-select:focus {
    background: var(--bg-card);
    border-color: var(--border-focus);
    color: var(--text);
    box-shadow: 0 0 0 3px var(--accent-dim);
    outline: none;
}

.form-select option {
    background: var(--bg-card);
    color: var(--text);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-text {
    font-size: 0.77rem;
    color: var(--text-dim);
}

.form-check-input {
    background-color: var(--bg-card);
    border-color: var(--border-light);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

/* =================================================================
   TABLES
   ================================================================= */
.table {
    color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border);
    font-size: 0.875rem;
}

.table thead th {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.85rem;
    background: var(--bg-card);
}

.table tbody td {
    padding: 0.7rem 0.85rem;
    border-color: var(--border);
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: var(--bg-card);
    color: var(--text);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
    background: rgba(26,37,64,0.4);
    color: var(--text);
}

/* =================================================================
   BADGES
   ================================================================= */
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 20px;
    padding: 0.25rem 0.55rem;
}

.badge.bg-primary   { background: var(--accent) !important; color: #fff; }
.badge.bg-success   { background: var(--success) !important; color: #000; }
.badge.bg-warning   { background: var(--warning) !important; color: #000; }
.badge.bg-danger    { background: var(--danger) !important; color: #fff; }
.badge.bg-info      { background: var(--info) !important; color: #000; }
.badge.bg-secondary { background: var(--bg-elevated) !important; color: var(--text-muted); border: 1px solid var(--border); }

/* =================================================================
   MODALS
   ================================================================= */
.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.modal-body {
    padding: 1.25rem;
    color: var(--text);
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
}

.modal-backdrop {
    background: rgba(0,0,0,0.6);
}

/* =================================================================
   DROPDOWNS
   ================================================================= */
.dropdown-menu {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    min-width: 180px;
}

.dropdown-item {
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    padding: 0.45rem 0.75rem;
    transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--bg-hover);
    color: var(--text);
}

.dropdown-divider {
    border-color: var(--border);
    margin: 0.3rem 0;
}

/* =================================================================
   PAGINATION
   ================================================================= */
.pagination .page-link {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    padding: 0.4rem 0.75rem;
}

.pagination .page-link:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text);
}

.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.pagination .page-item.disabled .page-link {
    background: var(--bg-surface);
    border-color: var(--border);
    color: var(--text-dim);
}

/* =================================================================
   PROGRESS BARS
   ================================================================= */
.progress {
    background: var(--bg-card);
    border-radius: 20px;
    height: 6px;
    overflow: hidden;
}

.progress-bar {
    background: var(--accent);
    border-radius: 20px;
    transition: width 0.4s ease;
}

.progress-bar.bg-success { background: var(--success); }
.progress-bar.bg-warning { background: var(--warning); }
.progress-bar.bg-danger  { background: var(--danger); }

/* =================================================================
   TOOLTIPS & POPOVERS
   ================================================================= */
.tooltip-inner {
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    box-shadow: var(--shadow);
}

.bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow::before,
.bs-tooltip-top .tooltip-arrow::before {
    border-top-color: var(--border-light);
}

/* =================================================================
   NOTIFICATION BADGE
   ================================================================= */
#notificationBadge {
    font-size: 0.6rem;
    min-width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: #fff;
    border-radius: 20px;
    font-weight: 700;
    padding: 0 4px;
}

/* =================================================================
   PAGE TITLE / HEADINGS
   ================================================================= */
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.2rem;
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-weight: 600;
}

hr {
    border-color: var(--border);
    opacity: 1;
}

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

/* =================================================================
   SCROLLBAR (global)
   ================================================================= */
:root {
    scrollbar-width: thin;
    scrollbar-color: var(--border) var(--bg-surface);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* =================================================================
   UTILITY CLASSES
   ================================================================= */
.text-accent   { color: var(--accent-hover) !important; }
.text-muted    { color: var(--text-muted) !important; }
.text-dim      { color: var(--text-dim) !important; }
.text-success  { color: var(--success) !important; }
.text-warning  { color: var(--warning) !important; }
.text-danger   { color: var(--danger) !important; }
.text-info     { color: var(--info) !important; }

.bg-surface    { background: var(--bg-surface) !important; }
.bg-card       { background: var(--bg-card) !important; }
.border-custom { border: 1px solid var(--border) !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* =================================================================
   RESPONSIVE — MOBILE
   ================================================================= */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

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

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .content-wrapper {
        padding: 1rem;
        padding-top: 4rem;
    }
}

@media (max-width: 767.98px) {
    .content-wrapper {
        padding: 0.75rem;
        padding-top: 4rem;
    }

    .page-title {
        font-size: 1.2rem;
    }
}

/* =================================================================
   SIDEBAR COLLAPSE
   ================================================================= */

.sidebar.collapsed {
    width: var(--sidebar-collapsed-w);
}

/* Adjust main content when sidebar is collapsed (desktop) */
@media (min-width: 992px) {
    .main-content.sidebar-collapsed {
        margin-left: var(--sidebar-collapsed-w);
    }
}

/* Hide text elements in collapsed mode */
.sidebar.collapsed .sidebar-brand > span,
.sidebar.collapsed .user-info,
.sidebar.collapsed .user-profile-arrow,
.sidebar.collapsed .sidebar-search,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .sidebar-branding {
    display: none !important;
}

/* Center remaining elements in collapsed mode */
.sidebar.collapsed .sidebar-header {
    padding: 1rem 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    width: 100%;
}

.sidebar.collapsed .user-profile-card {
    justify-content: center;
    padding: 0.5rem;
    margin: 0.5rem 0 0;
}

.sidebar.collapsed .user-avatar-wrap {
    margin: 0;
}

.sidebar.collapsed .sidebar-nav {
    overflow-x: visible;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.65rem 0;
    margin: 0 0.5rem;
    border-radius: var(--radius-sm);
    transform: none !important;
}
.sidebar.collapsed .nav-link:hover {
    padding-left: 0 !important;
    transform: none !important;
}

.sidebar.collapsed .nav-icon {
    width: auto;
    font-size: 1.1rem;
    margin: 0;
}

/* Sidebar tooltip (JS-managed floating el, see main.php) */
.sidebar-nav-tooltip {
    position: fixed;
    z-index: 9990;
    background: #0e1422;
    color: var(--text);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow);
    opacity: 0;
    transition: opacity 0.15s ease;
}
.sidebar-nav-tooltip.visible {
    opacity: 1;
}

/* Collapse toggle button */
.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), transform 0.3s ease;
    flex-shrink: 0;
    font-size: 0.75rem;
    position: absolute;
    right: -14px;
    top: 1.35rem;
    z-index: 1060;
    box-shadow: var(--shadow-sm);
}
.sidebar-collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.sidebar.collapsed .sidebar-collapse-btn {
    right: auto;
    position: static;
    margin-top: 0.5rem;
    transform: rotate(180deg);
}

/* Sidebar header row when expanded */
.sidebar-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

/* =================================================================
   LAYOUT SETTINGS FAB & PANEL
   ================================================================= */
.layout-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1055;
    width: 46px;
    height: 46px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,119,237,0.45);
    transition: transform 0.25s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.layout-fab:hover {
    background: var(--accent-hover);
    transform: scale(1.08) rotate(15deg);
    box-shadow: 0 6px 28px rgba(0,119,237,0.6);
}
.layout-fab.panel-open {
    transform: rotate(45deg);
    background: var(--danger);
    box-shadow: 0 4px 20px rgba(255,69,58,0.45);
}

/* Settings panel */
.layout-settings-panel {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    z-index: 1054;
    width: 300px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0;
    transform: translateY(12px) scale(0.96);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), opacity 0.18s ease;
}
.layout-settings-panel.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}
.lsp-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.1rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
.lsp-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}
.lsp-reset-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}
.lsp-reset-btn:hover {
    color: var(--text-muted);
    background: var(--bg-card);
}
.lsp-body {
    padding: 0.85rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.lsp-section-label {
    font-size: 0.67rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-dim);
    margin-bottom: 0.4rem;
}
.lsp-option-group {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.lsp-option-btn {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    text-align: center;
    transition: all var(--transition);
    white-space: nowrap;
}
.lsp-option-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border-light);
}
.lsp-option-btn.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent-hover);
    font-weight: 600;
}
.lsp-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.lsp-toggle-label {
    font-size: 0.82rem;
    color: var(--text-muted);
}
/* toggle switch */
.lsp-toggle {
    position: relative;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
}
.lsp-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.lsp-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.18s ease;
}
.lsp-toggle-track::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 14px;
    height: 14px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: transform 0.18s ease, background 0.18s ease;
}
.lsp-toggle input:checked + .lsp-toggle-track {
    background: var(--accent-dim);
    border-color: var(--accent);
}
.lsp-toggle input:checked + .lsp-toggle-track::before {
    transform: translateX(16px);
    background: var(--accent);
}
/* Color swatches */
.lsp-colors {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.lsp-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s ease, border-color 0.15s ease;
    outline: none;
}
.lsp-color-swatch:hover {
    transform: scale(1.15);
}
.lsp-color-swatch.active {
    border-color: #fff;
    transform: scale(1.1);
    box-shadow: 0 0 0 2px var(--border-light);
}
.lsp-footer {
    padding: 0.6rem 1.1rem;
    border-top: 1px solid var(--border);
    font-size: 0.7rem;
    color: var(--text-dim);
    text-align: center;
}

/* =================================================================
   DENSITY SETTINGS — applied via data-density on <html>
   ================================================================= */
html[data-density="compact"] .content-wrapper {
    padding: 1rem 1.25rem;
}
html[data-density="compact"] .card-body {
    padding: 0.85rem;
}
html[data-density="compact"] .card-header {
    padding: 0.65rem 0.85rem;
}
html[data-density="compact"] .table tbody td,
html[data-density="compact"] .table thead th {
    padding: 0.45rem 0.65rem;
}
html[data-density="spacious"] .content-wrapper {
    padding: 2.5rem 3rem;
}
html[data-density="spacious"] .card-body {
    padding: 1.75rem;
}
html[data-density="spacious"] .card-header {
    padding: 1.25rem 1.75rem;
}
html[data-density="spacious"] .table tbody td,
html[data-density="spacious"] .table thead th {
    padding: 0.9rem 1.1rem;
}

/* =================================================================
   FONT SIZE SETTINGS — applied via data-font-size on <html>
   ================================================================= */
html[data-font-size="sm"] body { font-size: 13px; }
html[data-font-size="md"] body { font-size: 14px; }
html[data-font-size="lg"] body { font-size: 16px; }

/* =================================================================
   DRAGGABLE WIDGETS
   ================================================================= */
.draggable-layout {
    display: flex;
    flex-wrap: wrap;
    gap: inherit;
}
.draggable-layout.dragging-active .draggable-widget {
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.draggable-widget {
    cursor: default;
}
.draggable-widget .drag-handle {
    cursor: grab;
    color: var(--text-dim);
    opacity: 0.5;
    user-select: none;
    transition: opacity 0.15s ease, color 0.15s ease;
}
.draggable-widget .drag-handle:hover {
    opacity: 1;
    color: var(--text-muted);
}
.draggable-widget.dragging {
    opacity: 0.45;
    cursor: grabbing;
}
.draggable-widget.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: 4px;
    border-radius: var(--radius);
}
.drag-handle-hint {
    font-size: 0.7rem;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}
.drag-handle-hint:hover {
    background: var(--bg-hover);
}

