/* ==============================================================================
   AtomEngineX - Główny arkusz stylów (Dark Lab & Sci-Fi Aesthetics)
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
    --bg-dark: #090d16;
    --bg-surface: #101726;
    --bg-surface-elevated: #162035;
    --bg-card: rgba(22, 32, 53, 0.75);
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(0, 229, 255, 0.3);
    
    --primary: #00e5ff;
    --primary-glow: rgba(0, 229, 255, 0.4);
    --primary-dark: #00a0b2;
    
    --accent: #d500f9;
    --accent-glow: rgba(213, 0, 249, 0.4);
    
    --warning: #ffb300;
    --danger: #ff3d00;
    --success: #00e676;
    
    --text-primary: #f0f4fc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --font-main: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --glass-blur: blur(16px);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    
    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--primary-glow);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(0, 229, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(213, 0, 249, 0.05) 0%, transparent 40%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 30px 30px, 30px 30px;
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header & Top Bar */
.topbar {
    background: rgba(16, 23, 38, 0.85);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: inherit;
}

.brand img {
    height: 44px;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #ffffff 30%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.brand-text p {
    font-size: 0.7rem;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.user-stats {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-chip {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}

.stat-chip.money {
    border-color: rgba(0, 230, 118, 0.3);
    color: var(--success);
}

.stat-chip.day {
    border-color: rgba(0, 229, 255, 0.3);
    color: var(--primary);
}

.stat-chip.tier {
    border-color: rgba(213, 0, 249, 0.3);
    color: var(--accent);
}

.btn {
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #05131a;
    box-shadow: 0 4px 15px var(--primary-glow);
}

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

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, #a000bc 100%);
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
}

/* Banner Samouczka */
.tutorial-banner {
    background: linear-gradient(90deg, rgba(0, 229, 255, 0.15) 0%, rgba(213, 0, 249, 0.15) 100%);
    border-bottom: 1px solid var(--border-glow);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: pulseBanner 4s infinite alternate;
}

@keyframes pulseBanner {
    0% { border-color: rgba(0, 229, 255, 0.3); }
    100% { border-color: rgba(213, 0, 249, 0.5); }
}

.tutorial-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tutorial-badge {
    background: var(--primary);
    color: #05131a;
    font-size: 0.75rem;
    font-weight: 800;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.tutorial-text {
    font-size: 0.9rem;
    color: #fff;
}

.tutorial-text strong {
    color: var(--primary);
}

/* Nawigacja Główna (Tabs) */
.nav-tabs {
    display: flex;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1.5rem;
    gap: 0.5rem;
}

.nav-tab {
    padding: 0.85rem 1.25rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-tab:hover {
    color: var(--text-primary);
}

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

/* Desktop & Window Manager (LabOS) */
.desktop-area {
    position: relative;
    width: 100%;
    min-height: calc(100vh - 120px);
    overflow: hidden;
    padding: 1rem;
}

.lab-window {
    position: absolute;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-md);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 229, 255, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.2s ease, opacity 0.2s ease;
    min-width: 280px;
}

.lab-window.active-window {
    border-color: var(--primary);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.8), 0 0 25px var(--primary-glow);
}

.lab-window.minimized {
    display: none !important;
}

.window-header {
    background: linear-gradient(90deg, rgba(22, 32, 53, 0.95) 0%, rgba(16, 23, 38, 0.95) 100%);
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
    border-bottom: 1px solid var(--border-subtle);
}

.window-title {
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: 0.5px;
}

.window-controls {
    display: flex;
    gap: 0.4rem;
}

.win-btn {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    line-height: 1;
}

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

.win-btn.close:hover {
    background: var(--danger);
    border-color: var(--danger);
}

.window-body {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - 220px);
}

/* Dolny Pasek Dokujący (Dock / Taskbar) */
.dock-bar {
    position: fixed;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 23, 38, 0.85);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 900;
    box-shadow: 0 10px 30px rgba(0,0,0,0.7), 0 0 20px rgba(0, 229, 255, 0.15);
}

.dock-item {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.dock-item:hover {
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.dock-item.active {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(0, 229, 255, 0.12);
}

/* Quest Log (Zadania) */
.quest-item {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    margin-bottom: 0.75rem;
    position: relative;
    border-left: 4px solid var(--text-muted);
    transition: all 0.2s;
}

.quest-item.active-quest {
    border-left-color: var(--primary);
    background: rgba(0, 229, 255, 0.05);
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.1);
}

.quest-item.completed-quest {
    border-left-color: var(--success);
    opacity: 0.7;
}

.quest-title {
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.quest-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.quest-reward {
    font-size: 0.75rem;
    color: var(--warning);
    font-family: var(--font-mono);
    margin-top: 0.4rem;
}

/* Logi Eksperymentów (Terminal & Analizator) */
.log-entry {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.6rem;
    font-size: 0.8rem;
    line-height: 1.4;
    border-left: 4px solid var(--text-muted);
}

.log-entry.success { border-left-color: var(--success); }
.log-entry.failed { border-left-color: var(--warning); }
.log-entry.exploded { border-left-color: var(--danger); }

.log-meta {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.log-diag {
    color: var(--text-primary);
    margin: 0.25rem 0;
}

.log-hint {
    color: var(--primary);
    font-style: italic;
    margin-top: 0.25rem;
}

/* Status LMStudio */
.lm-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-subtle);
}

.lm-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.lm-dot.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.lm-dot.offline { background: var(--danger); }
.lm-dot.connecting { background: var(--warning); animation: pulse 1.5s infinite; }

/* Style Codexu i Tagów */
.codex-tag {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.codex-tag:hover, .codex-tag.active {
    background: rgba(0, 229, 255, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}

.codex-ai-box {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.08) 0%, rgba(213, 0, 249, 0.08) 100%);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.45;
    color: #e2e8f0;
}

.codex-ai-box strong {
    color: var(--primary);
}

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

/* Magazyn Reagentów (Drag Items) */
.inventory-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.6rem;
    max-height: 520px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.inventory-list::-webkit-scrollbar {
    width: 5px;
}
.inventory-list::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 4px;
}

.inv-item {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.6rem;
    cursor: grab;
    user-select: none;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.inv-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.15);
}

.inv-item:active {
    cursor: grabbing;
}

.inv-item-symbol {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.inv-item-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inv-item-qty {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--success);
    font-weight: 600;
    margin-top: 0.25rem;
}

/* Stół Roboczy / Komora Syntezy */
.reaction-chamber {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    background: radial-gradient(circle at 50% 50%, rgba(16, 23, 38, 0.9) 0%, rgba(9, 13, 22, 0.95) 100%);
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 2rem;
    position: relative;
    transition: all 0.3s ease;
}

.reaction-chamber.drag-over {
    border-color: var(--primary);
    background: rgba(0, 229, 255, 0.08);
    box-shadow: inset 0 0 30px rgba(0, 229, 255, 0.2);
}

/* Aparatura i Animacja Płynu */
.vessel-container {
    width: 180px;
    height: 220px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.vessel-graphic {
    width: 140px;
    height: 180px;
    border: 4px solid rgba(255, 255, 255, 0.4);
    border-top: none;
    border-radius: 0 0 35px 35px;
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.05);
}

.vessel-liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 35%;
    background: linear-gradient(180deg, rgba(0, 229, 255, 0.6) 0%, rgba(0, 160, 178, 0.8) 100%);
    transition: all 0.6s ease;
    border-radius: 0 0 30px 30px;
}

.vessel-bubbles {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.chamber-slots {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 70px;
}

.slot-item {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--primary);
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    animation: fadeIn 0.3s ease;
}

.slot-remove {
    cursor: pointer;
    color: var(--danger);
    font-weight: 700;
}

/* Parametry: Temperatura i Ciśnienie */
.chamber-controls {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
    background: var(--bg-surface);
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.param-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.param-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.param-val {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--primary);
}

.param-slider {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Panel Doktora Atoma / Asystenta AI */
.ai-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ai-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.chat-history {
    flex: 1;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-right: 0.5rem;
}

.chat-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.4;
}

.chat-bubble.ai {
    background: var(--bg-surface-elevated);
    border-left: 3px solid var(--primary);
    color: var(--text-primary);
}

.chat-bubble.user {
    background: rgba(0, 229, 255, 0.15);
    border-right: 3px solid var(--primary);
    align-self: flex-end;
    color: #fff;
}

.chat-input-box {
    display: flex;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.85rem;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.85rem;
}

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

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-backdrop.active {
    display: flex;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-glow);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 480px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 30px var(--primary-glow);
    text-align: center;
    position: relative;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Komunikaty i Toast */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-surface-elevated);
    border-left: 4px solid var(--primary);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.9rem;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    0% { transform: translateX(100%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
