/* ====================
   Global Styles
   ==================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    color: #1a1a1a;
    margin: 0;
    padding: 0;
    line-height: 1.8;
    opacity: 0;
    animation: fadeIn 0.4s ease-in forwards;
}

/* Page transition on exit */
body.page-exit {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

h1,
h2,
h3 {
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0d0d0d;
}

h1 {
    font-size: 2.5em;
    margin-bottom: 0.5em;
}

p {
    max-width: 700px;
    margin: 0 auto 1em;
}

/* ====================
   Navigation
   ==================== */
nav {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    padding: 15px 20px;
    margin-bottom: 0;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 100;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-links a {
    text-decoration: none;
    color: #1a1a1a;
    font-weight: 500;
    position: relative;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #1e73be;
}

.nav-links a:focus-visible {
    outline: 3px solid #1e73be;
    outline-offset: 4px;
    border-radius: 3px;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: #1e73be;
    transition: width 0.3s ease;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-links a.active {
    font-weight: 700;
    color: #1e73be;
}

.dark-mode-toggle {
    margin-left: 32px;
    margin-top: 0;
    padding: 10px;
    border-radius: 999px;
    border: 1px solid #cbd5e1;
    background: white;
    cursor: pointer;
    font-size: 1.1em;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: all 0.2s;
}

.dark-mode-toggle:hover {
    background: #e6f2ff;
    border-color: #1e73be;
}

.dark-mode-toggle:focus-visible {
    outline: 3px solid #1e73be;
    outline-offset: 2px;
}

/* ====================
   Breadcrumbs
   ==================== */
.breadcrumbs {
    background: #f8f9fa;
    padding: 12px 20px;
    font-size: 0.9em;
    color: #666;
    border-bottom: 1px solid #e2e8f0;
}

.breadcrumbs a {
    color: #1e73be;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumbs a:hover {
    color: #155a8a;
    text-decoration: underline;
}

.breadcrumbs span {
    color: #333;
    font-weight: 600;
}

/* ====================
   Hero Section
   ==================== */
.hero {
    background: white;
    border-top: 4px solid #1e73be;
    padding: 60px 20px;
    text-align: center;
    margin-bottom: 40px;
}

.hero .profile-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    border: 4px solid #1e73be;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.hero h1 {
    margin-bottom: 0.3em;
}

.hero p {
    font-size: 1.1em;
    color: #4a4a4a;
}

/* ====================
   Main Content
   ==================== */
main {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
}

section {
    margin-bottom: 40px;
    background: white;
    border-radius: 14px;
    padding: 32px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
}

section h2 {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* ====================
   Practice Helpers
   ==================== */
.test-ideas {
    margin-top: 24px;
    padding: 24px;
    border: 1px dashed #1e73be;
    border-radius: 14px;
    background: #f0f7ff;
}

.test-ideas h2 {
    margin-top: 0;
    font-size: 1.25em;
}

.test-ideas ul {
    margin: 0;
    padding-left: 20px;
    color: #1a1a1a;
}

.test-ideas li+li {
    margin-top: 8px;
}

.playwright-snippet {
    margin-top: 28px;
    padding: 24px;
    border-radius: 14px;
    background: #0d1117;
    color: #e6edf3;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
}

.playwright-snippet h2 {
    margin-top: 0;
    color: #58a6ff;
}

.playwright-snippet p {
    margin-bottom: 18px;
    color: #c9d1d9;
}

.playwright-snippet pre {
    margin: 0;
    padding: 16px;
    background: #161b22;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 0.95em;
}

.playwright-snippet code {
    font-family: 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    display: block;
    white-space: pre;
}

.todo-item.selected {
    background: #edf5ff;
    border-radius: 10px;
    outline: 2px solid #1e73be;
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin: 24px 0;
}

.link-grid a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border-radius: 12px;
    background: white;
    border: 1px solid #cbd5e1;
    text-decoration: none;
    color: #1e293b;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.link-grid a:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.12);
}

.not-found section {
    text-align: center;
}

.not-found section p {
    margin-left: auto;
    margin-right: auto;
}

/* ====================
   CTA Buttons
   ==================== */
.cta-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 30px 0;
    width: 100%;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

.cta-button.primary {
    background: #1e73be;
    color: white;
}

.logout-link {
    width: auto;
    align-self: flex-start;
    margin-top: 20px;
}

.cta-button.primary:hover {
    background: #155a8a;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(30, 115, 190, 0.3);
}

.cta-button.secondary {
    background: white;
    color: #1e73be;
    border: 2px solid #1e73be;
}

.cta-button.secondary:hover {
    background: #1e73be;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(30, 115, 190, 0.3);
}

.cta-icon {
    font-size: 1.2em;
}

/* ====================
   Book Section
   ==================== */
.book-section {
    margin: 40px 0;
    padding: 30px 0;
    border-top: 2px solid #e2e8f0;
}

.book-link {
    display: flex;
    gap: 25px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 20px;
    border-radius: 10px;
    transition: all 0.3s ease;
    background: white;
    border: 1px solid #e2e8f0;
}

.book-link:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

.book-cover {
    width: 140px;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.book-info {
    flex: 1;
}

.book-info h3 {
    margin-top: 0;
    color: #1e73be;
    font-size: 1.3em;
}

.book-info p {
    color: #4a4a4a;
    margin: 10px 0;
    max-width: 100%;
}

.book-intro {
    margin: 12px 0 8px;
    font-weight: 600;
    color: #1a1a1a;
}

.book-review {
    margin: 0;
    padding: 18px 20px;
    background: #fff7ed;
    border-left: 4px solid #f59e0b;
    border-radius: 10px;
    color: #3d3d3d;
}

.book-review p {
    margin: 0;
    font-style: italic;
    line-height: 1.6;
}

.book-rating {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    font-weight: 600;
    color: #b45309;
}

.book-rating-stars {
    font-size: 1.1em;
    letter-spacing: 2px;
    color: #f59e0b;
}

.book-rating-label {
    font-size: 0.95em;
}

.book-cta {
    display: inline-block;
    margin-top: 10px;
    color: #1e73be;
    font-weight: 600;
    transition: color 0.2s;
}

.book-link:hover .book-cta {
    color: #155a8a;
}

/* ====================
   Footer
   ==================== */
footer {
    margin-top: 60px;
    padding: 30px 20px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    color: #4a4a4a;
    font-size: 0.9em;
    background: white;
    line-height: 1.8;
}

footer a {
    color: #1e73be;
    text-decoration: none;
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

footer a:hover {
    background: #e6f2ff;
    text-decoration: underline;
}

footer a:focus-visible {
    outline: 3px solid #1e73be;
    outline-offset: 2px;
}

footer p {
    margin: 10px auto;
}

footer a:hover {
    text-decoration: underline;
}

footer .tagline {
    margin-top: 10px;
    color: #999;
    font-size: 0.85em;
}

/* ====================
   Forms & Inputs
   ==================== */
label {
    display: block;
    margin-top: 15px;
    margin-bottom: 6px;
    font-weight: 600;
    color: #1a1a1a;
    font-size: 0.95em;
}

input[type="text"],
input[type="password"],
input#todoText {
    display: block;
    width: 100%;
    max-width: 400px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.2s;
    box-sizing: border-box;
    margin-bottom: 15px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input#todoText:focus {
    outline: none;
    border-color: #1e73be;
    box-shadow: 0 0 0 3px rgba(30, 115, 190, 0.1);
}

.credentials-hint {
    background: #f0f9ff;
    border-left: 4px solid #1e73be;
    padding: 16px 20px;
    margin: 20px 0;
    border-radius: 10px;
    max-width: 400px;
}

.credentials-hint p {
    margin: 6px 0;
    font-size: 0.95em;
}

.credentials-hint strong {
    color: #1e73be;
}

.credentials-hint code {
    background: white;
    padding: 3px 8px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    color: #333;
    border: 1px solid #cbd5e1;
}

button {
    padding: 12px 24px;
    background: #1e73be;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    margin-top: 10px;
    position: relative;
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

button:hover:not(:disabled) {
    background: #155a8a;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(30, 115, 190, 0.2);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

button:focus-visible {
    outline: 3px solid rgba(30, 115, 190, 0.5);
    outline-offset: 2px;
}

.btn-spinner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-text[hidden],
.btn-spinner[hidden] {
    display: none !important;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

button.secondary {
    background: #e2e8f0;
    color: #333;
}

button.secondary:hover {
    background: #cbd5e1;
}

/* ====================
   Media
   ==================== */
iframe.video {
    width: 100%;
    max-width: 560px;
    height: 315px;
    display: block;
    margin: 30px auto;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ====================
   Todo List
   ==================== */
.todo-limits {
    color: #666;
    font-size: 0.9em;
    margin: 8px 0 18px;
}

#todo-error {
    color: #dc2626;
    padding: 12px 16px;
    margin: 15px 0;
    background: #fee2e2;
    border-radius: 10px;
    border-left: 4px solid #dc2626;
    max-width: 400px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
}

#todo-error[hidden] {
    display: none !important;
}

#todo-error .message {
    flex: 1;
}

#todo-error .alert-dismiss {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}

#todo-error .alert-dismiss:hover {
    background: rgba(220, 38, 38, 0.1);
}

#todo-error .alert-dismiss:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ====================
   Dark Mode
   ==================== */
body.dark-mode {
    background: #0f172a;
    color: #e2e8f0;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3 {
    color: #f8fafc;
}

body.dark-mode p,
body.dark-mode label {
    color: #cbd5f5;
}

body.dark-mode nav {
    background: rgba(15, 23, 42, 0.95);
    border-bottom-color: #1e293b;
}

body.dark-mode .nav-links a {
    color: #e2e8f0;
}

body.dark-mode .nav-links a:hover,
body.dark-mode .nav-links a.active {
    color: #4a9eff;
}

body.dark-mode .nav-links a::after {
    background: #4a9eff;
}

body.dark-mode .dark-mode-toggle {
    background: #1f2937;
    border-color: #334155;
    color: #e2e8f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

body.dark-mode .dark-mode-toggle:hover {
    background: #273449;
    border-color: #4a9eff;
}

body.dark-mode .hero,
body.dark-mode main section,
body.dark-mode footer,
body.dark-mode .book-link,
body.dark-mode .course-card,
body.dark-mode #todoList li {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #273449;
    box-shadow: 0 12px 24px rgba(2, 6, 23, 0.55);
}

body.dark-mode main {
    background: transparent;
}

body.dark-mode .course-card:hover {
    border-color: #4a9eff;
    box-shadow: 0 8px 18px rgba(24, 144, 255, 0.25);
}

body.dark-mode .book-info p {
    color: #cbd5f5;
}

body.dark-mode .book-intro {
    color: #e2e8f0;
}

body.dark-mode .book-review {
    background: rgba(251, 191, 36, 0.12);
    border-left-color: #f59e0b;
    color: #f8fafc;
}

body.dark-mode .book-rating {
    color: #fbbf24;
}

body.dark-mode .book-rating-stars {
    color: #facc15;
}

body.dark-mode .book-rating-label {
    color: #fbbf24;
}

body.dark-mode .cta-button.primary {
    background: #2563eb;
}

body.dark-mode .cta-button.primary:hover {
    background: #1d4ed8;
}

body.dark-mode .cta-button.secondary {
    background: #1e293b;
    color: #4a9eff;
    border-color: #4a9eff;
}

body.dark-mode .cta-button.secondary:hover {
    background: #4a9eff;
    color: #0f172a;
}

body.dark-mode .test-ideas {
    background: #13213a;
    border-color: rgba(148, 163, 184, 0.45);
    color: #e2e8f0;
}

body.dark-mode .test-ideas h2 {
    color: #e54175;
}

body.dark-mode .test-ideas ul {
    color: #dbeafe;
}

body.dark-mode input[type="text"],
body.dark-mode input[type="password"],
body.dark-mode input#todoText {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #334155;
}

body.dark-mode input[type="text"]:focus,
body.dark-mode input[type="password"]:focus,
body.dark-mode input#todoText:focus {
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.3);
    border-color: #4a9eff;
}

body.dark-mode button:not(.dark-mode-toggle) {
    background: #2563eb;
}

body.dark-mode button:not(.dark-mode-toggle):hover:not(:disabled) {
    background: #1d4ed8;
    box-shadow: 0 6px 12px rgba(37, 99, 235, 0.35);
}

body.dark-mode footer {
    color: #cbd5f5;
    border-top-color: #1e293b;
}

body.dark-mode footer a {
    color: #4a9eff;
}

body.dark-mode footer a:hover {
    background: rgba(74, 158, 255, 0.15);
}

body.dark-mode #todoList li.completed {
    background: #064e3b;
    border-color: #22c55e;
}

body.dark-mode .done {
    color: #4ade80;
}

body.dark-mode .task-text {
    color: #e2e8f0;
}

body.dark-mode #todo-error {
    background: #991b1b;
    border-left-color: #fca5a5;
    color: #fee2e2;
}

body.dark-mode #todo-error .alert-dismiss:hover {
    background: rgba(252, 165, 165, 0.2);
}

body.dark-mode .credentials-hint {
    background: #1e293b;
    border-left-color: #4a9eff;
    color: #cbd5f5;
}

body.dark-mode .credentials-hint code {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.dark-mode .breadcrumbs {
    background: #1e293b;
    border-bottom-color: #273449;
}

#todoList {
    list-style: none;
    padding: 0;
}

#todoList li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 10px 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

#todoList li:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

#todoList li.completed {
    background: #f0fdf4;
    border-color: #22c55e;
}

.task-text {
    flex: 1;
    display: block;
    margin-right: 12px;
    overflow-wrap: anywhere;
}

.done {
    text-decoration: line-through;
    color: #047857;
    font-weight: 500;
}

#todoList input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin-right: 0;
    accent-color: #22c55e;
    flex-shrink: 0;
}

#todoList button {
    margin-left: auto;
    margin-top: 0;
    padding: 6px 12px;
    font-size: 0.9em;
}

#addTodo {
    margin-left: 0;
    margin-top: 10px;
}

#login-error {
    color: #dc2626;
    padding: 12px;
    margin-bottom: 15px;
    background: #fee2e2;
    border-radius: 10px;
    border-left: 4px solid #dc2626;
}

/* ====================
   Courses Grid
   ==================== */
.courses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.course-card {
    background: white;
    padding: 24px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.3s;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    border-color: #1e73be;
}

.course-card h3 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #0d0d0d;
    font-size: 1.15em;
    line-height: 1.4;
}

.course-card p {
    color: #4a4a4a;
    font-size: 0.95em;
    margin: 0;
    line-height: 1.6;
}

.course-card a {
    color: #1e73be;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.course-card a:hover {
    color: #155a8a;
    text-decoration: underline;
}

.course-card a:focus-visible {
    outline: 3px solid #1e73be;
    outline-offset: 2px;
    border-radius: 3px;
}

/* ====================
   Responsive
   ==================== */
@media (max-width: 768px) {
    .hero {
        padding: 40px 20px;
    }

    nav {
        font-size: 0.9em;
        padding: 12px 10px;
        gap: 12px;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px;
    }

    .nav-links a {
        font-size: 0.9em;
    }

    .dark-mode-toggle {
        margin-left: 0;
    }

    .cta-buttons {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        margin: 30px 0;
    }

    .cta-button {
        justify-content: center;
        width: 100%;
    }

    .logout-link {
        width: auto;
        align-self: flex-start;
    }

    .book-link {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .book-cover {
        width: 180px;
    }

    .courses-grid {
        grid-template-columns: 1fr;
    }

    .breadcrumbs {
        font-size: 0.85em;
        padding: 10px 15px;
    }
}