/* ── Global Loading Indicator ──────────────────────────── */
#global-loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    z-index: 10000;
    background: transparent;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.15s ease;
}

#global-loading-indicator.active {
    opacity: 1;
}

#global-loading-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%,
        #6C5CE7 10%,
        #a78bfa 30%,
        #06b6d4 50%,
        #a78bfa 70%,
        #6C5CE7 90%,
        transparent 100%);
    animation: loading-slide 1s ease-in-out infinite;
    box-shadow: 
        0 0 12px rgba(108, 92, 231, 0.6),
        0 0 24px rgba(167, 139, 250, 0.4),
        0 0 36px rgba(6, 182, 212, 0.2);
    border-radius: 0 2px 2px 0;
}

#global-loading-indicator::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        rgba(108, 92, 231, 0.15) 0%,
        rgba(167, 139, 250, 0.1) 50%,
        rgba(108, 92, 231, 0.15) 100%);
    animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-slide {
    0% { left: -40%; }
    100% { left: 100%; }
}

@keyframes loading-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ── Button Loading States ──────────────────────────── */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

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

/* ── Inline Loading Spinner ──────────────────────────── */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(108, 92, 231, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spinner-rotate 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

.loading-spinner-sm {
    width: 12px;
    height: 12px;
    border-width: 1.5px;
}

.loading-spinner-lg {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

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

/* ── Card/Section Loading Overlay ──────────────────────────── */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
    backdrop-filter: blur(2px);
}

.loading-overlay-dark {
    background: rgba(15, 23, 42, 0.7);
}

.loading-overlay .loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
}

.loading-overlay .loading-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Skeleton Loading ──────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, 
        rgba(108, 92, 231, 0.08) 25%, 
        rgba(108, 92, 231, 0.15) 50%, 
        rgba(108, 92, 231, 0.08) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-title {
    height: 20px;
    width: 40%;
    margin-bottom: 12px;
}

.skeleton-card {
    height: 80px;
    margin-bottom: 12px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── WebSocket running indicator ──────────────────────────── */
#ws-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 56px;
    z-index: 9999;
    background: linear-gradient(90deg,
        var(--primary) 0%,
        #a78bfa 40%,
        #06b6d4 70%,
        var(--primary) 100%);
    background-size: 200% 100%;
    animation: ws-bar-slide 1.6s linear infinite;
    display: none;
    pointer-events: auto;
    box-shadow: 0 -4px 24px rgba(37, 99, 235, 0.35);
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 24px;
}
#ws-progress-bar.running {
    display: flex;
}
#ws-progress-bar .ws-bar-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: ws-spin 0.75s linear infinite;
    flex-shrink: 0;
}
#ws-progress-bar .ws-bar-label {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.25);
    flex: 1;
    margin-left: 24px;
}

.ws-cancel-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ws-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

.ws-cancel-btn:active {
    transform: translateY(0);
}
@keyframes ws-bar-slide {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* Floating status badge — hidden, replaced by bottom bar */
#ws-status-badge {
    display: none !important;
}
#ws-status-badge .ws-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(37,99,235,0.25);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ws-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes ws-spin {
    to { transform: rotate(360deg); }
}
#ws-status-badge .ws-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}



* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100vw;
}

:root {
    /* ── Brand palette ────────────────────────────────── */
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --primary-lighter: #60a5fa;
    --primary-subtle: #93bbfd;

    /* ── Surfaces ─────────────────────────────────────── */
    --bg-white: #ffffff;
    --bg-primary: #f8f9fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e8f0fe;

    /* ── Typography ───────────────────────────────────── */
    --text-dark: #0f172a;
    --text-medium: #475569;
    --text-light: #94a3b8;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* ── Accent ───────────────────────────────────────── */
    --accent-primary: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: rgba(37, 99, 235, 0.08);

    /* ── Semantic ─────────────────────────────────────── */
    --success: #16a34a;
    --warning: #f59e0b;
    --error: #ef4444;

    /* ── Elevation ────────────────────────────────────── */
    --border: rgba(15, 23, 42, 0.06);
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.10);
    --shadow-card: 0 24px 56px rgba(15, 23, 42, 0.10);

    /* ── Radius ───────────────────────────────────────── */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    --radius-full: 999px;

    /* ── Motion ───────────────────────────────────────── */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    max-width: 100vw;
    overflow-x: hidden !important;
    margin: 0;
    padding: 0;
}

/* Loading overlay inicial */
body.loading::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.loading::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 10000;
}

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

/* ── Screen Management ──────────────────────────────── */

.screen {
    display: none;
    width: 100%;
    height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
}

.screen.active {
    display: flex;
}

/* ── Animations ─────────────────────────────────────── */

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* ── Scrollbar ──────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.45); }

/* ── Confirm Dialog ─────────────────────────────────── */

.confirm-dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.confirm-dialog-overlay.active {
    display: flex;
}

.confirm-dialog {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px 24px;
    width: 100%;
    max-width: 400px;
    animation: confirmDialogIn 0.22s cubic-bezier(0.34, 1.4, 0.64, 1);
    outline: none;
}

@keyframes confirmDialogIn {
    from { opacity: 0; transform: scale(0.90) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.confirm-dialog-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 22px;
    line-height: 1;
}

.confirm-dialog-icon.danger  { background: rgba(239, 68, 68, 0.10); }
.confirm-dialog-icon.primary { background: rgba(37, 99, 235, 0.10); }
.confirm-dialog-icon.warning { background: rgba(245, 158, 11, 0.10); }

.confirm-dialog-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 8px;
}

.confirm-dialog-message {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.65;
    margin-bottom: 24px;
}

.confirm-dialog-actions {
    display: flex;
    gap: 10px;
}

.confirm-dialog-actions button {
    flex: 1;
    width: auto;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ── Toast Notifications ────────────────────────────── */

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 360px;
    width: calc(100vw - 40px);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 14px 16px;
    pointer-events: all;
    border-left: 4px solid transparent;
    animation: toastIn 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) both;
    overflow: hidden;
    position: relative;
}

.toast.toast-hiding {
    animation: toastOut 0.28s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0);    max-height: 120px; margin-bottom: 0; }
    to   { opacity: 0; transform: translateX(110%); max-height: 0;     margin-bottom: -10px; }
}

.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--error); }
.toast-info    { border-left-color: var(--primary); }
.toast-warning { border-left-color: var(--warning); }

.toast-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    margin-top: 1px;
    color: white;
}

.toast-success .toast-icon { background: var(--success); }
.toast-error   .toast-icon { background: var(--error); }
.toast-info    .toast-icon { background: var(--primary); }
.toast-warning .toast-icon { background: var(--warning); }

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: break-word;
}

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

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

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 0 0;
    animation: toastProgress linear forwards;
}

.toast-success .toast-progress { background: var(--success); }
.toast-error   .toast-progress { background: var(--error); }
.toast-info    .toast-progress { background: var(--primary); }
.toast-warning .toast-progress { background: var(--warning); }

@keyframes toastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}