/* ═══════════════════════════════════════════════════════════
   Webradio Manager v2 — Composants Réutilisables
   ═══════════════════════════════════════════════════════════ */

/* ─── BUTTONS ─── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.2;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: var(--font-size-xs);
}

.btn-lg {
    padding: 12px 24px;
    font-size: var(--font-size-md);
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 0 12px var(--accent-glow);
}

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

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

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

.btn-success:hover:not(:disabled) {
    box-shadow: 0 0 12px rgba(0, 230, 118, 0.3);
}

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

.btn-danger:hover:not(:disabled) {
    box-shadow: 0 0 12px rgba(255, 23, 68, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.btn-icon {
    padding: 6px;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
}

.btn-icon:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ─── INPUTS ─── */

.input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
    outline: none;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.input::placeholder {
    color: var(--text-disabled);
}

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

.select {
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    outline: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.select:focus {
    border-color: var(--accent);
}

/* ─── SLIDER (range) ─── */

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: var(--radius-round);
    background: var(--accent);
    border: 2px solid var(--bg-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 0 4px var(--accent-glow);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 8px var(--accent-glow);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-round);
    background: var(--accent);
    border: 2px solid var(--bg-primary);
    cursor: pointer;
    box-shadow: 0 0 4px var(--accent-glow);
}

/* ─── TOGGLE SWITCH ─── */

.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 11px;
    transition: all var(--transition-fast);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    border-radius: var(--radius-round);
    transition: all var(--transition-fast);
}

.toggle input:checked + .toggle-slider {
    background: var(--accent-dim);
    border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
    background: var(--accent);
}

/* ─── BADGE ─── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.badge-accent {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent);
}

.badge-success {
    background: var(--success-dim);
    color: var(--success);
    border-color: var(--success);
}

.badge-danger {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: var(--danger);
}

.badge-warning {
    background: var(--warning-dim);
    color: var(--warning);
    border-color: var(--warning);
}

/* ─── CARD ─── */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── SECTION HEADER ─── */

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.section-header h2 {
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── UTILITY ─── */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* ─── EMPTY STATE ─── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-sm);
    text-align: center;
    padding: var(--sp-2xl) var(--sp-md);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}

.empty-state .empty-icon {
    font-size: 32px;
    opacity: 0.5;
}

.empty-state p {
    margin: 0;
}

.empty-state .text-muted {
    color: var(--text-disabled);
    font-size: var(--fs-xs);
}

/* ─── TOAST NOTIFICATIONS ─── */

.toast-container {
    position: fixed;
    top: var(--space-md);
    right: var(--space-md);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 400px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    animation: slideInRight 0.3s ease;
    font-size: var(--font-size-sm);
}

.toast-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.toast-message {
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-warning { border-left: 3px solid var(--warning); }

.toast-exit {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}

/* ─── MODAL ─── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideInUp 0.25s ease;
}

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

.modal-header h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* ─── LOADING SPINNER ─── */

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: var(--radius-round);
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

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

/* ─── TOOLTIP ─── */

[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: var(--font-size-xs);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    border: 1px solid var(--border);
    z-index: 10;
}

[data-tooltip]:hover::after {
    opacity: 1;
}
