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

/* CSS Variables & Design Tokens */
:root {
    /* Primary & Accent Colors */
    --primary-color: #4F46E5;
    /* Indigo 600 */
    --primary-hover: #4338CA;
    /* Indigo 700 */
    --secondary-color: #10B981;
    /* Emerald 500 */
    --accent-color: #F59E0B;
    /* Amber 500 */
    --danger-color: #EF4444;
    /* Red 500 */
    --success-color: #10B981;
    /* Emerald 500 */
    --info-color: #3173df;
    /* Blue 500 */

    /* Typography */
    --font-sans: 'Inter', sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* Typography - Fluid Scalable System using clamp() */
    --fs-xs: clamp(0.7rem, 0.5vw + 0.6rem, 0.75rem);
    --fs-sm: clamp(0.8rem, 0.5vw + 0.7rem, 0.875rem);
    --fs-base: clamp(0.875rem, 0.5vw + 0.75rem, 1rem);
    --fs-lg: clamp(1rem, 0.8vw + 0.8rem, 1.125rem);
    --fs-xl: clamp(1.125rem, 1vw + 0.9rem, 1.5rem);
    --fs-2xl: clamp(1.5rem, 2vw + 1.25rem, 2.25rem);
    --fs-3xl: clamp(2rem, 3vw + 1.5rem, 3rem);

    /* Spacing & Layout */
    --sidebar-width: clamp(240px, 15vw, 280px);
    --header-height: clamp(60px, 8vh, 70px);
    --main-padding: clamp(1rem, 3vw, 2.5rem);
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-soft: 0 5px 15px rgba(0, 0, 0, 0.05);

    /* Light Mode Colors (Default) */
    --bg-body: #F3F4F6;
    --bg-card: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-input: #F9FAFB;

    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    --border-color: #E5E7EB;
    --border-focus: var(--primary-color);

    /* Bootstrap Utility Sync */
    --bs-primary: var(--primary-color);
    --bs-primary-rgb: 79, 70, 229;
    --bs-success: var(--success-color);
    --bs-danger: var(--danger-color);
    --bs-warning: var(--accent-color);
    --bs-info: var(--info-color);
}

[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-body: #111827;
    /* Gray 900 */
    --bg-card: #1F2937;
    /* Gray 800 */
    --bg-sidebar: #1F2937;
    /* Gray 800 */
    --bg-input: #374151;
    /* Gray 700 */

    --text-primary: #F9FAFB;
    /* Gray 50 */
    --text-secondary: #D1D5DB;
    /* Gray 300 */
    --text-muted: #9CA3AF;
    /* Gray 400 */

    --border-color: #374151;
    /* Gray 700 */
    --border-focus: var(--primary-color);
    /* Indigo 500 */

    --shadow-soft: 0 5px 15px rgba(0, 0, 0, 0.5);
}

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

[data-theme="dark"] .form-label,
[data-theme="dark"] .form-check-label,
[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);
}

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

[data-theme="dark"] .card-header {
    background-color: transparent;
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .modal-content {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .modal-footer {
    border-top-color: var(--border-color);
}

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

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

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

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

[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-focus) !important;
}

/* Base Reset & Global Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    background-color: var(--bg-body);
    color: var(--text-primary);
    margin: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

h1,
.h1 {
    font-size: var(--fs-3xl);
}

h2,
.h2 {
    font-size: var(--fs-2xl);
}

h3,
.h3 {
    font-size: var(--fs-xl);
}

h4,
.h4 {
    font-size: var(--fs-lg);
}

h5,
.h5 {
    font-size: var(--fs-base);
}

h6,
.h6 {
    font-size: var(--fs-sm);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
    margin-top: 0;
}

/* Fluid Media */
img,
video,
canvas,
svg,
iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Utilities */
.text-primary {
    color: var(--primary-color) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.w-100 {
    width: 100%;
}

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-body);
}

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

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 var(--main-padding);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}

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

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background-color: rgba(79, 70, 229, 0.05);
    /* Very light primary */
    color: var(--primary-color);
}

.nav-link.active {
    background-color: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.nav-link i {
    font-size: 1.25rem;
    margin-right: 0.75rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Main Content Wrapper */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevent flex child overflow */
}

/* Topbar */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--main-padding);
    position: sticky;
    top: 0;
    z-index: 40;
}

.header-title h2 {
    font-size: 1.5rem;
    margin-bottom: 0;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Content Area */
.app-content {
    padding: var(--main-padding);
    flex: 1;
}

/* Components Override - Bootstrap Fixes */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
}

.card:hover {
    box-shadow: var(--shadow-soft);
    /* transform: translateY(-2px); Check if too aggressive later */
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.form-control,
.form-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--border-radius-md);
    padding: 0.75rem 1rem;
    width: 100%;
    min-height: 44px;
    /* Better for touch */
}

.form-control:focus {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-focus);
    outline: none;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Profile Dropdown & Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--bg-input);
    color: var(--text-primary);
}

/* Tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
}

.table> :not(caption)>*>* {
    padding: 1rem 1rem;
    background-color: var(--bs-table-bg);
    border-bottom-width: 1px;
    box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg);
}

.table-hover>tbody>tr:hover>* {
    --bs-table-accent-bg: rgba(79, 70, 229, 0.05);
    color: var(--text-primary);
}

/* Dark Mode Bootstrap Overrides */
[data-theme="dark"] .bg-light {
    background-color: #374151 !important;
    /* Gray 700 */
    color: #F9FAFB !important;
}

[data-theme="dark"] .bg-white {
    background-color: #1F2937 !important;
    /* Gray 800 */
    color: #F9FAFB !important;
}

[data-theme="dark"] .text-dark {
    color: #F9FAFB !important;
}

[data-theme="dark"] .text-muted {
    color: #9CA3AF !important;
}

[data-theme="dark"] .border {
    border-color: #374151 !important;
}

.modal-xl {
    max-width: 80% !important;
}

/* Mobile Responsive Enhancements */
@media (max-width: 768px) {
    :root {
        --header-height: 60px;
    }

    .app-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        width: 280px;
    }

    .app-sidebar.show {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
    }

    .app-main {
        margin-left: 0 !important;
    }

    .app-header {
        padding: 0 1rem;
    }

    .header-title h2 {
        font-size: 1.2rem;
    }

    .app-content {
        padding: 0.75rem;
    }

    /* Modal Adjustments */
    .modal-dialog.modal-xl {
        max-width: 95% !important;
        margin: 0.5rem auto;
    }

    .modal-content {
        border-radius: var(--border-radius-lg);
    }

    .card {
        padding: 1.25rem 1rem;
        margin-bottom: 1rem;
        border-radius: var(--border-radius-md);
    }

    /* Responsive Tables */
    .table-responsive {
        border: 0;
        margin-bottom: 0;
    }

    .table thead {
        display: none;
        /* Consider stacking for very small screens */
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-md);
        background: var(--bg-card);
    }

    .table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid var(--border-color);
        min-height: 2.5rem;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 45%;
        text-align: left;
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.75rem;
        text-transform: uppercase;
    }

    .table td:last-child {
        border-bottom: 0;
    }

    .table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 45%;
        text-align: left;
        font-weight: 600;
        color: var(--text-secondary);
    }

    /* Hide text in header actions for more space on extra small screens */
    @media (max-width: 480px) {
        .header-actions span {
            display: none;
        }
    }

    /* Sidebar Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 45;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

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

/* Kanban & Modal Custom Themes */
.kanban-column {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
}

.kanban-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .kanban-column {
    background-color: #0f172a !important;
    /* Slate 900 */
    border-color: #1e293b !important;
    /* Slate 800 */
}

[data-theme="dark"] .kanban-card {
    background-color: #1e293b !important;
    /* Slate 800 */
    border-color: #334155 !important;
    /* Slate 700 */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .modal-body {
    background-color: #1e293b !important;
}

[data-theme="dark"] .modal-label-primary {
    color: #818cf8 !important;
    /* Indigo 400 */
}

[data-theme="dark"] .text-primary-light {
    color: #a5b4fc !important;
    /* Indigo 300 */
}

[data-theme="dark"] .shadow-sm {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .shadow {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.7), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
}

/* Responsive Table Fixes */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Modern Toast Notifications */
.modern-toast {
    background: var(--bg-card) !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color) !important;
    overflow: hidden;
    animation: toastSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .modern-toast {
    background: rgba(30, 41, 59, 0.8) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5) !important;
}

.toast-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.smaller {
    font-size: 0.75rem;
}

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

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

[data-theme="dark"] .shadow-lg {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.8), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

[data-theme="dark"] .kanban-card h6,
[data-theme="dark"] .kanban-card .text-dark {
    color: #f8fafc !important;
}

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

/* Multi-row (Wrapping) Tabs Utility */
.custom-tabs.nav-tabs {
    display: flex !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    white-space: normal !important;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    gap: 2px;
    /* Small gap between tabs */
    row-gap: 8px;
    /* Vertical gap between rows */
}

.custom-tabs.nav-tabs::-webkit-scrollbar {
    display: none !important;
}

.custom-tabs .nav-item {
    flex: 0 0 auto !important;
}

.custom-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.8rem 1.25rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: -1px;
}

.custom-tabs .nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: transparent;
}

/* Premium Card Hover Effects */
.card-hover-bright:hover {
    border-color: var(--primary-color) !important;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.1) !important;
    transform: translateY(-2px);
}