/* ==========================================================================
   DASHBOARD STYLES - OPTIMISÉ MOBILE/TABLETTE
   ========================================================================== */

/* Variables CSS pour la cohérence */
:root {
    --primary-color: #89a265;
    --secondary-color: #d4e1c2;
    --accent-color: #d4e1c2;
    --background-color: #f9f9f9;
    --text-color: #333;
    --border-color: #ddd;
    --error-color: #e74c3c;
    --success-color: #27ae60;
}

/* ==========================================================================
   LAYOUT DU DASHBOARD
   ========================================================================== */

.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--background-color);
    min-height: calc(100vh - 200px);
}

.dashboard-wrapper {
    display: flex;
    gap: 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    overflow: hidden;
}

/* ==========================================================================
   NAVIGATION DU DASHBOARD
   ========================================================================== */

.dashboard-nav {
    min-width: 250px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 0;
}

.dashboard-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dashboard-nav li {
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.dashboard-nav a {
    display: block;
    padding: 20px 25px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 16px;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.dashboard-nav a:hover {
    background: rgba(255,255,255,0.1);
    border-left-color: var(--accent-color);
}

.dashboard-nav a.active {
    background: rgba(255,255,255,0.2);
    border-left-color: var(--accent-color);
    font-weight: 600;
}

/* ==========================================================================
   CONTENU DU DASHBOARD
   ========================================================================== */

.dashboard-content {
    flex: 1;
    padding: 30px;
}

.dashboard-section {
    display: none;
}

.dashboard-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dashboard-section h2 {
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 28px;
    font-weight: 600;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
}

/* ==========================================================================
   FORMULAIRES
   ========================================================================== */

#account-form {
    max-width: 600px;
}

#account-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 14px;
}

#account-form input {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

#account-form input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.address-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.address-row .field {
    position: relative;
}

.address-row .field label {
    margin-bottom: 5px;
}

.address-row .field input {
    margin-bottom: 0;
}

/* Autocomplete suggestions */
.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
    list-style: none;
    padding: 0;
    margin: 0;
}

.autocomplete-list li {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
}

.autocomplete-list li:hover {
    background: var(--accent-color);
}

/* Boutons */
button[type="submit"], .checkout-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button[type="submit"]:hover, .checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 69, 19, 0.3);
}

/* ==========================================================================
   TABLEAUX
   ========================================================================== */

.data-display {
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

table th {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table td {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

table tr:hover {
    background: #f8f9fa;
}

table tr:last-child td {
    border-bottom: none;
}

/* Boutons dans les tableaux */
.details-btn, .btn-danger, table button {
    padding: 8px 16px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.details-btn {
    background: var(--accent-color);
    color: var(--text-color);
}

.details-btn:hover {
    background: #c0d1a8;
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Total du panier */
#cart-total {
    text-align: right;
    margin: 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.checkout-btn {
    display: block;
    margin: 20px auto 0;
    max-width: 300px;
}

/* ==========================================================================
   SECTION PAIEMENT
   ========================================================================== */

#payment label {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#payment label:hover {
    border-color: var(--accent-color);
    background: #f8f9fa;
}

#payment input[type="radio"] {
    width: auto;
    margin: 0;
}

#card-form {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin: 20px 0;
}

#card-form input {
    margin-bottom: 15px;
}

#card-form input.invalid {
    border-color: var(--error-color);
    background: #ffebee;
}

#card-form input.valid {
    border-color: var(--success-color);
    background: #e8f5e8;
}

/* ==========================================================================
   RESPONSIVE DESIGN - TABLETTE
   ========================================================================== */

@media (max-width: 1024px) {
    .dashboard-container {
        padding: 15px;
    }
    
    .dashboard-wrapper {
        gap: 20px;
    }
    
    .dashboard-nav {
        min-width: 200px;
    }
    
    .dashboard-content {
        padding: 20px;
    }
    
    .address-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .address-row .field:last-child {
        grid-column: 1 / -1;
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN - MOBILE
   ========================================================================== */

@media (max-width: 768px) {
    .dashboard-container {
        padding: 10px;
        margin-top: 10px;
    }
    
    .dashboard-wrapper {
        flex-direction: column;
        gap: 0;
        border-radius: 8px;
    }
    
    /* Navigation mobile */
    .dashboard-nav {
        min-width: auto;
        background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
        border-radius: 8px 8px 0 0;
    }
    
    .dashboard-nav ul {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .dashboard-nav li {
        flex-shrink: 0;
        border-bottom: none;
        border-right: 1px solid rgba(255,255,255,0.1);
    }
    
    .dashboard-nav li:last-child {
        border-right: none;
    }
    
    .dashboard-nav a {
        padding: 15px 20px;
        white-space: nowrap;
        font-size: 14px;
        border-left: none;
        border-bottom: 4px solid transparent;
    }
    
    .dashboard-nav a:hover, 
    .dashboard-nav a.active {
        background: rgba(255,255,255,0.2);
        border-left: none;
        border-bottom-color: var(--accent-color);
    }
    
    /* Contenu mobile */
    .dashboard-content {
        padding: 20px 15px;
    }
    
    .dashboard-section h2 {
        font-size: 24px;
        margin-bottom: 20px;
    }
    
    /* Formulaires mobile */
    .address-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    #account-form input {
        font-size: 16px; /* Évite le zoom sur iOS */
        padding: 15px;
    }
    
    /* Tableaux mobile */
    .data-display {
        margin: 15px -15px;
        padding: 0 15px;
    }
    
    table {
        font-size: 12px;
        min-width: 600px; /* Force le scroll horizontal */
    }
    
    table th, table td {
        padding: 10px 8px;
        white-space: nowrap;
    }
    
    table th {
        font-size: 11px;
    }
    
    /* Boutons mobile */
    button[type="submit"], .checkout-btn {
        width: 100%;
        padding: 18px;
        font-size: 16px;
        margin-top: 20px;
    }
    
    .details-btn, .btn-danger, table button {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    /* Section paiement mobile */
    #card-form {
        padding: 20px 15px;
        margin: 15px 0;
    }
    
    #card-form input {
        padding: 15px;
        font-size: 16px;
    }
    
    /* Autocomplete mobile */
    .autocomplete-list {
        font-size: 14px;
    }
    
    .autocomplete-list li {
        padding: 12px 15px;
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN - TRÈS PETIT MOBILE
   ========================================================================== */

@media (max-width: 480px) {
    .dashboard-container {
        padding: 5px;
    }
    
    .dashboard-content {
        padding: 15px 10px;
    }
    
    .dashboard-section h2 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .dashboard-nav a {
        padding: 12px 15px;
        font-size: 13px;
    }
    
    table {
        min-width: 500px;
    }
    
    table th, table td {
        padding: 8px 6px;
    }
    
    #card-form {
        padding: 15px 10px;
    }
    
    button[type="submit"], .checkout-btn {
        padding: 16px;
        font-size: 15px;
    }
}

/* ==========================================================================
   AMÉLIORATIONS UX MOBILE
   ========================================================================== */

/* Éviter le zoom sur les inputs iOS */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"] {
        font-size: 16px !important;
    }
}

/* Améliorer la zone de toucher */
@media (max-width: 768px) {
    .dashboard-nav a,
    button,
    .details-btn,
    .btn-danger {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .autocomplete-list li {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* Indicateur de scroll pour la navigation mobile */
@media (max-width: 768px) {
    .dashboard-nav::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 20px;
        background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1));
        pointer-events: none;
    }
    
    .dashboard-nav {
        position: relative;
    }
}

/* Animation de chargement pour mobile */
@media (max-width: 768px) {
    .dashboard-section {
        transition: opacity 0.2s ease;
    }
    
    .dashboard-section.active {
        animation: mobileSlideIn 0.3s ease;
    }
    
    @keyframes mobileSlideIn {
        from { 
            opacity: 0; 
            transform: translateX(20px); 
        }
        to { 
            opacity: 1; 
            transform: translateX(0); 
        }
    }
}