@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --sidebar-bg: #ffffff;
    --success: #10b981;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; -webkit-tap-highlight-color: transparent; }
body { background-color: var(--bg-color); color: var(--text-color); line-height: 1.6; transition: background-color 0.3s ease; }

@keyframes slideUpFade { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fillProgress { from { width: 0; } }

/* Nowa animacja dla rozwijanych opracowań */
@keyframes fadeInAnswer {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   1. WSPÓLNE KOMPONENTY (Przyciski, Formularze)
========================================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; border-radius: 12px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); font-size: 1rem; text-decoration: none;}
.btn-primary { background: linear-gradient(135deg, var(--primary-color), var(--primary-hover)); color: white; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35); }
.btn-primary:active { transform: scale(0.98); }
.btn-outline { background: transparent; border: 2px solid var(--border-color); color: var(--text-color); }
.btn-outline:hover { border-color: var(--primary-color); color: var(--primary-color); background: rgba(99, 102, 241, 0.05); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: white; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2); }
.btn-success:active { transform: scale(0.98); }
.btn-block { width: 100%; }

.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text-color); font-size: 0.9rem; }
.form-group input, .form-group textarea { width: 100%; padding: 14px 16px; border: 2px solid var(--border-color); border-radius: 12px; background: var(--bg-color); color: var(--text-color); font-size: 1rem; transition: all 0.2s; font-family: 'Inter', sans-serif; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15); background: var(--card-bg); }
.alert { padding: 14px 20px; border-radius: 12px; margin-bottom: 24px; font-weight: 500; font-size: 0.95rem; text-align: center; }
.alert-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #059669; border: 1px solid #a7f3d0; }

/* =========================================
   2. STRONA GŁÓWNA (Landing Page)
========================================= */
.landing-page { min-height: 100vh; display: flex; flex-direction: column; background: #ffffff; background-image: radial-gradient(rgba(99, 102, 241, 0.05) 1px, transparent 1px); background-size: 20px 20px; }
.navbar { display: flex; justify-content: space-between; align-items: center; padding: 20px 5%; background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid rgba(0,0,0,0.05); }
.logo { font-size: 1.5rem; font-weight: 900; color: var(--text-color); text-decoration: none; letter-spacing: -0.5px; display: flex; align-items: center; gap: 5px;}
.logo span { color: var(--primary-color); }
.nav-links { display: flex; gap: 15px; }

.hero { flex: 1; display: flex; justify-content: center; align-items: center; text-align: center; padding: 80px 20px; }
.hero-content { max-width: 800px; animation: slideUpFade 0.6s ease-out; }
.hero h1 { font-size: clamp(2.5rem, 8vw, 4.5rem); font-weight: 900; line-height: 1.1; margin-bottom: 24px; letter-spacing: -1.5px; color: var(--text-color); }
.highlight { background: linear-gradient(135deg, var(--primary-color), #a855f7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { font-size: clamp(1.1rem, 3vw, 1.3rem); color: var(--text-muted); margin-bottom: 40px; max-width: 600px; margin-inline: auto; line-height: 1.6; }
.hero-buttons { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; }
.hero-buttons .btn { min-width: 180px; padding: 16px 24px; font-size: 1.1rem; border-radius: 14px;}

/* =========================================
   3. LOGOWANIE I REJESTRACJA
========================================= */
.auth-page { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%); padding: 20px; }
.auth-card { background: var(--card-bg); padding: 45px 40px; border-radius: 24px; box-shadow: var(--shadow-lg); width: 100%; max-width: 440px; text-align: center; animation: slideUpFade 0.5s ease-out; border: 1px solid rgba(255,255,255,0.5); }
.auth-card h2 { font-size: 2.2rem; font-weight: 800; margin-bottom: 5px; color: var(--text-color); letter-spacing: -1px; }
.auth-card p.subtitle { color: var(--text-muted); margin-bottom: 30px; font-size: 0.95rem; }
.auth-link { margin-top: 30px; font-size: 0.95rem; color: var(--text-muted); }
.auth-link a { color: var(--primary-color); font-weight: 700; text-decoration: none; transition: color 0.2s; }
.auth-link a:hover { color: var(--primary-hover); text-decoration: underline; }

/* =========================================
   4. DASHBOARD I APLIKACJA
========================================= */
.dashboard-body { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 280px; background: var(--sidebar-bg); padding: 30px 20px; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; z-index: 10; box-shadow: var(--shadow-sm); }
.sidebar h2 { color: var(--primary-color); margin-bottom: 40px; font-size: 1.8rem; font-weight: 800; text-align: center; letter-spacing: -0.5px;}
.sidebar ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 14px 18px; text-decoration: none; color: var(--text-muted); border-radius: 12px; font-weight: 600; transition: all 0.2s ease; }
.sidebar a:hover { background: var(--bg-color); color: var(--primary-color); }
.sidebar a.active { background: var(--primary-color); color: white; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }

.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; width: 100%; background: var(--sidebar-bg); border-top: 1px solid var(--border-color); z-index: 100; padding: 10px 15px; padding-bottom: max(10px, env(safe-area-inset-bottom)); box-shadow: 0 -4px 15px rgba(0,0,0,0.05); justify-content: space-around; align-items: center; }
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); text-decoration: none; font-size: 0.75rem; font-weight: 600; gap: 4px; padding: 8px; border-radius: 10px; transition: all 0.2s; flex: 1; }
.bottom-nav a.active { color: var(--primary-color); background: rgba(99, 102, 241, 0.1); }

.content { flex: 1; padding: 40px 50px; overflow-y: auto; scroll-behavior: smooth; padding-bottom: 100px; }
.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }
.tab-content { display: none; animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.tab-content.active { display: block; }

header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; gap: 20px; flex-wrap: wrap; }
header h1 { font-size: 2rem; font-weight: 800; color: var(--text-color); letter-spacing: -0.5px; line-height: 1.2; }
.countdown { background: var(--card-bg); padding: 12px 20px; border-radius: 14px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); font-weight: 600; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.countdown strong { color: var(--primary-color); font-size: 1.2rem; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 40px; }
.stat-card { background: var(--card-bg); padding: 25px; border-radius: 20px; border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); transition: transform 0.3s ease; }
.stat-card h3 { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.big-number { font-size: 2.8rem; font-weight: 800; background: linear-gradient(135deg, var(--primary-color), #a855f7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; line-height: 1.1; }

.progress-bar-container { width: 100%; height: 10px; background: #e2e8f0; border-radius: 10px; margin: 15px 0; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary-color), #a855f7); border-radius: 10px; animation: fillProgress 1s ease-out forwards; }

.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 40px; }
.chart-container { background: var(--card-bg); padding: 20px; border-radius: 20px; border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); width: 100%; overflow: hidden; }

.filters-container { display: flex; gap: 15px; margin-bottom: 25px; background: var(--card-bg); padding: 20px; border-radius: 16px; border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); flex-wrap: wrap; align-items: center; }
.filter-group { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.filter-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.filter-select { appearance: none; width: 100%; padding: 14px 40px 14px 16px; border: 2px solid var(--border-color); border-radius: 12px; background-color: var(--bg-color); color: var(--text-color); font-size: 1rem; font-weight: 500; cursor: pointer; transition: all 0.2s; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.filter-select:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }

/* =========================================
   KARTY PYTAŃ I DŁUGIE OPRACOWANIA
========================================= */
.questions-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.question-card { background: var(--card-bg); padding: 25px; border-radius: 20px; border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; transition: border-color 0.2s; }
.learned-card { border-color: var(--success); background: rgba(16, 185, 129, 0.02); }
.badge { display: inline-block; padding: 6px 12px; border-radius: 8px; font-size: 0.75rem; font-weight: 700; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; width: fit-content; }
.badge-epoch { background: rgba(99, 102, 241, 0.1); color: var(--primary-color); }
.question-card h4 { font-size: 1.15rem; margin-bottom: 8px; color: var(--text-color); line-height: 1.4; font-weight: 700; }
.lit-title { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; font-weight: 500; }

.btn-toggle-answer { background: var(--bg-color); border: 1px solid var(--border-color); color: var(--text-color); width: 100%; padding: 12px; border-radius: 10px; font-weight: 600; cursor: pointer; text-align: left; display: flex; justify-content: space-between; align-items: center; transition: background 0.2s; }
.btn-toggle-answer:hover { background: #e2e8f0; }

/* KLUCZOWA POPRAWKA DLA DŁUGICH TEKSTÓW */
.answer-box { 
    display: none; 
    margin-top: 15px; 
    padding: 20px; 
    background: var(--bg-color); 
    border-radius: 12px; 
    font-size: 0.95rem; 
    color: var(--text-color); 
    border-left: 4px solid var(--primary-color); 
    line-height: 1.7; 
}
.answer-box.show { 
    display: block; 
    animation: fadeInAnswer 0.3s ease-out forwards;
    max-height: 350px; /* Określa maksymalną wysokość na komputerach i telefonach */
    overflow-y: auto;  /* Pasek przewijania pojawi się tylko, gdy tekst przerośnie 350px */
}

/* Własny wygląd paska przewijania wewnątrz opracowania */
.answer-box::-webkit-scrollbar { width: 6px; }
.answer-box::-webkit-scrollbar-track { background: transparent; }
.answer-box::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }

.card-actions { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 10px; }

.flashcard-container { perspective: 1200px; display: flex; flex-direction: column; align-items: center; margin-top: 20px; width: 100%; }
.flashcard { width: 100%; max-width: 500px; height: 380px; position: relative; transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); transform-style: preserve-3d; cursor: pointer; }
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard .front, .flashcard .back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; background: var(--card-bg); border: 2px solid var(--border-color); border-radius: 24px; box-shadow: var(--shadow-md); }
.flashcard .front { font-size: 1.4rem; font-weight: 700; color: var(--text-color); }
.flashcard .back { transform: rotateY(180deg); font-size: 1.05rem; color: var(--text-color); overflow-y: auto; text-align: left; align-items: flex-start; justify-content: flex-start; }

/* =========================================
   5. MEDIA QUERIES (Mobile)
========================================= */
@media (max-width: 1024px) {
    .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .nav-links .btn { padding: 10px 16px; font-size: 0.9rem; }
    
    .dashboard-body { flex-direction: column; }
    .sidebar { display: none; }
    .bottom-nav { display: flex; }
    .content { padding: 25px 20px; padding-bottom: 100px; }
    header { flex-direction: column; gap: 15px; }
    header h1 { font-size: 1.8rem; }
    .countdown { width: 100%; justify-content: center; }
    .filter-group { min-width: 100%; }
    .btn-reset { margin-top: 10px; width: 100%; }
    .questions-list { grid-template-columns: 1fr; }
    .flashcard { height: 450px; }
}