/* ================================================================
   RegulAI — UI Components
   ================================================================ */

/* ── Glass Card ──────────────────────────────────────────── */
.card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-lg), 0 0 20px var(--primary-glow);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
}

.card-header h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
}

.card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.card-icon.primary {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary);
}

.card-icon.teal {
    background: var(--accent-teal-glow);
    color: var(--accent-teal);
}

.card-icon.emerald {
    background: var(--accent-emerald-glow);
    color: var(--accent-emerald);
}

.card-icon.amber {
    background: var(--accent-amber-glow);
    color: var(--accent-amber);
}

.card-icon.rose {
    background: var(--accent-rose-glow);
    color: var(--accent-rose);
}

/* ── Stat Card ───────────────────────────────────────────── */
.stat-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-card);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-accent);
}

.stat-card .stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
    position: relative;
    z-index: 1;
}

.stat-card .stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 800;
    line-height: 1;
    margin-bottom: var(--space-2);
    position: relative;
    z-index: 1;
}

.stat-card .stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    font-weight: 500;
    position: relative;
    z-index: 1;
}

.stat-card .stat-change {
    font-size: var(--font-size-xs);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    position: relative;
    z-index: 1;
}

.stat-change.positive {
    color: var(--success);
    background: var(--success-bg);
}

.stat-change.negative {
    color: var(--danger);
    background: var(--danger-bg);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    transition: background var(--transition-fast);
}

.btn:hover::after {
    background: rgba(255, 255, 255, 0.1);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 6px 25px var(--primary-glow);
    transform: translateY(-1px);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--primary-light);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: rgba(108, 99, 255, 0.1);
    color: var(--primary-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: var(--bg-deep);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--font-size-base);
    border-radius: var(--radius-lg);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-xs);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-block {
    width: 100%;
}

.btn:disabled,
.btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Form Elements ───────────────────────────────────────── */
.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-control {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--bg-tertiary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

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 12 12'%3E%3Cpath fill='%23ffffff50' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

.form-hint {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.form-error {
    font-size: var(--font-size-xs);
    color: var(--danger);
    margin-top: var(--space-1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ── Checkbox / Radio ────────────────────────────────────── */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-primary {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary-light);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* ── Progress Bar ────────────────────────────────────────── */
.progress {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    transition: width var(--transition-slow);
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-shimmer);
    animation: shimmer 2s infinite;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-6);
    gap: var(--space-1);
    overflow-x: auto;
}

.tab {
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-tertiary);
    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-family);
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary);
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: var(--z-modal-backdrop);
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-fast);
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    z-index: var(--z-modal);
    animation: slideUp var(--transition-base);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 300px;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight var(--transition-base);
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.warning {
    border-left: 3px solid var(--warning);
}

.toast.info {
    border-left: 3px solid var(--info);
}

/* ── Tooltip ─────────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: var(--z-tooltip);
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-16);
    color: var(--text-tertiary);
}

.empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.3;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

/* ── Alert Box ───────────────────────────────────────────── */
.alert {
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-sm);
}

.alert-success {
    background: var(--success-bg);
    border: 1px solid rgba(0, 230, 118, 0.2);
    color: var(--success);
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid rgba(255, 82, 82, 0.2);
    color: var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    border: 1px solid rgba(255, 171, 64, 0.2);
    color: var(--warning);
}

.alert-info {
    background: var(--info-bg);
    border: 1px solid rgba(0, 229, 255, 0.2);
    color: var(--info);
}

/* ── Divider ─────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--border-subtle);
    margin: var(--space-6) 0;
}

/* ── Tag / Chip ──────────────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    cursor: default;
}

.chip.active {
    background: rgba(108, 99, 255, 0.15);
    border-color: var(--primary);
    color: var(--primary-light);
}

.chip .chip-remove {
    cursor: pointer;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
}

.chip .chip-remove:hover {
    opacity: 1;
}

/* ── Skeleton Loader ─────────────────────────────────────── */
.skeleton {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-shimmer);
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 100%;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

.skeleton-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
}