/* Imports */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600;700&display=swap');

/* Police GNMS - MADE Outer Sans */
@font-face {
    font-family: 'MADE Outer Sans';
    src: url('../fonts/MADEOuterSans-Regular.woff2') format('woff2'),
         url('../fonts/MADEOuterSans-Regular.woff') format('woff'),
         url('../fonts/MADEOuterSans-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'MADE Outer Sans';
    src: url('../fonts/MADEOuterSans-Medium.woff2') format('woff2'),
         url('../fonts/MADEOuterSans-Medium.woff') format('woff'),
         url('../fonts/MADEOuterSans-Medium.otf') format('opentype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'MADE Outer Sans';
    src: url('../fonts/MADEOuterSans-Bold.woff2') format('woff2'),
         url('../fonts/MADEOuterSans-Bold.woff') format('woff'),
         url('../fonts/MADEOuterSans-Bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-bg-dark);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: var(--color-gold);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-gold-light);
}

img {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input, textarea, select {
    font-family: inherit;
}

/* Typographie */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }

.text-gold { color: var(--color-gold); }
.text-primary { color: var(--color-primary); }
.text-secondary-gnms { color: var(--color-secondary); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }

/* Layout */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* Grille */
.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-primary {
    background: var(--gradient-gnms);
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--color-primary-light) 0%, var(--color-secondary-light) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(91, 45, 145, 0.35);
}

.btn-secondary {
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-gold);
}

.btn-outline {
    background: transparent;
    color: var(--color-gold);
    border: 1px solid var(--color-gold);
}

.btn-outline:hover {
    background: var(--color-gold);
    color: #000;
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    transition: all 0.15s ease;
}

.btn-icon:hover {
    background: var(--color-bg-card-hover);
    color: var(--color-gold);
    border-color: var(--color-gold);
}

/* Cards */
.card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    transition: all var(--transition-base);
    overflow: visible;
    min-width: 0;
}

.card:hover {
    border-color: var(--color-border-light);
    box-shadow: var(--shadow-lg);
}

.card-premium {
    background: linear-gradient(145deg, var(--color-bg-card) 0%, #1f1f1f 100%);
    border: 1px solid var(--color-gold);
    box-shadow: var(--shadow-glow);
}

/* Inputs */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
}

.form-input {
    width: 100%;
    padding: var(--space-4);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: var(--text-base);
    transition: all var(--transition-fast);
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(91, 45, 145, 0.1);
}

.form-input::placeholder {
    color: var(--color-text-muted);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-primary {
    background: rgba(91, 45, 145, 0.1);
    color: var(--color-primary);
}

.badge-gold {
    background: rgba(91, 45, 145, 0.1);
    color: var(--color-primary);
}

/* Tables */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    max-width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--color-bg-card);
    padding: var(--space-4);
    text-align: left;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--color-border);
}

.table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--text-sm);
}

.table tr:hover td {
    background: var(--color-bg-card-hover);
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tr:last-child td {
    border-bottom: none;
}

/* Progress Bar */
.progress-bar {
    height: 6px;
    background: var(--color-bg-input);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-gnms);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* Utilitaires */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.text-center { text-align: center; }
.text-right { text-align: right; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.flex-wrap { flex-wrap: wrap; }
.gap-3 { gap: var(--space-3); }
.items-end { align-items: flex-end; }

.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.btn-gold { background: var(--color-gold); color: #000; border: none; }
.btn-gold:hover { background: #d4af37; }

/* Inline forms */
.inline-form { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-group { margin: 0; }
.form-group-grow { flex: 1; min-width: 120px; }
.form-group-fixed { width: 120px; }
.form-group-sm { width: 80px; }

/* ==========================================
   RESPONSIVE MOBILE
   ========================================== */

/* Boutons responsive */
@media (max-width: 640px) {
    .btn { padding: var(--space-2) var(--space-4); font-size: 13px; }
    .btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-sm); }
    .btn svg { width: 16px; height: 16px; }
    .btn-icon { width: 34px; height: 34px; }
    .btn-icon svg { width: 14px; height: 14px; }
}

/* Cards responsive */
@media (max-width: 640px) {
    .card { padding: var(--space-4); border-radius: var(--radius-lg); }
}

/* Tables responsive — handled by responsive.css */

/* Formulaires responsive */
@media (max-width: 640px) {
    .form-group { margin-bottom: var(--space-4); }
    .form-label { font-size: 12px; margin-bottom: var(--space-1); }
    .form-input { padding: var(--space-3); font-size: 14px; }
}

/* Modals responsive */
@media (max-width: 640px) {
    .modal-overlay { padding: var(--space-2); align-items: flex-end; }
    .modal-card { max-width: 100%; max-height: 85vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
    .modal-header { padding: var(--space-4); }
    .modal-header h3 { font-size: var(--text-base); }
    .modal-body { padding: var(--space-4); }
    .modal-footer { padding: var(--space-3) var(--space-4); }
    .modal-footer .btn { flex: 1; }
}

/* Page header responsive */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-6);
    gap: var(--space-4);
    flex-wrap: wrap;
}
.page-header h2 { margin-bottom: var(--space-1); }

.modules-nav { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

@media (max-width: 640px) {
    .page-header { flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
    .page-header > div { width: 100%; min-width: 0; }
    .page-header p { font-size: 12px; }
    .page-header > .flex { width: 100%; flex-wrap: wrap; gap: var(--space-2); }
    .page-header > .flex > .btn { font-size: 12px; padding: var(--space-2) var(--space-3); }
    .modules-nav { overflow-x: auto; flex-wrap: nowrap !important; -webkit-overflow-scrolling: touch; padding-bottom: var(--space-1); width: 100%; }
    .modules-nav .btn { flex-shrink: 0; font-size: 12px; padding: var(--space-2) var(--space-3); white-space: nowrap; }
}

/* Table actions responsive */
.table-actions { display: flex; gap: var(--space-2); align-items: center; }

@media (max-width: 640px) {
    .table-actions { gap: var(--space-1); }
    .table-actions .btn-icon { width: 30px; height: 30px; }
}

/* Form rows responsive */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-row-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-3); }

@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; gap: var(--space-3); }
    .form-row-5 { grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
}

@media (max-width: 380px) {
    .form-row-5 { grid-template-columns: repeat(2, 1fr); }
}

/* Inline forms responsive */
@media (max-width: 640px) {
    .inline-form { flex-direction: column; align-items: stretch; }
    .inline-form .form-group,
    .inline-form .form-group-grow,
    .inline-form .form-group-fixed,
    .inline-form .form-group-sm { width: 100%; flex: none; min-width: 0; }
    .inline-form .btn { width: 100%; justify-content: center; }
}

/* Badges responsive */
@media (max-width: 640px) {
    .badge { font-size: 10px; padding: 2px var(--space-2); }
}

/* Empty state responsive */
.empty-state { text-align: center; padding: var(--space-8); }
@media (max-width: 640px) {
    .empty-state { padding: var(--space-6); }
    .empty-state svg { width: 40px; height: 40px; }
    .empty-state p { font-size: 13px; }
}

/* Utilitaires responsive */
@media (max-width: 640px) {
    h1 { font-size: var(--text-xl); }
    h2 { font-size: var(--text-lg); }
    h3 { font-size: var(--text-base); }
    h4 { font-size: var(--text-sm); }
    .mb-6 { margin-bottom: var(--space-4); }
    .mt-6 { margin-top: var(--space-4); }
    .gap-6 { gap: var(--space-4); }
    p { word-wrap: break-word; overflow-wrap: break-word; }
    .page-header .flex { flex-wrap: wrap; }
    .page-header .flex.gap-2 { gap: var(--space-2); }
}

/* Flash messages */
.flash-message {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    margin: var(--space-3) var(--space-6);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: 500;
    animation: flashSlideIn 0.4s ease;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.flash-success {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.flash-error {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    margin-left: auto;
    opacity: 0.6;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    transition: opacity 0.15s;
}

.flash-close:hover { opacity: 1; }

.flash-message.flash-hide {
    opacity: 0;
    transform: translateY(-10px);
}

@keyframes flashSlideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease both;
}

.animate-slide-in {
    animation: slideIn 0.4s ease both;
}

/* ===== Print / PDF Export ===== */
@media print {
    /* Hide non-content elements */
    .sidebar,
    .topbar,
    .mobile-nav,
    .bottom-nav,
    .modules-nav,
    .flash-message,
    .btn,
    button[type="submit"],
    button[type="button"],
    .btn-icon,
    .modal-overlay,
    .lightbox,
    .no-print,
    form .btn,
    .page-header .modules-nav {
        display: none !important;
    }

    /* Reset layout */
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11pt;
        line-height: 1.4;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .page-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    /* Show input values as text in print */
    input[type="number"],
    input[type="text"],
    select {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        font-weight: 600;
    }

    .page-header {
        margin-bottom: 12pt;
        border-bottom: 2pt solid #5B2D91;
        padding-bottom: 8pt;
    }

    .page-header h2 {
        color: #5B2D91 !important;
        font-size: 18pt;
    }

    .page-header .text-muted {
        color: #555 !important;
        font-size: 10pt;
    }

    /* Print header with branding */
    .print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16pt;
        padding-bottom: 8pt;
        border-bottom: 1pt solid #ccc;
    }

    .print-header-brand {
        font-size: 14pt;
        font-weight: 700;
        color: #5B2D91;
    }

    .print-header-date {
        font-size: 9pt;
        color: #888;
    }

    /* Cards */
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        background: #fff !important;
        break-inside: avoid;
        margin-bottom: 10pt;
        page-break-inside: avoid;
    }

    /* Tables */
    .table-container {
        overflow: visible !important;
    }

    .table {
        width: 100% !important;
        border-collapse: collapse;
        font-size: 9pt;
    }

    .table th {
        background: #f3f0f7 !important;
        color: #333 !important;
        border: 1px solid #ccc;
        padding: 4pt 6pt;
        font-weight: 600;
    }

    .table td {
        border: 1px solid #ddd;
        padding: 4pt 6pt;
        color: #222 !important;
    }

    .table tbody tr:nth-child(even) {
        background: #fafafa !important;
    }

    /* Summary cards - keep layout */
    .fin-summary,
    .suivi-summary {
        display: flex !important;
        gap: 8pt;
        margin-bottom: 12pt;
    }

    .fin-stat-card,
    .suivi-card {
        border: 1px solid #ddd !important;
        background: #fff !important;
        padding: 8pt !important;
        flex: 1;
    }

    /* Progress bars */
    .progress-bar {
        border: 1px solid #ccc;
        background: #eee !important;
    }

    .progress-fill {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Status badges */
    .text-success { color: #16a34a !important; }
    .text-danger { color: #dc2626 !important; }
    .text-muted { color: #777 !important; }

    /* Gantt checks - show as symbols */
    .gantt-check { display: none; }
    .gantt-check:checked + .print-check-mark,
    .gantt-check + .print-check-mark { display: none; }

    /* Planning badges */
    .planning-badge {
        border: 1px solid #999 !important;
        padding: 2pt 6pt;
        font-size: 8pt;
    }

    /* Hide edit rows */
    .edit-row { display: none !important; }

    /* Page breaks */
    h3 { page-break-after: avoid; }
    .table { page-break-inside: auto; }
    .table tr { page-break-inside: avoid; }

    /* Animations off */
    * {
        animation: none !important;
        transition: none !important;
    }

    /* Print footer */
    @page {
        margin: 1.5cm;
        size: A4 landscape;
    }
}
