/* --- General Setup & Variables --- */
:root {
    --primary-blue: #00427E;
    --light-blue-bg: #F5FAFF;
    --border-color: #E0E7F0;
    --text-primary: #1A202C;
    --text-secondary: #5A677D;
    --accent-orange: #F57F17;
    --sidebar-bg: #FFFFFF;
    --header-height: 70px;
    --sidebar-width: 280px; /* increased from 240px to make sidebar thicker */
    --light-gray-bg: #F8F9FA; /* new: default track/background used by the theme toggle */
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    background-color: var(--light-blue-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- Main Layout --- */
.site-wrapper {
    display: flex;
}

.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease-in-out;
}

main {
    padding: 0 30px;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* changed: keep logo + nav at the top */
    z-index: 200;
    transition: width 0.3s ease-in-out;
    overflow-x: hidden;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    height: 40px;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo img {
    height: 70px; /* reduce logo image height slightly so it doesn't push nav down */
}

.logo-icon {
    display: none;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Add a separator between the main nav and the browse nav */
.sidebar-nav ul:first-of-type {
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav .nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin: 10px 0 10px;
    white-space: nowrap;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 15px 12px;
    margin: 5px;
    border-radius: 15px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: background-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.sidebar-nav li a:hover {
    background-color: #F0F5FA;
}

.sidebar-nav li a i {
    flex-shrink: 0;
    width: 28px;
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-right: 10px;
    text-align: center;
}

.sidebar-nav li a.active {
    background-color: #EDF2F7;
    color: var(--primary-blue);
    font-weight: 700;
}

.sidebar-nav li a.active i {
    color: var(--primary-blue);
}

/* New: sidebar contact area */
.sidebar-contact {
    margin-top: auto; /* new: push contact to bottom while keeping nav at top */
    padding: 12px 10px;
    border-top: 1px solid var(--border-color);
    text-align: left;
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.sidebar-contact p {
    margin: 0 0 6px 0;
    font-weight: 600;
    color: var(--text-primary);
}
.sidebar-contact .contact-email {
    color: var(--primary-blue);
    font-weight: 600;
    word-break: break-all;
    display: inline-block;
}

/* --- Header --- */
.site-header {
    height: var(--header-height);
    background-color: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 20px;
}

.search-bar {
    position: relative;
    width: 100%; /* Allow search to be flexible */
    max-width: 400px; /* But not excessively wide */
}

.search-bar input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: #F8F9FA;
    font-size: 0.95rem;
}

.search-bar i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* --- Dropdown Menu Styles --- */
.header-right {
    display: flex;
    align-items: center;
    margin-left: auto; /* This pushes the dropdown to the far right */
}

.header-dropdown {
    position: relative;
}

.dropdown-toggle {
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 10px;
    transition: background-color 0.2s, border-color 0.2s;
}

.dropdown-toggle:hover {
    background-color: #F0F5FA;
    border-color: #C0D0E0;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 220px;
    z-index: 110;
    padding: 8px;
    box-sizing: border-box;
}

.header-dropdown.is-active .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: var(--text-primary);
    font-weight: 500;
    border-radius: 6px;
    transition: background-color 0.2s;
    margin-bottom: 2px;
}

.dropdown-item:hover {
    background-color: #F0F5FA;
}

.dropdown-item i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

/* --- Google Login Button Styling --- */
#googleLoginBtn {
    padding: 0 8px;
    margin-top: 5px;
}

#googleLoginBtn > div {
    border-radius: 6px !important;
    box-shadow: none !important;
    border: 1px solid var(--border-color) !important;
    transition: background-color 0.2s, border-color 0.2s;
}

#googleLoginBtn > div:hover {
    background-color: #F0F5FA !important;
    border-color: #C0D0E0 !important;
}

/* --- Notification Modal Styling --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(30, 40, 50, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #ffffff;
    margin: 15vh auto;
    padding: 25px 30px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.modal-content label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 1rem;
}

.modal-content input[type="checkbox"] {
    margin-right: 12px;
    width: 18px;
    height: 18px;
}

.modal-content #notificationStatus {
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.close {
    color: #9ab;
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    font-weight: bold;
    line-height: 1;
    transition: color 0.2s;
}

.close:hover,
.close:focus {
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
}


/* --- Homepage & Page Content --- */
.sponsored-banner {
    background-color: #FFF9E6;
    border: 1px solid #FFECB3;
    text-align: center;
    padding: 12px;
    margin: 20px 0;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.main-promo-banner img {
    width: 100%;
    border-radius: 12px;
    display: block;
}

.home-content-area {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
    margin-top: 30px;
}

.page-content-area {
    margin-top: 30px;
}

.page-title {
    font-size: 1.8rem;
    margin-bottom: 25px;
}

.shiurim-section {
    margin-bottom: 40px;
}

.shiurim-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.shiur-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

.shiur-card {
    background: none;
}

.shiur-card-image {
    position: relative;
    aspect-ratio: 16 / 9;
    background-color: #e0e0e0;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.shiur-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.shiur-card-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 5px 0;
    line-height: 1.4;
}

.shiur-card-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.right-column {
    padding-top: 65px;
}

.info-box {
    background-color: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.info-box h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.yahrzeits-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.yahrzeits-box li {
    padding: 8px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid #F0F5FA;
}

.yahrzeits-box li:last-child {
    border-bottom: none;
}

.newsletter-box input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-sizing: border-box;
    margin-bottom: 10px;
}

.newsletter-box p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

.loading-message,
.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.error-message {
    color: #e53e3e;
}

/* --- Speakers Page --- */
.speaker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 30px;
}

.speaker-card {
    background-color: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 25px 20px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.speaker-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 66, 126, 0.08);
}

.speaker-card img {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 15px;
    border: 3px solid #FFFFFF;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.speaker-card h3 {
    margin: 0 0 5px 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

.speaker-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* --- View Shiur Page --- */
.view-shiur-container {
    max-width: 900px;
    margin: 30px auto;
    background-color: #FFFFFF;
    padding: 30px 40px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.view-shiur-container h1 {
    font-size: 2.2rem;
    margin: 0 0 10px 0;
    color: var(--text-primary);
    line-height: 1.3;
}

.view-shiur-meta {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.view-shiur-meta span {
    margin-right: 20px;
}

#mediaPlayer {
    width: 100%;
    height: auto;
    background-color: #000;
    border-radius: 8px;
    margin-bottom: 30px;
    display: block;
}

.view-shiur-content h2 {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-top: 30px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.view-shiur-content p {
    line-height: 1.7;
    color: var(--text-primary);
}

.view-shiur-content pre {
    background-color: #F8F9FA;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    white-space: pre-wrap;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
    line-height: 1.6;
    color: var(--text-primary);
}


/* --- Responsive Design --- */
@media (max-width: 1200px) {
    .home-content-area {
        grid-template-columns: 1fr;
    }
    .right-column {
        padding-top: 0;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}

@media (max-width: 992px) {
    :root {
        --sidebar-width: 80px;
    }
    .sidebar {
        padding: 15px;
    }
    .logo-full {
        display: none;
    }
    .logo-icon {
        display: block;
    }
    .sidebar-logo {
        justify-content: center;
    }
    .sidebar .nav-text,
    .sidebar .nav-section-title {
        display: none;
    }
    .sidebar-nav li a {
        justify-content: center;
        padding: 12px;
    }
    .sidebar-nav li a i {
        margin-right: 0;
        font-size: 1.4rem;
    }
    .search-bar {
        flex-grow: 1; /* Allow search to take up available space */
    }
}

@media (max-width: 768px) {
    main,
    .site-header {
        padding: 0 15px;
    }
    .right-column {
        grid-template-columns: 1fr;
    }
    .shiur-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    .speaker-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 20px;
    }
    .speaker-card img {
        width: 100px;
        height: 100px;
    }
    .speaker-card h3 {
        font-size: 1rem;
    }
    .view-shiur-container {
        padding: 20px;
    }
    .view-shiur-container h1 {
        font-size: 1.5rem;
    }
}
/* --- Dropdown User Info Styling --- */
.user-info {
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 130px; /* Prevents long names from breaking layout */
}

/* --- Account Page Styling --- */
.account-card {
    background-color: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px 40px;
    max-width: 700px;
}

.account-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.account-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.account-header h2 {
    margin: 0 0 5px 0;
    font-size: 1.8rem;
    color: var(--text-primary);
}

.account-header p {
    margin: 0;
    font-size: 1rem;
    color: var(--text-secondary);
}

.account-actions {
    padding-top: 25px;
}

.sign-out-btn-main {
    background-color: #F8F9FA;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.sign-out-btn-main:hover {
    background-color: #F0F5FA;
    border-color: #C0D0E0;
}

.sign-out-btn-main i {
    margin-right: 8px;
}

.theme-toggle button {
    --size: 22px;
    appearance: none;
    border: 1px solid var(--border-color);
    border-radius: 99px;
    width: calc(var(--size) * 2);
    height: var(--size);
    position: relative;
    cursor: pointer;
    background-color: var(--light-gray-bg);
}
.theme-toggle .thumb {
    display: block;
    width: calc(var(--size) - 6px);
    height: calc(var(--size) - 6px);
    border-radius: 50%;
    background-color: var(--text-secondary);
    position: absolute;
    top: 2px;
    left: 3px;
    transition: transform 0.3s ease;
}
[data-theme="dark"] .theme-toggle .thumb {
    transform: translateX(calc(var(--size) - 2px));
}

/* Add dark theme variables and some overrides so toggling [data-theme="dark"] produces visible changes */
[data-theme="dark"] {
    /* Color variables for dark mode */
    --primary-blue: #66a3ff;
    --light-blue-bg: #071028;
    --border-color: #173047;
    --text-primary: #E6EEF8;
    --text-secondary: #9FB5CE;
    --accent-orange: #F57F17;
    --sidebar-bg: #0b1220;
    --light-gray-bg: #0f1724;
}

/* Override some components that used hardcoded white/bright backgrounds */
[data-theme="dark"] .site-header,
[data-theme="dark"] .sidebar,
[data-theme="dark"] .info-box,
[data-theme="dark"] .view-shiur-container,
[data-theme="dark"] .speaker-card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .dropdown-menu {
    background-color: var(--sidebar-bg);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* Smooth transitions for theme switching */
body,
.site-header,
.sidebar,
.info-box,
.view-shiur-container,
.modal-content,
.dropdown-menu {
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

/* --- Quiz Modal Styles --- */
body.quiz-active > *:not(#quiz-modal-backdrop) {
    display: none !important;
}

#quiz-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

#quiz-modal {
    background-color: white;
    padding: 30px 40px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-width: 500px;
    width: 90%;
}

#quiz-modal h2 {
    margin-top: 0;
    color: var(--primary-color);
    text-align: center;
}

#quiz-modal p {
    color: #555;
    margin-bottom: 25px;
    text-align: center;
}

.quiz-question {
    margin-bottom: 20px;
}

/* Using existing .input-group styles for consistency */
#quiz-modal .input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary-color);
}
#quiz-modal .input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
}

#quiz-modal button {
    display: block;
    width: 100%;
    padding: 15px;
    border: none;
    background-color: #13405f;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 10px;
}

#quiz-modal button:hover:not(:disabled) {
    background-color: #081c2b;
}

#quiz-modal button:disabled {
    background-color: #aaa;
    cursor: not-allowed;
}

.quiz-status-message {
    font-size: 0.9em;
    font-weight: 600;
    margin-top: 15px;
    min-height: 1.2em;
}

/* Make range scrubbers visible and styled (for thumbnail scrubbing controls) */
.thumbnail-scrubber {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--primary-blue) 50%, #e6eef8 50%, #e6eef8 100%);
    outline: none;
    margin: 8px 0;
    cursor: pointer;
}

/* Thumb */
.thumbnail-scrubber::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid var(--primary-blue);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.thumbnail-scrubber::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid var(--primary-blue);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Provide a simple background handling for Firefox (fill track) */
.thumbnail-scrubber::-moz-range-progress {
    background: var(--primary-blue);
    height: 8px;
    border-radius: 8px;
}

/* Account Page Styles */
.account-content {
    padding: 2rem;
}

.profile-info {
    background: var(--surface-color);
    border-radius: 8px;
    padding: 2rem;
    margin-top: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.profile-picture {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-details h2 {
    margin: 0;
    color: var(--text-color);
}

.profile-details p {
    margin: 0.5rem 0 0;
    color: var(--text-secondary);
}