/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-sidebar: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-hover-bg: #1e293b;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #0ea5e9;
    
    --critical: #ef4444;
    --high: #f97316;
    --medium: #eab308;
    --low: #3b82f6;
    
    --status-open: #3b82f6;
    --status-progress: #8b5cf6;
    --status-pending: #f59e0b;
    --status-user: #06b6d4;
    --status-vendor: #ec4899;
    --status-resolved: #10b981;
    --status-closed: #64748b;

    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --transition-speed: 0.25s;
    --sidebar-width: 260px;
}

[data-theme="dark"] {
    --bg-primary: #090d16;
    --bg-secondary: #0f172a;
    --bg-sidebar: #080c14;
    --sidebar-text: #64748b;
    --sidebar-text-active: #f8fafc;
    --sidebar-hover-bg: #111827;
    --bg-card: #151f32;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #223049;
    
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --accent: #38bdf8;

    --card-shadow: 0 4px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

/* Dark Mode Helper Overrides */
[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary,
[data-theme="dark"] .text-body-secondary {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-dark-emphasis {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-secondary-subtle {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .list-group-item {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .list-group-item-action {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .list-group-item-action:hover {
    background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .table-custom th {
    background-color: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
    border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .table-custom td {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .table-custom tr:hover td {
    background-color: var(--bg-secondary) !important;
}

/* Dark Mode Form & Header Specific Overrides */
[data-theme="dark"] .card-custom-header, 
[data-theme="dark"] .card-custom-header span, 
[data-theme="dark"] .card-custom-header i {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .form-label {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    color: var(--text-primary) !important;
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted) !important;
    opacity: 0.65 !important;
}

[data-theme="dark"] .form-control[readonly],
[data-theme="dark"] .form-control[disabled] {
    background-color: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] h1, 
[data-theme="dark"] h2, 
[data-theme="dark"] h3, 
[data-theme="dark"] h4, 
[data-theme="dark"] h5, 
[data-theme="dark"] h6 {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-light {
    background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .border-primary-subtle {
    border-color: var(--border-color) !important;
}

/* Global Styles */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
    overflow-x: hidden;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

a {
    text-decoration: none;
    transition: color var(--transition-speed);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Main Layout Grid */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    transition: margin-left var(--transition-speed) ease;
    background-color: var(--bg-primary);
}

/* Sidebar Styling */
.sidebar-container {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    color: var(--sidebar-text);
    flex-shrink: 0;
    transition: transform var(--transition-speed) ease;
    z-index: 1000;
    border-right: 1px solid var(--border-color);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--sidebar-text-active);
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 0.5px;
}

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

.sidebar-menu {
    list-style: none;
    padding: 1rem 0.75rem;
    margin: 0;
}

.sidebar-item {
    margin-bottom: 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--sidebar-text);
    font-weight: 500;
    transition: all var(--transition-speed) ease;
}

.sidebar-link i {
    font-size: 1.15rem;
    margin-right: 0.85rem;
    width: 20px;
    text-align: center;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-text-active);
}

.sidebar-link.active {
    background-color: var(--primary);
    color: var(--sidebar-text-active);
}

.sidebar-badge {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
}

/* Glassmorphism & Cards */
.card-stat {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color var(--transition-speed);
    position: relative;
    overflow: hidden;
}

.card-stat:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px -5px rgb(0 0 0 / 0.1);
    border-color: var(--primary);
}

.card-stat::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background-color: var(--primary);
}

.card-stat.critical::after { background-color: var(--critical); }
.card-stat.warning::after { background-color: var(--high); }
.card-stat.info::after { background-color: var(--accent); }
.card-stat.success::after { background-color: var(--status-resolved); }

.card-custom {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.card-custom-header {
    padding: 1.25rem 1.5rem;
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-custom-body {
    padding: 1.5rem;
}

/* Tables Styling */
.table-custom {
    color: var(--text-primary) !important;
}

.table-custom th {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.table-custom td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

.table-custom tr:hover td {
    background-color: var(--bg-secondary);
}

/* Priority & Status Badges */
.badge-priority {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
}

.badge-priority.critical { background-color: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-priority.high { background-color: rgba(249, 115, 22, 0.15); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.3); }
.badge-priority.medium { background-color: rgba(234, 179, 8, 0.15); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.3); }
.badge-priority.low { background-color: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }

.badge-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    display: inline-flex;
    align-items: center;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 0.4rem;
    display: inline-block;
}

.badge-status.open { background-color: rgba(59, 130, 246, 0.1); color: var(--status-open); }
.badge-status.open::before { background-color: var(--status-open); }

.badge-status.progress { background-color: rgba(139, 92, 246, 0.1); color: var(--status-progress); }
.badge-status.progress::before { background-color: var(--status-progress); }

.badge-status.pending { background-color: rgba(245, 158, 11, 0.1); color: var(--status-pending); }
.badge-status.pending::before { background-color: var(--status-pending); }

.badge-status.user { background-color: rgba(6, 182, 212, 0.1); color: var(--status-user); }
.badge-status.user::before { background-color: var(--status-user); }

.badge-status.vendor { background-color: rgba(236, 72, 153, 0.1); color: var(--status-vendor); }
.badge-status.vendor::before { background-color: var(--status-vendor); }

.badge-status.resolved { background-color: rgba(16, 185, 129, 0.1); color: var(--status-resolved); }
.badge-status.resolved::before { background-color: var(--status-resolved); }

.badge-status.closed { background-color: rgba(100, 116, 139, 0.1); color: var(--status-closed); }
.badge-status.closed::before { background-color: var(--status-closed); }

/* Timeline design */
.timeline {
    position: relative;
    padding-left: 2rem;
    list-style: none;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -29px;
    top: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--bg-card);
    border: 3px solid var(--primary);
    z-index: 1;
}

.timeline-item.status-change::before {
    border-color: var(--status-progress);
}

.timeline-item.task-created::before {
    border-color: var(--status-resolved);
}

.timeline-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

.timeline-content {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-top: 0.25rem;
    border-left: 3px solid var(--primary);
}

/* Forms Styling */
.form-control, .form-select {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.5rem;
    padding: 0.6rem 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-control[readonly], .form-control[disabled] {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
}

/* Theme Switch Button */
.theme-switch-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.25s ease;
}

.theme-switch-btn:hover {
    color: var(--sidebar-text-active);
    background-color: var(--sidebar-hover-bg);
}

/* Glassmorphic Login */
.login-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    color: #f8fafc;
}

.login-card .form-control {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.login-card .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

/* Quick Floating Action Button */
.fab-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
    z-index: 999;
    transition: all var(--transition-speed) ease;
}

.fab-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.1) rotate(90deg);
    color: white;
}

/* Mobile Responsiveness Rules */
@media (max-width: 991.98px) {
    .app-wrapper {
        flex-direction: column;
    }
    
    .sidebar-container {
        width: 100%;
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    .sidebar-container.show {
        transform: translateX(0);
    }
    
    .main-content {
        padding: 1rem;
        margin-top: 56px;
    }
    
    .mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background-color: var(--bg-sidebar);
        border-bottom: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        padding: 0 1rem;
        z-index: 999;
        justify-content: space-between;
    }
    
    .mobile-header .brand {
        color: var(--sidebar-text-active);
        font-weight: 700;
        font-size: 1.1rem;
    }
    
    .mobile-toggle {
        background: transparent;
        border: none;
        color: var(--sidebar-text-active);
        font-size: 1.5rem;
        cursor: pointer;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }

    .fab-btn {
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

/* Universal Import Center / Wizard Styles & Contrast Fixes */
.step-indicator {
    color: var(--text-muted) !important;
    border-color: var(--border-color) !important;
    background-color: var(--bg-card) !important;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.25s ease;
}

.step-indicator.active {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
    background-color: rgba(37, 99, 235, 0.08) !important;
    font-weight: 600;
}

[data-theme="dark"] .step-indicator.active {
    color: #60a5fa !important;
    border-color: #3b82f6 !important;
    background-color: rgba(59, 130, 246, 0.15) !important;
}

/* Overwrite Bootstrap subtle utility classes in dark mode */
[data-theme="dark"] .bg-primary-subtle {
    background-color: rgba(59, 130, 246, 0.15) !important;
    color: #93c5fd !important;
}

/* Improve contrast of outline secondary buttons in dark theme */
[data-theme="dark"] .btn-outline-secondary {
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}

[data-theme="dark"] .btn-outline-secondary:hover {
    color: #ffffff !important;
    background-color: #1e293b !important;
    border-color: #475569 !important;
}

/* Custom Dropzone Style */
.dropzone-custom {
    border-style: dashed !important;
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    transition: all 0.25s ease;
}

.dropzone-custom:hover,
.dropzone-custom.dragover {
    background-color: rgba(37, 99, 235, 0.05) !important;
    border-color: var(--primary) !important;
}

[data-theme="dark"] .dropzone-custom:hover,
[data-theme="dark"] .dropzone-custom.dragover {
    background-color: rgba(59, 130, 246, 0.1) !important;
    border-color: var(--accent) !important;
}

/* Fixed Sidebar Behavior on Desktop (min-width: 992px) */
@media (min-width: 992px) {
    .sidebar-container {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        width: var(--sidebar-width);
        overflow-y: auto;
        z-index: 1000;
    }
    
    .main-content {
        margin-left: var(--sidebar-width) !important;
        width: calc(100% - var(--sidebar-width)) !important;
    }
}

/* Sidebar Text-Muted Contrast Correction (as sidebar is always dark) */
.sidebar-container .text-muted {
    color: var(--sidebar-text) !important;
    opacity: 0.65;
}

/* Overwrite bg-dark badges in dark mode for better contrast */
[data-theme="dark"] .badge.bg-dark {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
    border: 1px solid #334155 !important;
}



