/* ============================================================
   COMPONENTS — Buttons, Cards, Inputs, Badges, Toasts
   Shared across ALL pages
   ============================================================ */

/* ── Buttons ───────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.75rem 1.25rem;
    font-family: var(--font-main);
    font-size: var(--text-base);
    font-weight: var(--weight-semi);
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* Primary — Gold */
.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-hover) 100%);
    color: var(--text-inverse);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

/* Secondary — Indigo */
.btn-secondary {
    background: linear-gradient(135deg, var(--brand-secondary) 0%, var(--brand-secondary-hover) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-secondary:hover:not(:disabled) {
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

/* Outline */
.btn-outline {
    background: transparent;
    color: var(--brand-primary);
    border: 1.5px solid var(--brand-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--brand-primary-light);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

/* Danger */
.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: #fff;
}

/* Success */
.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #16a34a 100%);
    color: #fff;
}

/* Small */
.btn-sm {
    padding: 0.5rem 0.875rem;
    font-size: var(--text-sm);
    border-radius: var(--radius-sm);
}

/* Large */
.btn-lg {
    padding: 1rem 1.5rem;
    font-size: var(--text-md);
    border-radius: var(--radius-lg);
}

/* Icon Button (circular) */
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: var(--text-lg);
    flex-shrink: 0;
}

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

/* ── Cards ─────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-body {
    padding: var(--space-lg);
}

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

.card-header h3,
.card-header h4 {
    font-size: var(--text-md);
    font-weight: var(--weight-semi);
}

/* ── Form Components ───────────────────────────── */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-base);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
    background: var(--bg-elevated);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: var(--text-md);
    z-index: 2;
    pointer-events: none;
}

.input-with-icon .form-control {
    padding-left: 2.75rem;
}

.input-with-icon .password-toggle {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-tertiary);
    z-index: 2;
    font-size: var(--text-md);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}

.input-with-icon .password-toggle:hover {
    color: var(--brand-primary);
}

.error-message {
    display: block;
    font-size: var(--text-xs);
    color: var(--danger);
    margin-top: var(--space-xs);
}

/* ── Badges ────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: var(--text-xs);
    font-weight: var(--weight-semi);
    border-radius: var(--radius-full);
    white-space: nowrap;
}

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

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

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

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-brand {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

/* ── Notifications / Toasts ────────────────────── */
.notification {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    animation: slideUp 0.3s ease;
}

.notification.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.notification.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.notification.warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(234, 179, 8, 0.2);
}

.notification.info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

/* ── Toast (fixed position) ────────────────────── */
.toast-container {
    position: fixed;
    top: var(--space-md);
    left: 50%;
    transform: translateX(-50%);
    z-index: var(--z-toast);
    width: 90%;
    max-width: 400px;
}

.toast {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s var(--ease-spring);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
}

/* ── Divider ───────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-md) 0;
}

/* ── Avatar ────────────────────────────────────── */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover));
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-bold);
    font-size: var(--text-sm);
    flex-shrink: 0;
    text-transform: uppercase;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: var(--text-lg);
}

/* ── Empty State ───────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-tertiary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.4;
}

.empty-state p {
    font-size: var(--text-base);
}

/* ── Loading Skeleton ──────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ── Chip ──────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.35rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip.active,
.chip:hover {
    background: var(--brand-primary-light);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

/* ── Tab Bar ───────────────────────────────────── */
.tab-bar {
    display: flex;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 3px;
    gap: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-item {
    flex: 1;
    min-width: fit-content;
    padding: 0.625rem 0.875rem;
    text-align: center;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab-item:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.tab-item.active {
    background: var(--brand-primary);
    color: var(--text-inverse);
    font-weight: var(--weight-semi);
}

/* ── Modal ─────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: var(--z-modal);
    display: flex;
    align-items: flex-end;     /* Bottom sheet for mobile */
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

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

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: var(--max-content-width);
    max-height: 90vh;
    padding: var(--space-lg);
    transform: translateY(100%);
    transition: transform var(--transition-normal) var(--ease-spring);
    overflow-y: auto;
}

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

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    margin: 0 auto var(--space-md);
}
