/* ===== VARIABLES CSS ===== */
:root {
    /* Light mode */
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --secondary-color: #2ecc71;
    --secondary-dark: #27ae60;
    --accent-color: #e74c3c;
    --orange-btn: #e67e22;
    --orange-btn-hover: #d35400;
    
    --text-color: #333333;
    --text-light: #7f8c8d;
    --text-muted: #6c757d;
    --text-white: #ffffff;
    
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #2c3e50;
    --bg-header: #ffffff;
    --bg-footer: #2c3e50;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-success: #d4edda;
    --bg-danger: #f8d7da;
    --bg-warning: #fff3cd;
    --bg-info: #d1ecf1;
    
    --border-color: #e9ecef;
    --border-dark: #dee2e6;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --shadow-hover: 0 15px 35px rgba(52,152,219,0.2);
    
    /* Dark mode */
    --dark-bg-body: #1a1a2e;
    --dark-bg-card: #16213e;
    --dark-bg-sidebar: #0f3460;
    --dark-bg-header: #16213e;
    --dark-bg-footer: #0c2461;
    
    --dark-text: #ecf0f1;
    --dark-text-light: #bdc3c7;
    --dark-text-muted: #95a5a6;
    
    --dark-border: #34495e;
    --dark-border-light: #2c3e50;
    
    --dark-shadow: 0 10px 25px rgba(0,0,0,0.3);
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    --radius-circle: 50%;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Z-index */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal: 1040;
    --z-popover: 1050;
    --z-tooltip: 1060;
}

/* ===== DARK MODE ===== */
.dark-mode {
    --bg-body: var(--dark-bg-body);
    --bg-card: var(--dark-bg-card);
    --bg-header: var(--dark-bg-header);
    --bg-footer: var(--dark-bg-footer);
    --bg-sidebar: var(--dark-bg-sidebar);
    
    --text-color: var(--dark-text);
    --text-light: var(--dark-text-light);
    --text-muted: var(--dark-text-muted);
    
    --border-color: var(--dark-border);
    --border-dark: var(--dark-border-light);
    
    --shadow-md: var(--dark-shadow);
    --shadow-lg: var(--dark-shadow);
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-body);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color var(--transition-normal), 
                color var(--transition-normal);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* ===== CONTAINER ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

.container-fluid {
    width: 100%;
    padding: 0 var(--spacing-lg);
}

/* ===== TYPOGRAPHIE ===== */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: var(--spacing-md);
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-color);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ===== BOUTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.5;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-body);
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-dark));
    color: var(--text-white);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.2);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: var(--text-white);
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: var(--text-white);
}

.btn-info {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: var(--text-white);
}

.btn-light {
    background: var(--bg-card);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-dark {
    background: #2c3e50;
    color: white;
}

.btn-outline-primary {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: 0.875rem;
}

.btn-lg {
    padding: var(--spacing-md) var(--spacing-xl);
    font-size: 1.125rem;
}

.btn-block {
    width: 100%;
}

/* ===== CARTES ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform var(--transition-fast), 
                box-shadow var(--transition-fast);
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.02);
}

.card-body {
    padding: var(--spacing-lg);
}

.card-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background: rgba(0,0,0,0.02);
}

/* ===== FORMULAIRES ===== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: all var(--transition-fast);
    background: var(--bg-card);
    color: var(--text-color);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}

.form-control:disabled {
    background: var(--bg-body);
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--spacing-md) center;
    padding-right: var(--spacing-xl);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* ===== ALERTES ===== */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.alert-success {
    background: var(--bg-success);
    color: #155724;
    border-left: 4px solid #28a745;
}

.alert-danger {
    background: var(--bg-danger);
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.alert-warning {
    background: var(--bg-warning);
    color: #856404;
    border-left: 4px solid #ffc107;
}

.alert-info {
    background: var(--bg-info);
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-primary { background: var(--primary-color); color: white; }
.badge-success { background: var(--secondary-color); color: white; }
.badge-danger { background: #e74c3c; color: white; }
.badge-warning { background: #f39c12; color: white; }
.badge-info { background: #3498db; color: white; }

/* ===== PROGRESS BAR ===== */
.progress {
    width: 100%;
    height: 20px;
    background: var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: var(--spacing-md) 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: var(--spacing-sm);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

/* ===== TABLEAUX ===== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-lg);
}

.table th,
.table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 600;
    background: var(--bg-body);
}

.table-hover tbody tr:hover {
    background: var(--bg-body);
}

/* ===== GRID ===== */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(-1 * var(--spacing-md));
}

.col {
    flex: 1 0 0%;
    padding: 0 var(--spacing-md);
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--secondary-color); }
.text-danger { color: #e74c3c; }
.text-warning { color: #f39c12; }
.text-muted { color: var(--text-muted); }

.bg-primary { background: var(--primary-color); }
.bg-success { background: var(--secondary-color); }
.bg-danger { background: #e74c3c; }
.bg-warning { background: #f39c12; }
.bg-info { background: #3498db; }
.bg-light { background: var(--bg-body); }
.bg-dark { background: #2c3e50; color: white; }

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }
.mt-5 { margin-top: var(--spacing-xxl); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }
.mb-5 { margin-bottom: var(--spacing-xxl); }

.ml-1 { margin-left: var(--spacing-sm); }
.ml-2 { margin-left: var(--spacing-md); }
.ml-3 { margin-left: var(--spacing-lg); }

.mr-1 { margin-right: var(--spacing-sm); }
.mr-2 { margin-right: var(--spacing-md); }
.mr-3 { margin-right: var(--spacing-lg); }

.p-1 { padding: var(--spacing-sm); }
.p-2 { padding: var(--spacing-md); }
.p-3 { padding: var(--spacing-lg); }
.p-4 { padding: var(--spacing-xl); }
.p-5 { padding: var(--spacing-xxl); }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.justify-content-start { justify-content: flex-start; }
.justify-content-end { justify-content: flex-end; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-around { justify-content: space-around; }

.align-items-start { align-items: flex-start; }
.align-items-end { align-items: flex-end; }
.align-items-center { align-items: center; }
.align-items-baseline { align-items: baseline; }
.align-items-stretch { align-items: stretch; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.fade-in {
    animation: fadeIn var(--transition-normal);
}

.slide-in {
    animation: slideIn var(--transition-normal);
}

.spin {
    animation: spin 1s linear infinite;
}

/* ===== LOADER ===== */
.loader {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

.loader-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.loader-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* ===== DARK MODE TOGGLE ===== */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    background: var(--bg-card);
    border-radius: 50px;
    padding: 10px 15px;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.theme-toggle i {
    font-size: 18px;
    color: var(--primary-color);
}

.toggle-switch {
    width: 50px;
    height: 25px;
    background: var(--border-color);
    border-radius: 25px;
    position: relative;
    transition: background-color 0.3s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 21px;
    height: 21px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.dark-mode .toggle-switch {
    background: var(--primary-color);
}

.dark-mode .toggle-switch::after {
    transform: translateX(25px);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .container {
        padding: 0 var(--spacing-md);
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    .row {
        flex-direction: column;
    }
    
    .col {
        width: 100%;
        margin-bottom: var(--spacing-md);
    }
    
    .theme-toggle {
        top: 10px;
        right: 10px;
        padding: 8px 12px;
    }
    
    .table {
        display: block;
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .card {
        margin-bottom: var(--spacing-md);
    }
}

/* ===== IMPRESSION ===== */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Footer horizontal pour les pages internes */
.footer-horizontal {
    background-color: #1a252f !important;
    color: white !important;
    padding: 20px 0;
}

.footer-horizontal a {
    color: #ecf0f1 !important;
    transition: color 0.3s;
}

.footer-horizontal a:hover {
    color: #3498db !important;
    text-decoration: underline !important;
}

.footer-horizontal .separator {
    color: #6c757d;
    margin: 0 10px;
}

/* Version dark mode */
.dark-mode .footer-horizontal {
    background-color: #0c2461 !important;
}

/* ===== CORRECTION SÉLECTEURS DE DOMAINE ===== */
.domain-option {
    background: #ffffff !important;
    border: 2px solid #dee2e6 !important;
    color: #2c3e50 !important;
    font-weight: 500;
}

.domain-option i {
    color: #3498db !important;
    font-size: 1.3rem;
}

.domain-option span {
    color: #2c3e50 !important;
    font-size: 0.9rem;
    font-weight: 500;
}

.domain-option:hover {
    border-color: #3498db !important;
    background: #f1f9ff !important;
}

.domain-option.selected {
    background: #e3f2fd !important;
    border-color: #1976d2 !important;
}

.domain-option.selected i {
    color: #1976d2 !important;
}

.domain-option.selected span {
    color: #0d47a1 !important;
    font-weight: 600;
}

/* ===== MENU MOBILE AMÉLIORÉ ===== */
@media (max-width: 768px) {
    .navbar-collapse {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: var(--bg-card);
        padding: 20px;
        box-shadow: 0 10px 20px rgba(0,0,0,0.2);
        max-height: 80vh;
        overflow-y: auto;
        border-radius: 0 0 20px 20px;
        z-index: 999;
    }
    
    .navbar-nav {
        flex-direction: column !important;
        width: 100%;
    }
    
    .nav-item {
        width: 100%;
        margin: 5px 0;
    }
    
    .nav-link {
        padding: 12px 15px !important;
        border-radius: 10px;
    }
    
    .nav-link.btn-primary {
        margin: 10px 0 !important;
        text-align: center;
    }
    
    .credit-badge {
        margin-top: 10px;
        justify-content: center;
        width: 100%;
    }
}