:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --secondary-color: #3f37c9;
    --success-color: #4cc9f0;
    --danger-color: #f72585;
    --dark-bg: #0b090a;
    --dark-surface: #161a1d;
    --text-main: #f5f3f4;
    --text-muted: #b1a7a6;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(22, 26, 29, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-main);
    line-height: 1.6;
    background-image: radial-gradient(circle at top right, rgba(67, 97, 238, 0.15), transparent 40%),
                      radial-gradient(circle at bottom left, rgba(247, 37, 133, 0.1), transparent 40%);
    min-height: 100vh;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--dark-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.brand {
    padding: 1.5rem 1.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.5px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.brand span {
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    gap: 0.5rem;
    flex: 1;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    transition: all 0.3s;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-links a:hover, .nav-links a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-links a.logout {
    margin-top: auto;
    color: #ff758f;
}

.nav-links a.logout:hover {
    background: rgba(247, 37, 133, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.page-header p {
    color: var(--text-muted);
}

/* Layouts */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    align-items: start;
}

/* Cards (Glassmorphism) */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.card h2 {
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
}

.styled-form input[type="text"],
.styled-form input[type="number"],
.styled-form input[type="date"],
.styled-form select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.styled-form input:focus,
.styled-form select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.3s;
    text-align: center;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
}

.btn-danger {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.btn-danger:hover {
    background: rgba(247, 37, 133, 0.1);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.styled-table {
    width: 100%;
    border-collapse: collapse;
}

.styled-table th,
.styled-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.styled-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.styled-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.mono {
    font-family: monospace;
    letter-spacing: 1px;
    color: #fff;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert.success {
    background: rgba(76, 201, 240, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.alert.error {
    background: rgba(247, 37, 133, 0.1);
    border: 1px solid var(--danger-color);
    color: #ff758f;
}

/* Print CSS */
@media print {
    body {
        background: none;
        color: black;
    }
    
    .navbar, .page-header, .btn, .sidebar, .no-print {
        display: none !important;
    }
    
    .app-wrapper {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
    }

    .print-container {
        position: relative;
        width: 100%;
        height: 100vh;
        page-break-after: always;
    }

    /* L'image de fond doit être cachée à l'impression, mais visible à l'écran pour l'alignement */
    .print-bg {
        display: none !important;
    }

    .print-absolute {
        position: absolute;
        font-family: "Courier New", Courier, monospace;
        font-size: 14px;
        font-weight: bold;
        color: black;
    }
}

/* Affichage écran du gabarit d'impression (pour ajustement) */
@media screen {
    .print-preview-mode {
        background-color: #ccc;
    }
    .print-container {
        position: relative;
        width: 210mm; /* Largeur A4 / Traite - à ajuster selon traite.jpg */
        height: 100mm; /* Hauteur Traite estimée - à ajuster */
        background-color: white;
        margin: 20px auto;
        box-shadow: 0 0 10px rgba(0,0,0,0.5);
        overflow: hidden;
    }
    .print-bg {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
        z-index: 1;
        opacity: 0.5; /* Pour voir le texte par-dessus */
    }
    .print-absolute {
        position: absolute;
        z-index: 2;
        font-family: "Courier New", Courier, monospace;
        font-size: 14px;
        font-weight: bold;
        color: red; /* Rouge à l'écran pour bien voir, noir à l'impression */
    }
}

/* Responsive */
@media screen and (max-width: 768px) {
    .app-wrapper {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0 1rem;
    }
    
    .brand {
        border-bottom: none;
        padding: 1rem 0;
    }
    
    .nav-links {
        display: none; /* Consider adding a hamburger menu for full mobile support */
    }
    
    .main-content {
        margin-left: 0;
    }
}
