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

:root {
    --primary-glow: #00d2ff;
    --secondary-glow: #3a7bd5;
    --accent-gold: #ffd700;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --sidebar-bg: rgba(15, 23, 42, 0.8);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', 'Heebo', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(0, 210, 255, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(58, 123, 213, 0.15) 0%, transparent 40%);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo-section {
    margin-bottom: 3rem;
    text-align: center;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-glow), var(--secondary-glow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.8rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 1rem 1.2rem;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 12px;
    transition: var(--transition);
    cursor: pointer;
    font-size: 1.1rem;
}

.nav-link:hover, .nav-link.active, .portion-link:hover, .portion-link.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(5px);
}

.sidebar-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 1.5rem 0;
}

.sidebar-label {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1rem;
    letter-spacing: 1px;
}

.portions-menu {
    overflow-y: auto;
    flex: 1;
    padding-right: 5px;
}

.portions-menu::-webkit-scrollbar {
    width: 4px;
}

.portions-menu::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 10px;
}

.portion-link {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
    cursor: pointer;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.nav-link i {
    margin-right: 12px;
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2.5rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.header-title h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.header-meta {
    text-align: right;
}

#jewish-date {
    color: var(--accent-gold);
    font-size: 1.2rem;
    font-weight: 600;
}

/* Horizontal Book Tabs */
.book-tabs-container {
    width: 100%;
    margin-bottom: 2rem;
    overflow: hidden;
}

.book-tabs-scroll {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 10px;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;
}

.book-tabs-scroll::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.book-tab-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    padding: 0.6rem 1.8rem;
    border-radius: 30px;
    font-size: 1.05rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
}

.book-tab-item.active {
    background: rgba(255, 215, 0, 0.15);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.book-tab-item:active {
    transform: scale(0.95);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 1.8rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.card:hover {
    transform: translateY(-10px);
    border-color: rgba(255, 215, 0, 0.3);
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    display: inline-block;
}

.card h3 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
    color: var(--accent-gold);
}

.card p {
    color: var(--text-dim);
    line-height: 1.6;
}

/* Active Portion Selector Mobile */
.active-portion-selector {
    display: none;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    padding: 1rem 1.5rem;
    border-radius: 20px;
    margin-bottom: 2rem;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: 700;
    transition: var(--transition);
}

.active-portion-selector:active {
    transform: scale(0.98);
}

/* Premium Badges */
.badge {
    background: rgba(255, 215, 0, 0.1);
    color: var(--accent-gold);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    margin-bottom: 1rem;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate {
    animation: fadeIn 0.8s ease forwards;
}

/* RTL Support for Hebrew */
[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: 280px;
}

[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
    border-right: none;
    border-left: 1px solid var(--glass-border);
}

@media (max-width: 768px) {
    [dir="rtl"] .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }
}

/* Bottom Navigation */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 75px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(25px);
    border-top: 1px solid var(--glass-border);
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1000;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-dim);
    font-size: 0.75rem;
    transition: var(--transition);
    cursor: pointer;
}

.bottom-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.bottom-nav-item.active {
    color: var(--primary-glow);
}

/* Overlays */
.overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 15, 24, 0.9);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center; /* Centered instead of flex-end */
    justify-content: center;
    padding: 1.5rem;
}

.overlay-content {
    background: var(--nav-bg);
    width: 100%;
    max-width: 500px;
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease-out forwards;
    max-height: 85vh; /* Ensure it stays fully visible */
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.book-btn {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 20px;
    text-align: center;
    color: var(--text-main);
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.book-btn:active {
    transform: scale(0.95);
    background: rgba(0, 210, 255, 0.1);
}

/* Lists and Overlays */
.books-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
}

.books-list .book-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    padding: 1rem 1.5rem;
    text-align: right;
    font-size: 1.2rem;
}

.close-overlay-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    width: auto;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    font-family: inherit;
}

.close-overlay-btn:active {
    background: rgba(255,255,255,0.1);
    transform: scale(0.95);
}

/* Header Back Button */
.back-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

.back-btn:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.9);
}

.portions-grid-overlay {
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 5px;
}

.portions-grid-overlay::-webkit-scrollbar {
    width: 4px;
}

.portions-grid-overlay::-webkit-scrollbar-thumb {
    background: var(--primary-glow);
    border-radius: 10px;
}

/* Responsiveness */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin: 0 !important; padding: 1.2rem; padding-bottom: 120px; width: 100vw; }
    header { flex-direction: column; align-items: center; text-align: center; gap: 0.8rem; margin-bottom: 2rem; }
    .header-meta { text-align: center; }
    .bottom-nav { display: flex; }
    .dashboard-grid { grid-template-columns: 1fr; gap: 1.5rem; width: 100%; }
    .header-title h1 { font-size: 1.6rem; }
    #jewish-date { font-size: 1rem; }
    .card { padding: 1.5rem; }
}
