/**
 * SOLVUH Design System - Components
 * ==================================
 * Reusable UI component styles
 */

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-base);
    font-weight: 500;
    line-height: 1.5;
    border-radius: var(--radius-lg);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

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

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

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

.btn-secondary {
    background: var(--btn-secondary-bg);
    border-color: var(--btn-secondary-border);
    color: var(--surface-100);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-700);
    border-color: var(--surface-600);
}

.btn-ghost {
    background: transparent;
    color: var(--surface-400);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-800);
    color: var(--surface-100);
}

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

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-icon {
    padding: var(--space-2);
    width: 2.5rem;
    height: 2.5rem;
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-lg);
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-size-xs);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--info);
}

.badge-neutral {
    background: var(--surface-800);
    border-color: var(--surface-700);
    color: var(--surface-400);
}

.badge-primary {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--primary-400);
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
}

.card-hover:hover {
    border-color: var(--card-hover-border);
    background: var(--surface-850);
}

.card-interactive {
    cursor: pointer;
    transition: all var(--transition-fast);
}

.card-interactive:hover {
    border-color: var(--primary-500);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--surface-100);
}

.card-subtitle {
    font-size: var(--font-size-sm);
    color: var(--surface-400);
}

/* ========================================
   INPUTS
   ======================================== */
.input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-lg);
    color: var(--surface-100);
    font-size: var(--font-size-base);
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

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

.input:focus {
    outline: none;
    border-color: var(--input-focus-border);
}

.input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

textarea.input {
    resize: none;
    min-height: 3rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.input-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--surface-300);
}

.input-help {
    font-size: var(--font-size-xs);
    color: var(--surface-500);
}

/* ========================================
   SELECT
   ======================================== */
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    padding-right: var(--space-10);
}

/* ========================================
   TOGGLE SWITCH
   ======================================== */
.toggle-switch {
    width: 2.5rem;
    height: 1.5rem;
    background: var(--surface-700);
    border: 1px solid var(--surface-600);
    border-radius: var(--radius-full);
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle-switch.active {
    background: var(--primary-600);
    border-color: var(--primary-500);
}

.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1rem;
    height: 1rem;
    background: var(--surface-300);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.toggle-switch.active .toggle-knob {
    left: calc(100% - 1.125rem);
    background: white;
}

/* ========================================
   KEYBOARD SHORTCUTS
   ======================================== */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 var(--space-1);
    background: var(--surface-800);
    border: 1px solid var(--surface-700);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--surface-400);
}

.kbd-group {
    display: inline-flex;
    gap: 2px;
}

/* ========================================
   PROGRESS BARS
   ======================================== */
.progress-bar {
    height: 0.5rem;
    background: var(--surface-800);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-500);
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

.progress-bar-fill.success { background: var(--success); }
.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }

/* ========================================
   SCORE RING
   ======================================== */
.score-ring {
    position: relative;
    width: 5rem;
    height: 5rem;
}

.score-ring svg {
    transform: rotate(-90deg);
}

.score-ring circle {
    fill: none;
    stroke-width: 4;
}

.score-ring .bg {
    stroke: var(--surface-800);
}

.score-ring .progress {
    stroke: var(--primary-500);
    stroke-dasharray: 251.2;
    stroke-dashoffset: calc(251.2 - (251.2 * var(--score, 0)) / 10);
    stroke-linecap: round;
    transition: stroke-dashoffset 1s ease-out;
}

.score-ring .value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--primary-400);
}

/* ========================================
   TOOLTIPS
   ======================================== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: var(--space-1) var(--space-2);
    background: var(--surface-800);
    border: 1px solid var(--surface-700);
    border-radius: var(--radius-md);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    z-index: var(--z-tooltip);
    pointer-events: none;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   MODALS
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal-overlay.open {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 32rem;
    max-height: 90vh;
    background: var(--surface-900);
    border: 1px solid var(--surface-800);
    border-radius: var(--radius-xl);
    overflow: hidden;
    animation: scaleIn var(--transition-base) ease-out;
}

.modal-lg { max-width: 48rem; }
.modal-xl { max-width: 64rem; }
.modal-full { max-width: 90vw; max-height: 90vh; }

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

.modal-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
    color: var(--surface-100);
}

.modal-close {
    width: 2rem;
    height: 2rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--surface-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--surface-800);
    color: var(--surface-100);
}

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
    max-height: calc(90vh - 8rem);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--surface-800);
}

/* ========================================
   TOASTS
   ======================================== */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface-900);
    border: 1px solid var(--surface-800);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 24rem;
    pointer-events: auto;
    animation: slideInRight var(--transition-slow) ease-out;
}

.toast-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
}

.toast-content { flex: 1; }

.toast-title {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--surface-100);
    margin-bottom: var(--space-1);
}

.toast-message {
    font-size: var(--font-size-sm);
    color: var(--surface-400);
}

.toast-close {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--surface-500);
    cursor: pointer;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

/* ========================================
   LOADING STATES
   ======================================== */
.loading-screen {
    position: fixed;
    inset: 0;
    background: var(--surface-950);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-slow);
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    width: 4rem;
    height: 4rem;
    margin: 0 auto var(--space-4);
    color: var(--primary-500);
    animation: pulse 2s ease-in-out infinite;
}

.loading-text {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--surface-100);
    margin-bottom: var(--space-6);
    letter-spacing: 0.1em;
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--surface-800);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--surface-800) 25%, var(--surface-700) 50%, var(--surface-800) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* ========================================
   EMPTY STATES
   ======================================== */
.empty-state {
    text-align: center;
    padding: var(--space-8);
    color: var(--surface-500);
}

.empty-state-icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto var(--space-4);
    opacity: 0.5;
}

.empty-state-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--surface-400);
    margin-bottom: var(--space-2);
}

.empty-state-description {
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-4);
}

/* ========================================
   STATUS INDICATORS
   ======================================== */
.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--surface-600);
}

.status-dot.connected { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }
.status-dot.pending { background: var(--warning); animation: pulse 2s infinite; }
.status-dot.active { background: var(--info); animation: pulse 1s infinite; }

.connection-status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--surface-900);
    border: 1px solid var(--surface-800);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
}

.status-text {
    color: var(--surface-400);
}

/* ========================================
   TABS
   ======================================== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--surface-800);
}

.tab {
    padding: var(--space-3) var(--space-4);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--surface-400);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--surface-200);
    background: var(--surface-850);
}

.tab.active {
    color: var(--primary-400);
    border-bottom-color: var(--primary-500);
}

/* ========================================
   PIPELINE STAGE
   ======================================== */
.pipeline-stage {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--surface-900);
    border: 1px solid var(--surface-800);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
}

.pipeline-stage.active {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.05);
}

.pipeline-stage.complete {
    border-color: rgba(34, 197, 94, 0.3);
}

.pipeline-stage.failed {
    border-color: rgba(239, 68, 68, 0.3);
}

.pipeline-stage-icon {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: var(--surface-800);
    color: var(--surface-500);
}

.pipeline-stage.active .pipeline-stage-icon {
    background: var(--warning);
    color: white;
}

.pipeline-stage.complete .pipeline-stage-icon {
    background: var(--success);
    color: white;
}

.pipeline-stage.failed .pipeline-stage-icon {
    background: var(--danger);
    color: white;
}

.pipeline-stage-info {
    flex: 1;
    min-width: 0;
}

.pipeline-stage-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--surface-200);
}

.pipeline-stage-status {
    font-size: var(--font-size-xs);
    color: var(--surface-500);
}

.pipeline-stage.active .pipeline-stage-status { color: var(--warning); }
.pipeline-stage.complete .pipeline-stage-status { color: var(--success); }
.pipeline-stage.failed .pipeline-stage-status { color: var(--danger); }
