:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --accent-color: #8b5cf6;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow: hidden; /* Prevent body scroll, everything happens inside main */
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

#app-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    height: 100%;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.glass-header {
    background: var(--bg-color);
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.glass-footer {
    background: var(--bg-color);
    border-top: 1px solid var(--glass-border);
    padding: 1rem;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
button {
    font-family: var(--font-main);
    cursor: pointer;
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 9999px;
    font-size: 1.1rem;
    font-weight: 600;
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.icon-btn {
    background: transparent;
    color: var(--text-color);
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

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

.footer-actions {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
}

.btn-action {
    background: transparent;
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    transition: color 0.2s, transform 0.2s;
}

.btn-action:hover {
    color: white;
    transform: translateY(-2px);
}

.btn-highlight {
    color: var(--accent-color);
}

.btn-highlight:hover {
    color: #a78bfa;
}

/* Overlays (Welcome & Search) */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.welcome-content {
    padding: 3rem 2rem;
    border-radius: 24px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

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

.welcome-content h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome-content p {
    color: #94a3b8;
    line-height: 1.6;
}

.search-content {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    background: var(--bg-color);
    padding: 1.5rem;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.overlay.active .search-content {
    transform: translateX(0);
}

.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tags & Search Box */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tag-badge {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tag-badge:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
}

.search-box {
    position: relative;
}

#search-input {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

#search-input:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.autocomplete-list {
    list-style: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-top: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    z-index: 20;
    display: none;
}

.autocomplete-list.active {
    display: block;
}

.autocomplete-list li {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.autocomplete-list li:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Reader Area */
#reader-container {
    flex: 1;
    position: relative;
    padding-top: 65px; /* Header space */
    padding-bottom: 75px; /* Footer space */
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #ffffff; /* White background for the book extract readability */
}

/* Make iframe take full space but look nice */
#book-frame {
    flex: 1;
    width: 100%;
    max-width: 800px;
    border: none;
    background: transparent;
    opacity: 0;
    transition: opacity 0.5s;
}

/* Spinner */
.spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* For dark mode iframe content we might need to rely on the html files having their own styles or we can invert colors, 
   but since extracts usually have a white bg, keeping the reader container white and hiding the scrollbars behind footer is good. */
