/* ==========================================================================
   GEMDesk - Modern B2B SaaS Design System
   Colors, Typography, Layout, Cards, Buttons, Form Controls & Utilities
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Color Palette */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-glow: rgba(79, 70, 229, 0.15);
    
    --slate-950: #090d16;
    --slate-900: #0f172a;
    --slate-850: #131d35;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
    --white: #ffffff;

    /* Semantic Status Accents */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    
    --info: #0ea5e9;
    --info-bg: #f0f9ff;
    --info-border: #bae6fd;

    /* Spacing & Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Elevation Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Layout Dimensions */
    --sidebar-width: 260px;
    --topbar-height: 70px;
}

/* Reset & Base Setup */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f6f8fb;
    color: var(--slate-800);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
}

/* App Shell Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--slate-900);
    color: var(--slate-300);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    border-right: 1px solid var(--slate-800);
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--slate-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.app-content {
    padding: 28px 32px 60px;
    flex: 1;
}

/* Sidebar Styling */
.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--slate-800);
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.brand-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.brand-text span {
    font-size: 0.7rem;
    color: var(--slate-400);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sidebar-company-card {
    margin: 16px 14px 10px;
    padding: 12px 14px;
    background: var(--slate-850);
    border: 1px solid var(--slate-800);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
}

.company-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--slate-700);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.company-meta {
    overflow: hidden;
}

.company-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.company-sub {
    font-size: 0.72rem;
    color: var(--slate-400);
}

.sidebar-nav {
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-section-header {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--slate-500);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 14px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    color: var(--slate-300);
    font-weight: 500;
    font-size: 0.88rem;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background-color: var(--slate-800);
    color: var(--white);
}

.nav-item.active {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.nav-label-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

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

.nav-badge {
    background: var(--slate-800);
    color: var(--slate-300);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.nav-item.active .nav-badge {
    background: rgba(255, 255, 255, 0.25);
    color: var(--white);
}

/* User Card in Sidebar Bottom */
.sidebar-footer {
    padding: 14px;
    border-top: 1px solid var(--slate-800);
    background: var(--slate-950);
}

.user-snippet {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.user-avatar-initials {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

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

.user-role-badge {
    display: inline-block;
    font-size: 0.68rem;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.15);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.logout-btn {
    color: var(--slate-400);
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.logout-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

/* Topbar Controls */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.command-search-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    color: var(--slate-500);
    font-size: 0.86rem;
    cursor: pointer;
    width: 320px;
    transition: all 0.15s ease;
}

.command-search-btn:hover {
    border-color: var(--slate-300);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.kbd-shortcut {
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    background: var(--white);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    color: var(--slate-600);
}

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

.today-date-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--slate-600);
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.3;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}

.btn-outline {
    background: var(--white);
    border-color: var(--slate-300);
    color: var(--slate-700);
}

.btn-outline:hover {
    background: var(--slate-50);
    border-color: var(--slate-400);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-md);
    color: var(--slate-600);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-icon:hover {
    background: var(--slate-100);
    color: var(--slate-900);
}

/* Card Container */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--slate-200);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--slate-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--slate-900);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 24px;
}

/* Data Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
}

.table th {
    background: var(--slate-50);
    color: var(--slate-500);
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 12px 18px;
    border-bottom: 1px solid var(--slate-200);
    white-space: nowrap;
}

.table td {
    padding: 14px 18px;
    font-size: 0.86rem;
    color: var(--slate-700);
    border-bottom: 1px solid var(--slate-100);
    vertical-align: middle;
}

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

/* Badges & Status Pills */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
}

.badge-margin-healthy {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge-margin-watch {
    background: #fef9c3;
    color: #a16207;
    border: 1px solid #fef08a;
}

.badge-margin-warning {
    background: #ffedd5;
    color: #c2410c;
    border: 1px solid #fed7aa;
}

.badge-margin-critical {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Form Styling */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--slate-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid var(--slate-300);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--slate-800);
    transition: all 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Flash Toast Notifications */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--slate-200);
    animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

@keyframes modalPop {
    from { transform: scale(0.96); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.mobile-open {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
    }
}
