/* ============================================
   COMPOSANTS UI - QUIZZ MAKER
   Bibliotheque de composants reutilisables
   Version 1.0 - 2024-12-21
   ============================================ */

/* === BOUTONS === */
/* Nouveau systeme .button avec variantes */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: transform var(--transition-fast),
                box-shadow var(--transition-fast),
                background var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.button:hover {
    transform: translateY(-2px);
}

.button:active {
    transform: translateY(0);
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Primary - Bleu (actions principales) */
.button.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.button.primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* CTA - Orange (actions importantes) */
.button.cta {
    background: var(--cta);
    color: white;
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
}

.button.cta:hover {
    background: var(--cta-dark);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
}

/* Secondary - Gris clair */
.button.secondary {
    background: var(--border);
    color: var(--ink);
}

.button.secondary:hover {
    background: var(--border-dark);
}

/* Ghost - Transparent avec bordure */
.button.ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--border-dark);
}

.button.ghost:hover {
    background: var(--paper);
    border-color: var(--ink-soft);
}

/* Danger - Rouge */
.button.danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.button.danger:hover {
    background: var(--danger-dark);
}

/* Success - Vert */
.button.success {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 14px rgba(34, 197, 94, 0.35);
}

.button.success:hover {
    background: var(--success-dark);
}

/* Tailles */
.button.sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.button.lg {
    padding: 16px 32px;
    font-size: 1.125rem;
}

/* Block (pleine largeur) */
.button.block {
    width: 100%;
}

/* Icone seule */
.button.icon-only {
    padding: 12px;
    border-radius: var(--radius-md);
}

/* Time adjust buttons (dashboard) */
.button.time-adjust {
    padding: 8px 14px;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
}

.button.time-adjust.minus {
    background: var(--danger-bg);
    color: #dc2626;
}

.button.time-adjust.minus:hover {
    background: #fecaca;
}

.button.time-adjust.plus {
    background: var(--success-bg);
    color: #166534;
}

.button.time-adjust.plus:hover {
    background: #bbf7d0;
}

/* === ALIAS POUR COMPATIBILITE === */
/* Les anciennes classes .btn-* fonctionnent toujours */
.btn-primary {
    composes: button primary from global;
}

.btn-secondary {
    composes: button secondary from global;
}

.btn-danger {
    composes: button danger from global;
}

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge.success {
    background: var(--success-bg);
    color: #166534;
}

.badge.warning {
    background: var(--warning-bg);
    color: #92400e;
}

.badge.info {
    background: var(--info-bg);
    color: #1e3a8a;
}

.badge.danger {
    background: var(--danger-bg);
    color: #991b1b;
}

.badge.neutral {
    background: var(--border);
    color: var(--ink-soft);
}

/* Badge avec dot */
.badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* === CARTES === */
.card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--paper) 0%, #f1f5f9 100%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    background: var(--paper);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Card elevee */
.card.elevated {
    box-shadow: var(--shadow-lg);
}

/* Card interactive */
.card.interactive {
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.card.interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* === PANELS (Dashboard) === */
.panel {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.panel + .panel {
    margin-top: var(--space-md);
}

.panel-title {
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: var(--space-md);
}

/* === FORMULAIRES ENRICHIS === */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: var(--space-xs);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--ink);
    background: var(--white);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:hover,
.form-group textarea:hover,
.form-group select:hover {
    border-color: var(--muted);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Select standalone (LISTE_DEROUL, appariement) */
.form-select {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--ink);
    background: var(--white);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-md);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: calc(16px + 20px);
    cursor: pointer;
}

.form-select:hover {
    border-color: var(--muted);
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Texte d'aide sous le champ */
.form-group small,
.form-group .help-text {
    display: block;
    margin-top: var(--space-xs);
    font-size: 0.85rem;
    color: var(--muted);
}

/* Champ en erreur */
.form-group.error input,
.form-group.error textarea,
.form-group.error select {
    border-color: var(--danger);
}

.form-group.error small {
    color: var(--danger);
}

/* Champ valide */
.form-group.valid input,
.form-group.valid textarea,
.form-group.valid select {
    border-color: var(--success);
}

/* === KPI (Indicateurs cles) === */
.kpi {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.kpi-label {
    font-size: 0.9rem;
    color: var(--muted);
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
}

.kpi-value.success { color: var(--success); }
.kpi-value.warning { color: var(--warning); }
.kpi-value.danger { color: var(--danger); }

/* === STATUS DOT + LABEL === */
/* Toujours accompagner le dot d'un label texte */
.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.active { background: var(--success); }
.status-dot.idle { background: var(--warning); }
.status-dot.warning { background: var(--danger); }
.status-dot.waiting { background: var(--primary); }
.status-dot.offline { background: var(--muted); }

.status-label {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

/* === ALERTES === */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert.success {
    background: var(--success-bg);
    color: #166534;
    border: 1px solid #86efac;
}

.alert.warning {
    background: var(--warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert.danger {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert.info {
    background: var(--info-bg);
    color: #1e3a8a;
    border: 1px solid #93c5fd;
}

/* === DIVIDER === */
.divider {
    display: flex;
    align-items: center;
    margin: var(--space-lg) 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    padding: 0 var(--space-md);
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 500;
}

/* === PROGRESS BAR === */
.progress {
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* Progress avec etats */
.progress.success .progress-bar { background: var(--success); }
.progress.warning .progress-bar { background: var(--warning); }
.progress.danger .progress-bar { background: var(--danger); }

/* === NAVIGATION RAPIDE (Exam) === */
.question-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.qchip {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    background: var(--border);
    color: var(--ink-soft);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.qchip:hover {
    background: var(--paper);
    border-color: var(--primary);
}

.qchip.answered {
    background: var(--success-bg);
    color: #166534;
    border-color: #86efac;
}

.qchip.unanswered {
    background: var(--danger-bg);
    color: #991b1b;
    border-color: #fecaca;
}

.qchip.current {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.qchip.flagged {
    background: var(--warning-bg);
    color: #92400e;
    border-color: #fde68a;
}

/* === STUDENT CARD (Dashboard) === */
.student-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color var(--transition);
}

.student-card:hover {
    border-color: var(--primary-light);
}

.student-card .name {
    font-weight: 600;
    color: var(--ink);
}

.student-card .code {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--muted);
}

.student-card .status {
    margin-top: var(--space-xs);
}

/* === SAVE PILL (Autosave status) === */
.save-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    background: var(--success-bg);
    color: #065f46;
}

.save-pill.saving {
    background: var(--warning-bg);
    color: #92400e;
}

.save-pill.error {
    background: var(--danger-bg);
    color: #991b1b;
}

/* === TIMER === */
.timer {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 600;
    padding: 6px 12px;
    background: var(--bg-dark);
    color: var(--paper);
    border-radius: var(--radius-md);
}

.timer.warning {
    background: var(--warning);
    color: var(--ink);
    animation: pulse 1s infinite;
}

.timer.danger {
    background: var(--danger);
    color: white;
    animation: pulse 0.5s infinite;
}

/* === TOASTS === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--muted);
    animation: slideIn 0.3s ease;
    position: relative;
}

.toast.success {
    border-left-color: var(--success);
    background: linear-gradient(135deg, var(--white) 0%, #f0fdf4 100%);
}

.toast.warning {
    border-left-color: var(--warning);
    background: linear-gradient(135deg, var(--white) 0%, #fffbeb 100%);
}

.toast.danger {
    border-left-color: var(--danger);
    background: linear-gradient(135deg, var(--white) 0%, #fef2f2 100%);
}

.toast.info {
    border-left-color: var(--primary);
    background: linear-gradient(135deg, var(--white) 0%, #eff6ff 100%);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.danger .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--primary); }

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ink);
    margin-bottom: 4px;
}

.toast-message {
    font-size: 0.875rem;
    color: var(--ink-soft);
    line-height: 1.4;
}

.toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.toast-close:hover {
    opacity: 1;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden;
}

.toast-progress-bar {
    height: 100%;
    background: currentColor;
    transition: width linear;
}

.toast.success .toast-progress-bar { background: var(--success); }
.toast.warning .toast-progress-bar { background: var(--warning); }
.toast.danger .toast-progress-bar { background: var(--danger); }
.toast.info .toast-progress-bar { background: var(--primary); }

.toast.hiding {
    animation: slideOut 0.3s ease forwards;
}

@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;
    }
}

/* === CONFIRM MODAL === */
.confirm-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.confirm-modal.active {
    display: flex;
}

.confirm-modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: modalIn 0.2s ease;
}

.confirm-modal-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

.confirm-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: var(--space-sm);
}

.confirm-modal-message {
    color: var(--ink-soft);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}

.confirm-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

@keyframes modalIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}
