/* ============================================
   Intranet Handisport 74 - Styles principaux
   ============================================ */

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e3a55;
    --secondary: #e67e22;
    --secondary-light: #f39c12;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --light: #f8f9fa;
    --dark: #2c3e50;
    --sidebar-width: 260px;
    --header-height: 64px;
}

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

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ============ LAYOUT ============ */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}

.sidebar-brand small {
    font-size: 0.75rem;
    opacity: 0.7;
    display: block;
    margin-top: 4px;
}

.sidebar-brand img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-bottom: 10px;
    border: 2px solid rgba(255,255,255,0.3);
}

.sidebar-nav {
    flex: 1;
    padding: 15px 0;
}

.sidebar-nav .nav-section {
    padding: 10px 20px 5px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.5;
    font-weight: 600;
}

.sidebar-nav .nav-item {
    list-style: none;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-left-color: var(--secondary);
}

.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: var(--secondary);
    font-weight: 600;
}

.sidebar-nav .nav-link i {
    width: 24px;
    margin-right: 12px;
    font-size: 1.1rem;
    text-align: center;
}

.sidebar-nav .nav-link .badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.75rem;
    opacity: 0.5;
    text-align: center;
}

/* ============ MAIN CONTENT ============ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============ HEADER ============ */

.top-header {
    background: #fff;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 999;
}

.top-header h1 {
    font-size: 1.3rem;
    color: var(--dark);
    font-weight: 600;
}

.btn-sidebar-toggle {
    display: none;
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--dark);
    cursor: pointer;
    padding: 5px;
}

/* ============ PAGE CONTENT ============ */

.page-content {
    flex: 1;
    padding: 25px 30px;
}

/* ============ CARDS ============ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-card .stat-icon.blue { background: #e8f4fd; color: var(--info); }
.stat-card .stat-icon.green { background: #e8f8f0; color: var(--success); }
.stat-card .stat-icon.orange { background: #fef5e7; color: var(--warning); }
.stat-card .stat-icon.red { background: #fdedec; color: var(--danger); }

.stat-card .stat-info h3 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
}

.stat-card .stat-info p {
    font-size: 0.85rem;
    color: #7f8c8d;
    margin-top: 4px;
}

/* ============ DATA CARD ============ */

.data-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    margin-bottom: 25px;
}

.data-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.data-card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark);
}

.data-card-body {
    padding: 24px;
}

/* ============ TABLE ============ */

.table-responsive {
    overflow-x: auto;
}

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

.data-table th {
    background: #f8f9fa;
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7f8c8d;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
    vertical-align: middle;
}

.data-table tr:hover {
    background-color: #f8f9fa;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* ============ BADGES ============ */

.badge-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-disponible { background: #e8f8f0; color: #27ae60; }
.badge-indisponible { background: #fdedec; color: #e74c3c; }
.badge-en_cours { background: #e8f4fd; color: #2980b9; }
.badge-en_retard { background: #fdedec; color: #e74c3c; }
.badge-retourne { background: #e8f8f0; color: #27ae60; }
.badge-annule { background: #f0f0f0; color: #7f8c8d; }

.badge-etat-neuf { background: #e8f8f0; color: #27ae60; }
.badge-etat-bon { background: #e8f4fd; color: #2980b9; }
.badge-etat-usage { background: #fef5e7; color: #e67e22; }
.badge-etat-abime { background: #fdedec; color: #e74c3c; }
.badge-etat-hors_service { background: #f0f0f0; color: #7f8c8d; }

/* ============ BUTTONS ============ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn i { font-size: 1rem; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }

.btn-secondary { background: #ecf0f1; color: var(--dark); }
.btn-secondary:hover { background: #d5dbdb; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d68910; }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.btn-group {
    display: flex;
    gap: 6px;
}

/* ============ FORMS ============ */

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    color: #333;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}

.form-control::placeholder {
    color: #bbb;
}

select.form-control {
    appearance: auto;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid #eee;
    margin-top: 10px;
}

/* ============ MODAL ============ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-dialog {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #e0e0e0;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============ FILTERS BAR ============ */

.filters-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filters-bar .form-control {
    width: auto;
    min-width: 160px;
}

.search-input {
    position: relative;
}

.search-input input {
    padding-left: 36px;
}

.search-input i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #bbb;
}

/* ============ EMPTY STATE ============ */

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: #999;
}

.empty-state i {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 1rem;
    margin-bottom: 20px;
}

/* ============ TOAST NOTIFICATIONS ============ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #fff;
    border-radius: 10px;
    padding: 14px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

.toast i {
    font-size: 1.2rem;
}

.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ============ PROCHAINS RETOURS ============ */

.retour-list {
    list-style: none;
    padding: 0;
}

.retour-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.retour-item:last-child {
    border-bottom: none;
}

.retour-info {
    flex: 1;
}

.retour-info .materiel-name {
    font-weight: 600;
    color: var(--dark);
    font-size: 0.9rem;
}

.retour-info .emprunteur-name {
    font-size: 0.8rem;
    color: #999;
}

.retour-date {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
}

.retour-date.overdue {
    background: #fdedec;
    color: var(--danger);
}

.retour-date.soon {
    background: #fef5e7;
    color: var(--warning);
}

.retour-date.ok {
    background: #e8f8f0;
    color: var(--success);
}

/* ============ RESPONSIVE ============ */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .btn-sidebar-toggle {
        display: block;
    }

    .page-content {
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }

    .stat-card .stat-info h3 {
        font-size: 1.4rem;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-bar .form-control {
        width: 100%;
    }

    .data-card-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
    
    .modal-dialog {
        width: 95%;
        margin: 10px;
    }

    .top-header {
        padding: 0 15px;
    }

    .top-header h1 {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .data-table th, .data-table td {
        padding: 10px 8px;
        font-size: 0.8rem;
    }
}
