/* =====================================================
   Suivi BET - Modern & Professional UI System
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette - High-Tech Pro */
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.2);
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --warning: #f59e0b;
    --danger: #ef4444;

    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;

    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    /* Grid Functional Colors */
    --cell-complete: #dcfce7;
    --cell-progress: #fef9c3;
    --cell-started: #f1f5f9;

    /* Layout & Effects */
    --sidebar-width: 260px;
    --radius-xl: 1.25rem;
    --radius-lg: 1rem;
    --shadow-pro: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.02);
    --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    /* Transitions */
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Layout */
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* Sidebar Layout Architecture */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 2.5rem;
    min-width: 0;
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* Prevent flex box issues */
}

/* Sidebar Hidden State (Desktop) */
.sidebar-hidden .sidebar {
    transform: translateX(-100%);
}

.sidebar-hidden .main-content {
    margin-left: 0;
}

.btn-show-sidebar {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 32px;
    height: 60px;
    border-radius: 0 12px 12px 0;
    display: none !important;
    /* Managed by JS/class */
    align-items: center;
    justify-content: center;
    z-index: 1050;
    padding: 0;
    background: var(--sidebar-bg);
    border: none;
    color: white;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
    transition: var(--transition-fast);
}

.sidebar-hidden .btn-show-sidebar {
    display: flex !important;
}

.btn-show-sidebar:hover {
    width: 40px;
}

.sidebar-desktop-toggle {
    opacity: 0.5;
    transition: var(--transition-fast);
}

.sidebar-desktop-toggle:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Brand Area */
.sidebar-brand {
    padding: 0 2rem;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    background: var(--primary);
    color: white;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--primary-glow);
}

.brand-name {
    font-weight: 800;
    color: white;
    letter-spacing: -0.5px;
    font-size: 1.2rem;
}

/* Navigation Links */
.sidebar-nav {
    flex: 1;
    padding: 0 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.nav-item:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 16px var(--primary-glow);
}

.nav-item i {
    font-size: 1.2rem;
}

/* Grid Editor: The Instrument Panel */
.control-center-card {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-pro);
    border: none;
}

.grid-wrapper-pro {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float);
    overflow: auto;
    max-height: calc(100vh - 260px);
    border: 1px solid var(--border-color);
    transition: var(--transition-smooth);
}

/* Header Hidden State */
.header-hidden.container-fluid {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

.header-hidden .project-header-row {
    display: none !important;
}

.header-hidden .grid-wrapper-pro {
    max-height: calc(100vh - 60px);
    border-radius: 0;
    margin: 0 -0.5rem;
}

.btn-toggle-header {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    cursor: pointer;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.btn-toggle-header:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-show-header {
    position: fixed;
    top: 20px;
    right: 40px;
    z-index: 1050;
    display: none;
    animation: fadeIn 0.3s ease;
}

.header-hidden .btn-show-header {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.grid-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.grid-table thead th {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(4px);
    padding: 1.25rem 0.5rem;
    border-bottom: 2px solid var(--border-color);
    font-weight: 800;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.pk-header {
    min-width: 60px;
    text-align: center;
    border-left: 1px solid rgba(0, 0, 0, 0.03);
}

.pk-header::after {
    content: '';
    display: block;
    height: 8px;
    width: 1px;
    background: var(--text-muted);
    margin: 0.5rem auto 0;
    opacity: 0.5;
}

/* Sticky Columns */
.sticky-col {
    position: sticky !important;
    background-color: var(--bg-surface) !important;
    z-index: 110 !important;
    box-shadow: 2px 0 5px -2px rgba(0, 0, 0, 0.1);
    border-right: 1px solid var(--border-color);
    margin: 0 !important;
}

.sticky-col.col-phase {
    left: 0;
    z-index: 111 !important;
    /* Higher than task col to overlap border if needed */
}

/* Ensure sticky header stays on top of sticky columns */
.grid-table thead th.sticky-col {
    z-index: 120 !important;
}

/* Cell Visuals: Tactile & High Density */
.grid-table .cell {
    padding: 1px;
    border: 0.5px solid rgba(226, 232, 240, 0.7) !important;
    min-width: 65px;
    height: 40px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cell-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background-color: transparent;
    transition: background-color 0.2s ease;
}

/* Date-based dynamic coloring */
.cell[style*="--date-bg"] .cell-inner {
    background-color: var(--date-bg) !important;
    color: #0f172a !important;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.03), inset 0 0 0 1px rgba(0, 0, 0, 0.05) !important;
}

.grid-table .cell:hover {
    z-index: 110;
    transform: scale(1.1);
    box-shadow: var(--shadow-float);
}

/* High-Visibility Selection */
.cell.selected {
    z-index: 120;
    position: relative;
}

.cell.selected .cell-inner {
    background-color: var(--primary) !important;
    color: white !important;
    box-shadow: 0 0 15px var(--primary-glow), inset 0 0 0 2px rgba(255, 255, 255, 0.4) !important;
    transform: scale(1.05);
}

.grid-table .cell:hover .cell-inner {
    background-color: #fff !important;
    color: var(--primary) !important;
    box-shadow: inset 0 0 0 1px var(--primary);
}

/* Tactile States */
.cell-complete .cell-inner {
    background-color: var(--cell-complete);
    color: #065f46;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.02);
}

.cell-progress .cell-inner {
    background-color: var(--cell-progress);
    color: #92400e;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.02);
}

.cell-started .cell-inner {
    background-color: var(--cell-started);
    color: #475569;
}

/* Phase Rows: Data Grouping */
.phase-row td {
    background: #f8fafc !important;
    padding: 0.75rem 1.5rem !important;
    border-top: 1px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
}

.phase-title {
    font-weight: 800 !important;
    color: #0f172a;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.phase-badge {
    background: var(--primary);
    color: white;
    padding: 0.1rem 0.6rem;
    border-radius: 6px;
    font-size: 0.65rem;
    box-shadow: 0 4px 10px var(--primary-glow);
}

/* Dashboard Cards (Project List) */
.project-card {
    background: white;
    border-radius: var(--radius-xl);
    border: none;
    box-shadow: var(--shadow-pro);
    padding: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-float);
}

.data-table-pro {
    margin: 0;
}

.data-table-pro thead {
    background-color: #f8fafc;
}

.data-table-pro th {
    padding: 1.25rem 1rem !important;
    font-size: 0.7rem !important;
    font-weight: 800 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.data-table-pro td {
    padding: 1.25rem 1rem !important;
}

/* UI Particles */
.badge-pro {
    padding: 0.5rem 1rem;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.75rem;
    border: 1px solid transparent;
}

.btn-pro {
    padding: 0.6rem 1.5rem;
    border-radius: 12px;
    font-weight: 700;
    transition: all 0.2s ease;
}

.btn-pro-primary {
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 8px 16px var(--primary-glow);
}

.btn-pro-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 20px var(--primary-glow);
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.main-content>* {
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}