/* ===== CSS VARIABLES FOR THEMES ===== */
:root {
    --bg: #f8fafc;
    --bg-secondary: #ffffff;
    --fg: #1e293b;
    --fg-secondary: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --positive: #10b981;
    --negative: #ef4444;
    --warning: #f59e0b;
    --klass-a: #dc2626;
    --klass-b: #ea580c;
    --klass-c: #ca8a04;
    --legal: #059669;
    --illegal: #dc2626;
    --rx: #7c3aed;
    --header-bg: #ffffff;
    --input-bg: #f1f5f9;
    --overlay-bg: rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-secondary: #1e293b;
    --fg: #f1f5f9;
    --fg-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --card-bg: #1e293b;
    --card-border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --header-bg: #1e293b;
    --input-bg: #334155;
    --overlay-bg: rgba(0, 0, 0, 0.7);
}

[data-theme="synthwave"] {
    --bg: #1a1033;
    --bg-secondary: #2d1b4e;
    --fg: #f0e6ff;
    --fg-secondary: #b8a9c9;
    --accent: #ff00ff;
    --accent-hover: #ff66ff;
    --card-bg: #2d1b4e;
    --card-border: #4a2875;
    --shadow: rgba(255, 0, 255, 0.2);
    --positive: #00ffcc;
    --negative: #ff3366;
    --warning: #ffcc00;
    --header-bg: #1a1033;
    --input-bg: #3d2060;
    --overlay-bg: rgba(26, 16, 51, 0.9);
}

[data-theme="matrix"] {
    --bg: #000000;
    --bg-secondary: #0a0a0a;
    --fg: #00ff00;
    --fg-secondary: #00aa00;
    --accent: #00ff00;
    --accent-hover: #33ff33;
    --card-bg: #0a0f0a;
    --card-border: #003300;
    --shadow: rgba(0, 255, 0, 0.1);
    --positive: #00ff00;
    --negative: #ff3333;
    --warning: #ffff00;
    --header-bg: #000000;
    --input-bg: #001a00;
    --overlay-bg: rgba(0, 0, 0, 0.9);
}

[data-theme="dracula"] {
    --bg: #282a36;
    --bg-secondary: #21222c;
    --fg: #f8f8f2;
    --fg-secondary: #6272a4;
    --accent: #bd93f9;
    --accent-hover: #ffb86c;
    --card-bg: #44475a;
    --card-border: #6272a4;
    --shadow: rgba(0, 0, 0, 0.4);
    --positive: #50fa7b;
    --negative: #ff5555;
    --warning: #ffb86c;
    --klass-a: #ff5555;
    --klass-b: #ffb86c;
    --klass-c: #f1fa8c;
    --legal: #50fa7b;
    --illegal: #ff5555;
    --rx: #bd93f9;
    --header-bg: #21222c;
    --input-bg: #1e1f29;
    --overlay-bg: rgba(0, 0, 0, 0.8);
}

/* ===== BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
}

[data-theme="matrix"] body {
    font-family: 'JetBrains Mono', monospace;
}

/* ===== HEADER ===== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 12px 16px;
    transition: all 0.3s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-icon {
    color: var(--accent);
    font-size: 1.6rem;
    animation: pulse 2s ease-in-out infinite;
}

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

.header-actions {
    display: flex;
    gap: 8px;
}

.theme-btn, .info-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 2px solid var(--card-border);
    background: var(--card-bg);
    color: var(--fg);
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover, .info-btn:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

.search-container {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 2px solid var(--card-border);
    background: var(--input-bg);
    color: var(--fg);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

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

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

/* ===== FILTER NAV ===== */
.filter-nav {
    padding: 12px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-nav::-webkit-scrollbar {
    display: none;
}

.filter-scroll {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 10px 18px;
    border-radius: 20px;
    border: 2px solid var(--card-border);
    background: var(--card-bg);
    color: var(--fg-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.filter-btn:active {
    transform: scale(0.95);
}

.filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* ===== STATS BAR ===== */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--card-border);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--fg-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    padding: 16px;
    min-height: calc(100vh - 200px);
}

.preparat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 480px) {
    .preparat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .preparat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .preparat-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===== PREPARAT CARD ===== */
.preparat-card {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.preparat-card:active {
    transform: scale(0.98);
}

.preparat-card:hover {
    border-color: var(--accent);
    box-shadow: 0 8px 24px var(--shadow);
}

.preparat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.preparat-card:hover::before {
    opacity: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.card-name {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.card-category {
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.card-category.laglig {
    background: rgba(5, 150, 105, 0.2);
    color: var(--legal);
}

.card-category.olaglig {
    background: rgba(220, 38, 38, 0.2);
    color: var(--illegal);
}

.card-category.receptbelagd {
    background: rgba(124, 58, 237, 0.2);
    color: var(--rx);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--fg-secondary);
    margin-bottom: 12px;
    font-style: italic;
}

.card-klass {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--bg);
    margin-bottom: 12px;
}

.card-klass.klass-a {
    color: var(--klass-a);
    border: 1px solid var(--klass-a);
}

.card-klass.klass-b {
    color: var(--klass-b);
    border: 1px solid var(--klass-b);
}

.card-klass.klass-c {
    color: var(--klass-c);
    border: 1px solid var(--klass-c);
}

.card-klass.oklassad {
    color: var(--fg-secondary);
    border: 1px solid var(--fg-secondary);
}

.card-dose {
    display: flex;
    gap: 6px;
    margin-top: auto;
}

.dose-tag {
    flex: 1;
    text-align: center;
    padding: 6px 4px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
}

.dose-tag.svag {
    background: rgba(16, 185, 129, 0.15);
    color: var(--positive);
}

.dose-tag.normal {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.dose-tag.stark {
    background: rgba(239, 68, 68, 0.15);
    color: var(--negative);
}

/* ===== THEME PANEL ===== */
.theme-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 24px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 200;
    max-height: 50vh;
    overflow-y: auto;
}

.theme-panel.active {
    transform: translateY(0);
}

.theme-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.theme-panel-header h2 {
    font-size: 1.2rem;
}

.close-panel {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg);
    color: var(--fg);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-panel:hover {
    background: var(--accent);
    color: white;
}

.theme-options {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

@media (max-width: 400px) {
    .theme-options {
        grid-template-columns: repeat(3, 1fr);
    }
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    border: 2px solid var(--card-border);
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-option:hover {
    border-color: var(--accent);
}

.theme-option.active {
    border-color: var(--accent);
    background: rgba(var(--accent), 0.1);
}

.theme-preview {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid transparent;
}

.light-preview { background: linear-gradient(135deg, #f8fafc, #2563eb); }
.dark-preview { background: linear-gradient(135deg, #0f172a, #3b82f6); }
.synthwave-preview { background: linear-gradient(135deg, #1a1033, #ff00ff); }
.matrix-preview { background: linear-gradient(135deg, #000000, #00ff00); }
.dracula-preview { background: linear-gradient(135deg, #282a36, #bd93f9); }

.theme-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--fg-secondary);
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow-y: auto;
    padding: 16px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--card-bg);
    border-radius: 20px;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--card-border);
    background: var(--bg);
    color: var(--fg);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: var(--negative);
    border-color: var(--negative);
    color: white;
}

.modal-content {
    padding: 24px;
}

.modal-header {
    margin-bottom: 24px;
    padding-right: 48px;
}

.modal-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-subtitle {
    font-size: 1rem;
    color: var(--fg-secondary);
    font-style: italic;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.modal-section {
    margin-bottom: 24px;
}

.modal-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-secondary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-section-title::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--accent);
    border-radius: 2px;
}

.dose-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg);
    border-radius: 12px;
    overflow: hidden;
}

.dose-table th,
.dose-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
}

.dose-table th {
    background: var(--card-bg);
    font-weight: 600;
    font-size: 0.85rem;
}

.dose-table tr:last-child td {
    border-bottom: none;
}

.effects-grid {
    display: grid;
    gap: 16px;
}

.effect-group {
    background: var(--bg);
    border-radius: 12px;
    padding: 16px;
}

.effect-group.positive {
    border-left: 4px solid var(--positive);
}

.effect-group.negative {
    border-left: 4px solid var(--negative);
}

.effect-title {
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.effect-title.positive { color: var(--positive); }
.effect-title.negative { color: var(--negative); }

.effect-list {
    list-style: none;
}

.effect-list li {
    padding: 6px 0;
    padding-left: 16px;
    position: relative;
    font-size: 0.9rem;
    color: var(--fg-secondary);
}

.effect-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--fg-secondary);
}

.warning-box {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--negative);
    border-radius: 12px;
    padding: 16px;
    color: var(--negative);
    font-weight: 600;
    text-align: center;
}

/* ===== INFO MODAL ===== */
.info-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-overlay.active {
    opacity: 1;
    visibility: visible;
}

.info-modal {
    background: var(--card-bg);
    border-radius: 20px;
    max-width: 400px;
    width: 100%;
    padding: 24px;
    position: relative;
}

.info-modal h2 {
    margin-bottom: 16px;
}

.info-modal p {
    margin-bottom: 12px;
    color: var(--fg-secondary);
}

.info-modal ul {
    margin-bottom: 16px;
    padding-left: 20px;
}

.info-modal li {
    margin-bottom: 8px;
    color: var(--fg-secondary);
}

.info-modal .warning {
    color: var(--negative);
    font-weight: 600;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.preparat-card {
    animation: fadeIn 0.4s ease forwards;
}

.preparat-card:nth-child(1) { animation-delay: 0.02s; }
.preparat-card:nth-child(2) { animation-delay: 0.04s; }
.preparat-card:nth-child(3) { animation-delay: 0.06s; }
.preparat-card:nth-child(4) { animation-delay: 0.08s; }
.preparat-card:nth-child(5) { animation-delay: 0.10s; }
.preparat-card:nth-child(6) { animation-delay: 0.12s; }
.preparat-card:nth-child(7) { animation-delay: 0.14s; }
.preparat-card:nth-child(8) { animation-delay: 0.16s; }

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ===== FOCUS STYLES ===== */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== MATRIX THEME SPECIAL ===== */
[data-theme="matrix"] .preparat-card {
    border-color: #003300;
}

[data-theme="matrix"] .preparat-card:hover {
    border-color: #00ff00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

[data-theme="matrix"] .logo-icon {
    text-shadow: 0 0 10px #00ff00;
}

/* ===== SYNTHWAVE THEME SPECIAL ===== */
[data-theme="synthwave"] .preparat-card {
    border-color: #4a2875;
}

[data-theme="synthwave"] .preparat-card:hover {
    border-color: #ff00ff;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.3);
}

[data-theme="synthwave"] .logo-icon {
    text-shadow: 0 0 10px #ff00ff;
    animation: none;
}

/* ===== DRACULA THEME SPECIAL ===== */
[data-theme="dracula"] .preparat-card:hover {
    border-color: var(--accent-hover);
}
