/**
 * Composants UI réutilisables
 */

/* ==========================================
 * Boutons
 * ========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-main);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}
.btn-primary:hover { background: var(--accent-blue-dark); }

.btn-gold {
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dark));
    color: #0a0e17;
    font-weight: 600;
}
.btn-gold:hover { background: linear-gradient(135deg, var(--accent-gold-light), var(--accent-gold)); }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }

.btn-danger {
    background: transparent;
    color: var(--status-critical);
    border-color: var(--status-critical);
}
.btn-danger:hover { background: var(--status-critical); color: white; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.4rem 0.6rem;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; aspect-ratio: 1; justify-content: center; }

/* ==========================================
 * Cards
 * ========================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: all var(--transition-normal);
}
.card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
}
.card-body { }
.card-footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--stat-color, var(--accent-blue));
}
.stat-card:hover {
    border-color: var(--stat-color, var(--accent-blue));
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==========================================
 * Tables
 * ========================================== */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}
table {
    width: 100%;
    border-collapse: collapse;
}
thead {
    background: var(--bg-tertiary);
}
thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}
tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}
tbody tr:hover {
    background: var(--bg-hover);
}
tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
}
tbody tr:last-child {
    border-bottom: none;
}

/* ==========================================
 * Badges
 * ========================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}
.badge-primary { background: rgba(59,130,246,0.15); color: var(--accent-blue-light); }
.badge-success { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-danger { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-gray { background: rgba(107,114,128,0.15); color: var(--text-secondary); }
.badge-gold { background: rgba(201,168,76,0.15); color: var(--accent-gold-light); }

/* ==========================================
 * Formulaires
 * ========================================== */
.form-group {
    margin-bottom: 1rem;
}
.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.875rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-control::placeholder {
    color: var(--text-muted);
}
.form-control.is-invalid {
    border-color: var(--status-critical);
}
.form-error {
    font-size: 0.8rem;
    color: var(--status-critical);
    margin-top: 0.25rem;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

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

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}
.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* Color picker */
input[type="color"] {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 2px;
    background: var(--bg-secondary);
    cursor: pointer;
}

/* ==========================================
 * Modals
 * ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}
.modal-overlay.active {
    display: flex;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}
@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-size: 1.1rem;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color var(--transition-fast);
}
.modal-close:hover { color: var(--text-primary); }
.modal-body {
    padding: 1.5rem;
}
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ==========================================
 * Toast notifications
 * ========================================== */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-height) + 10px);
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.3s ease-out;
    position: relative;
}
.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.toast-success::before { background: var(--status-closed); }
.toast-error::before { background: var(--status-critical); }
.toast-warning::before { background: var(--status-active); }
.toast-info::before { background: var(--accent-blue); }
.toast-message { flex: 1; font-size: 0.875rem; }
.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

/* ==========================================
 * Pagination
 * ========================================== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1.5rem;
}
.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.pagination-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.pagination-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}
.pagination-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination-info {
    margin: 0 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ==========================================
 * Onglets
 * ========================================== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}
.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast);
    white-space: nowrap;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: var(--font-main);
}
.tab:hover { color: var(--text-primary); }
.tab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* ==========================================
 * Barre de recherche
 * ========================================== */
.search-bar {
    position: relative;
}
.search-bar .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.search-bar input {
    padding-left: 2.25rem;
}

/* ==========================================
 * Avatars
 * ========================================== */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    color: var(--accent-gold);
    border: 2px solid var(--border-color);
    overflow: hidden;
    flex-shrink: 0;
}
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-xl { width: 64px; height: 64px; font-size: 1.2rem; }

.avatar-stack {
    display: flex;
}
.avatar-stack .avatar {
    margin-left: -8px;
}
.avatar-stack .avatar:first-child {
    margin-left: 0;
}

/* ==========================================
 * Loaders
 * ========================================== */
.loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loader-lg { width: 40px; height: 40px; border-width: 3px; }

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 0.75rem;
}

/* ==========================================
 * Progress bar
 * ========================================== */
.progress {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width var(--transition-normal);
}

/* ==========================================
 * Toolbar
 * ========================================== */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

/* ==========================================
 * Empty state
 * ========================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted);
}
.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.3;
}
.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.empty-state p {
    max-width: 400px;
}

/* ==========================================
 * Confirm dialog
 * ========================================== */
.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}
