/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --success-color: #4CAF50;
    --dark-color: #333;
    --light-color: #f4f4f4;
    --white-color: #fff;
    --border-color: #ddd;
    --shadow: 0 2px 5px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 10px rgba(0,0,0,0.15);
    --transition: all 0.3s ease;
    --border-radius: 8px;
    --max-width: 1200px;
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Optimisation: transition de chargement */
body {
    opacity: 0;
    transition: opacity 0.2s ease-in;
}

body.loaded {
    opacity: 1;
}

/* ============================================
   BADGES DE PERMISSION (uniformisés)
   ============================================ */
.user-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
}

.user-badge-user {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 2px 8px rgba(67, 233, 123, 0.3);
}

.user-badge-moderator {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

.user-badge-admin {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.user-badge-owner {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
    box-shadow: 0 2px 8px rgba(247, 151, 30, 0.3);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    overflow-y: scroll;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

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: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--secondary-color);
}

/* ============================================
   CONTAINER
   ============================================ */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ============================================
   HEADER
   ============================================ */
.site-header {
    background: var(--white-color);
    box-shadow: var(--shadow);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    padding: 0 20px;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
}

.logo a {
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: bold;
}

.main-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.main-nav a {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.main-nav a:hover {
    background: var(--light-color);
}

.user-info {
    color: var(--dark-color);
    font-size: 0.9rem;
}

/* Menu hamburger - caché par défaut */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.menu-toggle span {
    width: 25px;
    height: 3px;
    background: var(--dark-color);
    border-radius: 2px;
    transition: var(--transition);
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    background: var(--dark-color);
    color: var(--white-color);
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
}

/* ============================================
   FORMS
   ============================================ */
.form-container {
    max-width: 500px;
    margin: 2rem auto;
    background: var(--white-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
}

/* Supprimer les icônes par défaut des navigateurs */
.form-control::-ms-clear,
.form-control::-ms-reveal {
    display: none;
}

.form-control::-webkit-search-cancel-button,
.form-control::-webkit-search-decoration,
.form-control::-webkit-inner-spin-button,
.form-control::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-control:disabled {
    background-color: var(--light-color);
    cursor: not-allowed;
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

/* Styles pour les selects avec couleurs de rôles */
select.form-control {
    appearance: none;
}

/* Select dans les tableaux - style identique aux badges */
table td select.form-control {
    display: inline-block;
    width: auto;
    min-width: 0;
    padding: 4px 14px 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto;
}

/* Empêcher l'ouverture du dropdown natif */
table td select.form-control:focus {
    outline: none;
}

table td select.form-control option {
    display: none;
}

/* Custom dropdown pour les sélections de rôles */
.custom-select-wrapper {
    position: relative;
    display: inline-block;
}

.custom-select-dropdown {
    position: fixed;
    margin-top: 4px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px;
    z-index: 9999;
    min-width: auto;
    width: auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.custom-select-option {
    display: inline-block;
    padding: 4px 14px 4px 12px;
    margin: 2px 0;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    width: auto;
    white-space: nowrap;
}

.custom-select-option:hover {
    transform: translateY(-1px);
}

.custom-select-option.option-user {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 2px 8px rgba(67, 233, 123, 0.3);
}

.custom-select-option.option-user:hover {
    box-shadow: 0 3px 12px rgba(67, 233, 123, 0.5);
}

.custom-select-option.option-moderator {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

.custom-select-option.option-moderator:hover {
    box-shadow: 0 3px 12px rgba(79, 172, 254, 0.5);
}

.custom-select-option.option-admin {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

.custom-select-option.option-admin:hover {
    box-shadow: 0 3px 12px rgba(255, 107, 107, 0.5);
}

.custom-select-option.option-owner {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
    box-shadow: 0 2px 8px rgba(247, 151, 30, 0.3);
}

.custom-select-option.option-owner:hover {
    box-shadow: 0 3px 12px rgba(247, 151, 30, 0.5);
}



table td select.form-control.select-user {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    box-shadow: 0 2px 8px rgba(67, 233, 123, 0.3);
}

table td select.form-control.select-user:hover {
    box-shadow: 0 3px 12px rgba(67, 233, 123, 0.5);
    transform: translateY(-1px);
}

table td select.form-control.select-moderator {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

table td select.form-control.select-moderator:hover {
    box-shadow: 0 3px 12px rgba(79, 172, 254, 0.5);
    transform: translateY(-1px);
}

table td select.form-control.select-admin {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}

table td select.form-control.select-admin:hover {
    box-shadow: 0 3px 12px rgba(255, 107, 107, 0.5);
    transform: translateY(-1px);
}

table td select.form-control.select-owner {
    background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%);
    box-shadow: 0 2px 8px rgba(247, 151, 30, 0.3);
}

table td select.form-control.select-owner:hover {
    box-shadow: 0 3px 12px rgba(247, 151, 30, 0.5);
    transform: translateY(-1px);
}

table td select.form-control:focus {
    outline: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white-color);
}

.btn-primary:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: var(--white-color);
}

.btn-secondary:hover:not(:disabled) {
    background: #1976D2;
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white-color);
}

.btn-danger:hover:not(:disabled) {
    background: #da190b;
}

.btn-success {
    background: var(--success-color);
    color: var(--white-color);
}

.btn-success:hover:not(:disabled) {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-block {
    width: 100%;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid;
    transition: all 0.5s ease;
}

.alert.fade-out {
    opacity: 0;
    transform: translateY(-30px);
    margin-bottom: 0;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-color: var(--success-color);
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-color: var(--danger-color);
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-color: var(--warning-color);
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-color: var(--secondary-color);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--white-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-header {
    padding: 1rem 1.5rem;
    background: var(--light-color);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
    transition: all 0.5s ease;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--light-color);
    border-top: 1px solid var(--border-color);
}

/* ============================================
   TABLES
   ============================================ */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white-color);
}

table thead {
    background: var(--light-color);
}

table th,
table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

table th {
    font-weight: 600;
    color: var(--dark-color);
}

table tbody tr:hover {
    background: var(--light-color);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 12px;
    text-align: center;
}

.badge-success {
    background: var(--success-color);
    color: var(--white-color);
}

.badge-danger {
    background: var(--danger-color);
    color: var(--white-color);
}

.badge-warning {
    background: var(--warning-color);
    color: var(--white-color);
}

.badge-info {
    background: var(--secondary-color);
    color: var(--white-color);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
    border: 3px solid var(--light-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE MEDIA QUERIES
   ============================================ */

/* Tablettes */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    .header-content {
        flex-direction: row;
        gap: 1rem;
        justify-content: space-between;
        align-items: center;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .main-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        width: 100%;
        box-shadow: var(--shadow);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .main-nav.active {
        max-height: 500px;
    }
    
    .main-nav a {
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
        width: 100%;
        display: block;
    }
    
    .form-container {
        padding: 1.5rem;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    table {
        font-size: 0.9rem;
    }
    
    table th,
    table td {
        padding: 0.75rem;
    }
}

/* Mobiles */
@media (max-width: 480px) {
    html {
        font-size: 13px;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .main-nav {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-container {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.95rem;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    
    .card-body {
        padding: 1rem;
    }
    
    table {
        font-size: 0.85rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
    }
}

/* Mode sombre (optionnel) */
@media (prefers-color-scheme: dark) {
    :root {
        --dark-color: #f4f4f4;
        --light-color: #2d2d2d;
        --white-color: #1a1a1a;
        --border-color: #444;
    }
    
    body {
        background-color: #121212;
        color: var(--dark-color);
    }
    
    .site-header,
    .card,
    .form-container,
    table {
        background: var(--white-color);
    }
    
    .form-control {
        background: #2d2d2d;
        color: var(--dark-color);
        border-color: var(--border-color);
    }
}