/* ==========================================================================
   Design Tokens & Root Variables (Tailored Harmonious HSL Palette)
   ========================================================================== */
:root {
    --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Fira Code', 'Courier New', Courier, monospace;

    /* Dark Mode Palette */
    --bg-main: #070913;
    --bg-terminal: #03050a;
    --card-bg: rgba(13, 17, 33, 0.7);
    --border-color: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.35);

    /* Accent & Glow Colors */
    --primary: hsl(243, 75%, 62%);
    --primary-glow: rgba(99, 102, 241, 0.4);
    --success: hsl(150, 75%, 45%);
    --success-glow: rgba(16, 185, 129, 0.3);
    --error: hsl(351, 80%, 55%);
    --error-glow: rgba(239, 68, 68, 0.3);
    --warning: hsl(35, 85%, 55%);
    --info: hsl(188, 85%, 50%);
    --text-main: #f1f3f9;
    --text-muted: #8b9bb4;
}

/* ==========================================================================
   Base Layout & Background Elements
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-ui);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
}

/* Cosmic Background Stars */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: radial-gradient(circle at 50% 50%, #10142e 0%, #070913 100%);
    opacity: 0.8;
}

/* Radial Glow Orbs */
.glow-effect {
    position: fixed;
    top: -10%;
    left: 60%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.03) 50%, transparent 100%);
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
}

.container {
    width: 100%;
    max-width: 1300px;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* ==========================================================================
   Header Section
   ========================================================================== */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #ffffff 40%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Pulsing Status Dot indicator */
.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.pulse-dot.idle { background-color: var(--text-muted); }
.pulse-dot.running {
    background-color: var(--info);
    box-shadow: 0 0 10px var(--info);
    animation: pulse 1.5s infinite alternate;
}
.pulse-dot.success {
    background-color: var(--success);
    box-shadow: 0 0 12px var(--success);
}
.pulse-dot.failed {
    background-color: var(--error);
    box-shadow: 0 0 12px var(--error);
}

.status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-badge.idle { color: var(--text-muted); background: rgba(255, 255, 255, 0.03); }
.status-badge.running { color: var(--info); background: rgba(6, 182, 212, 0.1); border-color: rgba(6, 182, 212, 0.2); }
.status-badge.success { color: var(--success); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); }
.status-badge.failed { color: var(--error); background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); }

/* ==========================================================================
   Dashboard Grid & Cards (Glassmorphism)
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.8rem;
    align-items: start;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass:hover {
    border-color: var(--border-hover);
}

.card {
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-main);
}

.card-body {
    padding: 1.5rem;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

/* ==========================================================================
   Buttons and Micro-Animations
   ========================================================================== */
.btn {
    width: 100%;
    padding: 0.9rem 1.5rem;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: #ffffff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-glow::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.1) 30%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.1) 70%,
        rgba(255, 255, 255, 0) 100%
    );
    transform: rotate(30deg);
    animation: sweep 4s infinite linear;
}

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

/* CSS Loader Ring */
.loader-ring {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   Sub-elements (Env Configuration & Captcha solver card)
   ========================================================================== */
.env-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

.env-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

.env-label {
    color: var(--text-muted);
}

.env-val {
    font-family: var(--font-mono);
    color: #a5b4fc;
}

/* Captcha visual design */
.captcha-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.captcha-preview-wrap {
    position: relative;
    width: 100%;
    height: 80px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.captcha-img {
    max-height: 80%;
    max-width: 90%;
    object-fit: contain;
}

.captcha-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 17, 33, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-spinner {
    width: 24px;
    height: 24px;
    border: 2px dashed var(--primary);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.captcha-info {
    text-align: center;
    width: 100%;
}

.captcha-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.captcha-solution {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.solved-text {
    font-weight: 700;
    color: var(--success);
    letter-spacing: 1px;
}

/* ==========================================================================
   Interactive Live Mono Terminal
   ========================================================================== */
.terminal-panel {
    height: calc(100vh - 120px - 2.5rem);
    min-height: 520px;
}

.terminal-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-terminal);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.terminal-card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.1);
}

.terminal-header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.2rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mac-dots {
    display: flex;
    gap: 6px;
}

.mac-dots .dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    display: inline-block;
}

.mac-dots .close { background-color: #ef4444; }
.mac-dots .minimize { background-color: #f59e0b; }
.mac-dots .expand { background-color: #10b981; }

.terminal-title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-clear {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-clear:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* Terminal logs and content styling */
.terminal-body {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

/* Live scanline overlay */
.terminal-body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

.log-line {
    word-break: break-all;
    white-space: pre-wrap;
    display: flex;
    align-items: flex-start;
}

.log-timestamp {
    color: #4b5563;
    margin-right: 0.5rem;
    flex-shrink: 0;
    user-select: none;
}

.log-badge {
    font-weight: 600;
    flex-shrink: 0;
    user-select: none;
}

/* Log categorization colors */
.log-line.log {
    color: var(--text-muted);
}
.log-line.log .log-badge {
    color: var(--text-muted);
}

.log-line.status {
    color: #818cf8; /* indigo-400 */
}
.log-line.status .log-badge {
    color: #6366f1;
}

.log-line.captcha {
    color: #22d3ee; /* cyan-400 */
}
.log-line.captcha .log-badge {
    color: #06b6d4;
}

.log-line.success {
    color: #34d399; /* emerald-400 */
    font-weight: 500;
}
.log-line.success .log-badge {
    color: var(--success);
}

.log-line.error {
    color: #f87171; /* red-400 */
}
.log-line.error .log-badge {
    color: var(--error);
}

.log-line.system-msg {
    color: var(--text-muted);
    font-style: italic;
    opacity: 0.8;
}

/* ==========================================================================
   Full screen glass overlay Modal (Successful Retrieval pop)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 7, 18, 0.85);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal {
    width: 100%;
    max-width: 540px;
    padding: 3rem 2.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

.modal-glow {
    position: absolute;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.25) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}

.success-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.15);
    border: 2px solid var(--success);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px var(--success-glow);
    margin-bottom: 0.5rem;
}

.success-icon svg {
    width: 32px;
    height: 32px;
}

.modal h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
}

.modal p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Access token container block */
.token-container {
    width: 100%;
    text-align: left;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.token-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #a5b4fc;
    letter-spacing: 1.5px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.token-box {
    display: flex;
    width: 100%;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    overflow: hidden;
    height: 50px;
    transition: border-color 0.3s ease;
}

.token-box:focus-within {
    border-color: var(--primary);
}

.token-box input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0 1.2rem;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
}

.btn-copy {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    width: 100px;
    color: var(--text-main);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.btn-copy:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-copy.copied {
    background: var(--success);
    color: #fff;
    border-left-color: var(--success);
}

.copy-icon {
    width: 15px;
    height: 15px;
}

/* ==========================================================================
   Standard Animations
   ========================================================================== */
@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.15); opacity: 1; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes sweep {
    0% { left: -100%; }
    50% { left: 150%; }
    100% { left: 150%; }
}
