/* Enterprise SaaS CRM - Master UI Design System with Ultra-Modern Glassmorphism & Toast Alerts */
@import url('/vendor/fonts/fonts.css');

:root {
    /* DARK MODE DEFAULT TOKENS */
    --bg-primary: #090d16;
    --bg-secondary: #0f172a;
    --bg-tertiary: #1e293b;
    --bg-glass: rgba(15, 23, 42, 0.8);
    
    --accent-blue: #3b82f6;
    --accent-indigo: #6366f1;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;

    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    --gradient-card: linear-gradient(145deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.9) 100%);
    --gradient-blue: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --gradient-emerald: linear-gradient(135deg, #059669 0%, #10b981 100%);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.5);

    --shadow-glass: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.3);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 9999px;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    /* FLUID AUTOMATIC TYPOGRAPHY TOKENS */
    --font-size-xs: clamp(0.68rem, 0.64rem + 0.2vw, 0.78rem);
    --font-size-sm: clamp(0.75rem, 0.7rem + 0.28vw, 0.875rem);
    --font-size-base: clamp(0.85rem, 0.78rem + 0.35vw, 1rem);
    --font-size-md: clamp(0.95rem, 0.88rem + 0.45vw, 1.15rem);
    --font-size-lg: clamp(1.1rem, 1.02rem + 0.6vw, 1.35rem);
    --font-size-xl: clamp(1.3rem, 1.18rem + 0.85vw, 1.75rem);
    --font-size-2xl: clamp(1.65rem, 1.45rem + 1.25vw, 2.25rem);
}

/* LIGHT THEME OVERRIDES */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-glass: rgba(255, 255, 255, 0.92);

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;

    --border-color: rgba(15, 23, 42, 0.08);
    --border-hover: rgba(99, 102, 241, 0.5);

    --shadow-glass: 0 10px 30px -5px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    background-color: var(--bg-primary);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.55;
}

h1, .page-title {
    font-family: var(--font-heading);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

h2 {
    font-family: var(--font-heading);
    font-size: var(--font-size-xl);
    font-weight: 600;
}

h3 {
    font-family: var(--font-heading);
    font-size: var(--font-size-lg);
    font-weight: 600;
}

h4 {
    font-family: var(--font-heading);
    font-size: var(--font-size-md);
    font-weight: 600;
}

h5, h6 {
    font-family: var(--font-heading);
    font-size: var(--font-size-sm);
    font-weight: 600;
}

/* Glassmorphism Panel Component */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glass);
    transition: border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-panel:hover {
    border-color: var(--border-hover);
}

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

/* Sidebar Styling */
.sidebar {
    width: 270px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.brand-logo {
    width: 42px;
    height: 42px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.35rem;
    color: white;
    box-shadow: var(--shadow-glow);
}

.brand-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
}

.tenant-badge {
    font-size: 0.68rem;
    padding: 0.2rem 0.65rem;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-indigo);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: var(--radius-full);
    text-transform: uppercase;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    list-style: none;
    flex: 1;
    overflow-y: auto;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all 0.25s ease;
}

.nav-item a:hover, .nav-item.active a {
    color: var(--accent-indigo);
    background: rgba(99, 102, 241, 0.12);
    border-left: 3px solid var(--accent-indigo);
}

.nav-section-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    margin: 1rem 0 0.3rem 0.75rem;
    font-weight: 700;
}

/* User Profile Sidebar Footer & Theme Toggle */
.user-profile-bar {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.theme-toggle-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    border-color: var(--accent-indigo);
    color: var(--accent-indigo);
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.btn-logout:hover {
    color: var(--accent-rose);
}

/* Module Command Tiles Styling */
.module-tile {
    padding: 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.module-tile:hover {
    transform: translateY(-4px);
    border-color: var(--accent-indigo);
    box-shadow: 0 12px 24px -10px rgba(99, 102, 241, 0.3);
}

.module-tile-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}


/* Main Content Area */
.main-content {
    margin-left: 270px;
    flex: 1;
    padding: 2rem 2.5rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.85rem;
    font-weight: 700;
}

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

/* Buttons System */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.68rem 1.3rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: var(--border-hover);
}

.btn-tester {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(16, 185, 129, 0.35);
}

.btn-tester:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(16, 185, 129, 0.5);
}

/* Stat KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    padding: 1.35rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-indigo);
}

.kpi-card.emerald::before { background: var(--accent-emerald); }
.kpi-card.amber::before { background: var(--accent-amber); }
.kpi-card.purple::before { background: var(--accent-purple); }

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 1.95rem;
    font-weight: 700;
    margin: 0.35rem 0;
    font-family: var(--font-heading);
}

.kpi-subtext {
    font-size: 0.75rem;
    color: var(--accent-emerald);
    font-weight: 600;
}

/* Data Table Component */
.table-container {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 1rem 1.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
}

.data-table td {
    padding: 1.1rem 1.25rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table tr:hover td {
    background: var(--bg-tertiary);
}

/* Kanban Deals Board */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.kanban-column {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    min-height: 500px;
}

.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.stage-title {
    font-size: 0.9rem;
    font-weight: 700;
}

.stage-total {
    font-size: 0.75rem;
    color: var(--accent-indigo);
    font-weight: 600;
}

.deal-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.85rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.deal-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.25);
    border-color: var(--border-hover);
}

.deal-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.deal-company {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.deal-amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-emerald);
}

/* Status Badges & Pills */
.badge {
    padding: 0.28rem 0.7rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-block;
}

.badge-new { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.badge-qualified { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge-urgent { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.badge-ai { background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(217, 70, 239, 0.15)); color: var(--accent-indigo); border: 1px solid rgba(217, 70, 239, 0.3); }

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    border: 1px solid var(--accent-emerald);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    animation: slideIn 0.3s ease forwards;
}

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

/* Modal Component */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-body {
    width: 90%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.75rem;
    position: relative;
    box-sizing: border-box;
    transition: max-width 0.3s ease;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal-body.modal-xl {
    max-width: 1120px;
    width: 95%;
}

.modal-body.modal-lg {
    max-width: 820px;
    width: 92%;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent-indigo);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Login Auth Box */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.15), transparent 40%),
                radial-gradient(circle at bottom left, rgba(217, 70, 239, 0.1), transparent 40%);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
}

/* ==========================================================================
   MOBILE TOP BAR & SIDEBAR OVERLAY
   ========================================================================== */
.top-mobile-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 95;
    width: 100%;
}

.mobile-nav-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mobile-brand-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: var(--font-size-md);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 99;
}

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

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (MOBILE, TABLET, DESKTOP, ULTRA-WIDE)
   ========================================================================== */

/* Mobile & Tablet (< 992px) */
@media screen and (max-width: 991px) {
    .top-mobile-bar {
        display: flex;
    }

    .app-container {
        flex-direction: column;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }

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

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem !important;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .page-header > div:last-child {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .page-header > div:last-child button {
        flex: 1 1 auto;
    }

    /* Grid Layout Responsiveness */
    .metrics-grid,
    .dashboard-tiles-grid,
    .kanban-board,
    .grid-2col,
    .grid-3col,
    .grid-4col {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Table Container Responsiveness */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .data-table {
        min-width: 650px;
    }

    /* Modal Responsiveness */
    .modal-body {
        width: 95vw !important;
        max-width: 100% !important;
        padding: 1.25rem !important;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: var(--radius-md);
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: calc(100vw - 2rem);
    }
}

/* Tablet Only (768px - 991px) */
@media screen and (min-width: 768px) and (max-width: 991px) {
    .metrics-grid,
    .dashboard-tiles-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .grid-2col, .grid-3col, .grid-4col {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Desktop & Up (992px - 1200px) */
@media screen and (min-width: 992px) and (max-width: 1200px) {
    .sidebar {
        width: 240px;
    }
    .main-content {
        margin-left: 240px;
        width: calc(100% - 240px);
    }
}

/* Ultra-Wide Screens (> 1600px) */
@media screen and (min-width: 1600px) {
    .main-content {
        max-width: 1750px;
        margin-right: auto;
    }
}
