/**
 * Styles personnalisés — Parc Matériel Musée Granet
 * Charte graphique identique à la Médiathèque Granet
 */

/* ========================================
   Variables CSS
   ======================================== */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --sidebar-width: 256px;
    --header-height: 120px;
}

/* ========================================
   Base
   ======================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ========================================
   Layout
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 40;
    transition: transform 0.3s ease;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 24px;
    max-width: 1400px;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
}

.header.with-search {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 24px;
    align-items: center;
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    top: 132px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
    max-width: 400px;
}

.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info    { background: var(--primary); }

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

@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ========================================
   Loader
   ======================================== */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Materiel Cards
   ======================================== */
.materiel-card {
    background: var(--bg-white);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    overflow: hidden;
}

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

.materiel-card-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.materiel-card-body {
    padding: 16px;
}

.materiel-card-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.3;
}

.materiel-card-number {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
    margin-top: 2px;
}

.materiel-card-meta {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

/* ========================================
   Status Badges
   ======================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
}

.status-available    { background: #dcfce7; color: #166534; }
.status-on_display   { background: #dbeafe; color: #1e40af; }
.status-in_repair    { background: #fef9c3; color: #854d0e; }
.status-under_warranty { background: #f3e8ff; color: #6b21a8; }
.status-out_of_order { background: #fee2e2; color: #991b1b; }

/* ========================================
   Condition Badges
   ======================================== */
.condition-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.condition-new  { background: #ecfdf5; color: #059669; }
.condition-good { background: #f0fdf4; color: #16a34a; }
.condition-fair { background: #fffbeb; color: #d97706; }
.condition-poor { background: #fef2f2; color: #dc2626; }

/* ========================================
   Alert Badges (maintenance, garantie)
   ======================================== */
.alert-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    background: #fef2f2;
    color: #dc2626;
}

.alert-badge-warning {
    background: #fffbeb;
    color: #d97706;
}

/* ========================================
   Stats Cards
   ======================================== */
.stat-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

/* ========================================
   Modal
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

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

.modal {
    background: var(--bg-white);
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.2s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ========================================
   Forms
   ======================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
    margin-left: 2px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg-white);
    color: var(--text-primary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input.error {
    border-color: var(--danger);
}

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

.form-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

.form-hint {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 4px;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-light);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   Search Bar
   ======================================== */
.search-bar {
    position: relative;
    max-width: 600px;
    width: 100%;
    justify-self: center;
}

.search-bar input {
    width: 100%;
    padding: 14px 18px 14px 48px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    background: var(--bg-light);
    transition: all 0.2s ease;
    font-family: inherit;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-bar-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* ========================================
   Filters / Sidebar nav
   ======================================== */
.filter-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--bg-light);
    color: var(--text-primary);
}

.nav-item.active {
    background: #eef2ff;
    color: var(--primary);
}

.nav-item .nav-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-light);
    color: var(--text-secondary);
    padding: 1px 7px;
    border-radius: 9999px;
}

.nav-item.active .nav-count {
    background: #e0e7ff;
    color: var(--primary);
}

/* ========================================
   Table
   ======================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-light);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.data-table tbody tr:hover {
    background: var(--bg-light);
    cursor: pointer;
}

/* ========================================
   Pagination
   ======================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
}

.pagination-btn {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-family: inherit;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-light);
}

.pagination-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-secondary);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    opacity: 0.4;
    color: var(--text-secondary);
}

/* ========================================
   Spec Table (fiche matériel)
   ======================================== */
.spec-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 16px;
}

.spec-row:last-child {
    border-bottom: none;
}

.spec-label {
    flex: 0 0 180px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.spec-value {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
}

/* ========================================
   Alert Box (dashboard)
   ======================================== */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
}

.alert-item.danger  { background: #fef2f2; }
.alert-item.warning { background: #fffbeb; }
.alert-item.info    { background: #eff6ff; }

/* ========================================
   View toggle (grille / liste)
   ======================================== */
.view-toggle {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.view-toggle-btn {
    padding: 7px 12px;
    background: var(--bg-white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.view-toggle-btn.active {
    background: var(--primary);
    color: white;
}

.view-toggle-btn:hover:not(.active) {
    background: var(--bg-light);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1024px) {
    .main-content {
        margin-left: 0;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 35;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0 16px;
    }

    .main-content {
        padding: 16px;
    }

    .modal {
        width: 95%;
        margin: 16px;
    }

    .spec-label {
        flex: 0 0 120px;
    }
}

/* ========================================
   Utilities
   ======================================== */
.hidden { display: none !important; }

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card {
    background: var(--bg-white);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.section-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}
