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

body {
    font-family: 'Nata Sans', sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.upgrade-banner {
    background: linear-gradient(135deg, #5d4037 0%, #6d4c41 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(93, 64, 55, 0.2);
}

.btn-upgrade {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 25px;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.btn-upgrade:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Upload Section */
.upload-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    max-width: 50%;
    transition: all 0.3s ease;
}

.upload-section.processing {
    max-width: 100%;
}

.upload-section h2 {
    color: #5d4037;
    margin-bottom: 10px;
    font-size: 1.8rem;
    font-weight: 600;
}

.upload-section p {
    color: #666;
    margin-bottom: 20px;
}

/* Book info section with cover images */
.book-info-content {
    display: flex;
    align-items: center;
    gap: 25px;
}

.book-covers-stack {
    position: relative;
    height: 120px;
    min-width: 120px;
    display: flex;
    align-items: center;
}

.book-cover-image {
    position: absolute;
    height: 120px;
    width: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid #fff;
}

/* Stack multiple book covers with overlap */
.book-cover-image:nth-child(1) {
    left: 0;
    z-index: 3;
}

.book-cover-image:nth-child(2) {
    left: 30px;
    z-index: 2;
}

.book-cover-image:nth-child(3) {
    left: 60px;
    z-index: 1;
}

.book-cover-image:nth-child(4) {
    left: 90px;
    z-index: 0;
}

/* Hover effect - lift on hover */
.book-cover-image:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    z-index: 10 !important;
}

/* Adjust container width based on number of books */
.book-covers-stack:has(.book-cover-image:nth-child(2)) {
    min-width: 150px;
}

.book-covers-stack:has(.book-cover-image:nth-child(3)) {
    min-width: 180px;
}

.book-covers-stack:has(.book-cover-image:nth-child(4)) {
    min-width: 210px;
}

.book-info-text {
    flex: 1;
}

.book-info-text h2 {
    margin-bottom: 10px;
}

.book-info-text p {
    margin-bottom: 0;
}

.upload-box {
    border: 3px dashed #ddd;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.upload-box:hover {
    border-color: #5d4037;
    background-color: #f9f7f6;
    transform: translateY(-2px);
}

.upload-box.dragover {
    border-color: #5d4037;
    background-color: #f0ebe9;
    transform: scale(1.02);
}

.upload-box input[type="file"] {
    display: none;
}

.upload-label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: #666;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.upload-label:hover {
    color: #5d4037;
}

.upload-label i {
    font-size: 3rem;
    color: #5d4037;
    opacity: 0.7;
}

.sample-upload-container {
    display: none;
    animation: slideDown 0.3s ease-out;
}

.sample-upload-container.show {
    display: block;
}

.add-sample-btn {
    background: transparent;
    border: 2px dashed #ccc;
    color: #666;
    padding: 15px 20px;
    border-radius: 10px;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.add-sample-btn:hover {
    border-color: #5d4037;
    color: #5d4037;
    background-color: #f9f7f6;
}

.btn-upload {
    background: linear-gradient(135deg, #5d4037 0%, #6d4c41 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px auto 0;
    box-shadow: 0 4px 15px rgba(93, 64, 55, 0.3);
}

.btn-upload:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(93, 64, 55, 0.4);
}

.btn-upload:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.spinner {
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        max-height: 500px;
        transform: translateY(0);
    }
}

/* Main Content Area */
.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    display: none;
}

.main-content.show {
    display: grid;
}

@media (min-width: 768px) {
    .main-content.show {
        grid-template-columns: 350px 1fr;
    }
}

/* Chapter Selection */
.chapter-panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

.chapter-panel h3 {
    color: #5d4037;
    margin-bottom: 20px;
    font-size: 1.4rem;
    font-weight: 600;
}

.select-all-container {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.form-check-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #5d4037;
}

.form-check-label {
    cursor: pointer;
    font-weight: 500;
    color: #333;
}

.chapter-list {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.chapter-list::-webkit-scrollbar {
    width: 6px;
}

.chapter-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chapter-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chapter-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* New multi-book vertical layout */
.chapter-list-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 600px;
    /* Default, will be overridden by JS */
    overflow-y: auto;
    padding-right: 5px;
    transition: max-height 0.3s ease;
}

.chapter-list-container::-webkit-scrollbar {
    width: 6px;
}

.chapter-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chapter-list-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chapter-list-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Per-book chapter list with dynamic height */
.book-chapter-list {
    overflow-y: auto;
    padding-right: 8px;
    padding-left: 5px;
}

.book-chapter-list::-webkit-scrollbar {
    width: 5px;
}

.book-chapter-list::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 3px;
}

.book-chapter-list::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 3px;
}

.book-chapter-list::-webkit-scrollbar-thumb:hover {
    background: #868e96;
}

/* Book-level select all styling */
.book-select-all {
    background: #e9ecef;
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 6px;
}

.book-select-all .form-check-label {
    font-size: 0.9rem;
    color: #495057;
}

.part-name {
    font-weight: bold;
    color: #5d4037;
    margin: 15px 0 10px 0;
    font-size: 1.1rem;
    padding-bottom: 5px;
    border-bottom: 2px solid #f0f0f0;
}

/* Control Panel */
.control-panel {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.control-panel h3 {
    color: #5d4037;
    margin-bottom: 25px;
    font-size: 1.4rem;
    font-weight: 600;
}

.question-types-grid {
    display: grid;
    gap: 20px;
}

.question-type-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.question-type-card.active {
    border-color: #5d4037;
    background: #f9f7f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(93, 64, 55, 0.1);
}

.question-type-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.question-type-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #333;
}

.question-count-badge {
    background: #5d4037;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
}

.slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    transition: background 0.3s ease;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #5d4037;
    cursor: pointer;
    transition: all 0.3s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 8px rgba(93, 64, 55, 0.1);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #5d4037;
    cursor: pointer;
    border: none;
}

.slider-value {
    font-weight: 600;
    color: #5d4037;
    min-width: 30px;
    text-align: center;
}

.generation-options {
    border-top: 2px solid #f0f0f0;
    padding-top: 25px;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
}

.form-select {
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.form-select:focus {
    outline: none;
    border-color: #5d4037;
    box-shadow: 0 0 0 3px rgba(93, 64, 55, 0.1);
}

.btn-generate {
    background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.btn-generate:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-generate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Editor Section */
.editor-section {
    grid-column: 1 / -1;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    display: none;
}

.editor-section.show {
    display: block;
}

/* Reference Section */
.reference-section {
    display: none;
    /* Hidden by default */
    margin-top: 40px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.reference-section h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

/* Paper heading in reference section */
.paper-heading {
    color: #3e2723;
    background: linear-gradient(135deg, #d7ccc8 0%, #bcaaa4 100%);
    padding: 10px 15px;
    border-radius: 8px;
    margin: 25px 0 15px 0;
    font-size: 1.3rem;
    font-weight: 600;
    border-left: 5px solid #5d4037;
}

.reference-type-group {
    margin-bottom: 20px;
}

.reference-type-group h2 {
    color: #5d4037;
    border-bottom: 2px solid #d7ccc8;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.reference-type-group h3 {
    color: #5d4037;
    border-bottom: 2px solid #d7ccc8;
    padding-bottom: 5px;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.reference-item {
    margin-bottom: 15px;
    padding-left: 10px;
    border-left: 3px solid #bcaaa4;
}

.reference-item p {
    margin: 5px 0;
}

.ref-question strong {
    color: #3e2723;
}

.ref-answer {
    color: #28a745;
    font-weight: bold;
}

.ref-source {
    font-size: 0.9em;
    color: #666;
}

.ref-clue {
    font-size: 0.9em;
    color: #888;
    font-style: italic;
}

/* Reference Image Styling */
.ref-image-wrapper {
    max-height: 70px;
    max-width: 640px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 10px;
    transition: max-height 0.3s ease;
}

.ref-image-wrapper.expanded {
    max-height: none;
}

.ref-overlay-text {
    position: absolute;
    top: 15px;
    right: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 4px;
    border-radius: 4px;
    max-width: 400px;
    font-size: 0.5em;
    color: #333;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(2px);
    text-align: right;
}

.ref-image-wrapper::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.9));
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.ref-image-wrapper.expanded::after {
    opacity: 0;
}

.ref-image {
    width: 100%;
    display: block;
    height: auto;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.editor-title {
    color: #5d4037;
    font-size: 1.4rem;
    font-weight: 600;
}

.editor-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-action {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-action.btn-primary {
    background: #5d4037;
    color: white;
}

.btn-action.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-action.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

#editor {
    min-height: 500px;
    border: 2px solid #f0f0f0;
    border-radius: 8px;
}

/* Alert Messages */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-info {
    background: #e3f2fd;
    color: #0277bd;
    border-left: 4px solid #2196f3;
}

.alert-danger {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #f44336;
}

.alert-success {
    background: #e8f5e8;
    color: #2e7d32;
    border-left: 4px solid #4caf50;
}

/* Placeholder text */
.placeholder-text {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 40px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px dashed #ddd;
}

/* Mobile Responsiveness */
@media (max-width: 767px) {
    .upload-section {
        max-width: 100%;
        padding: 20px;
    }

    .book-info-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .book-covers-stack {
        align-self: center;
    }

    .book-info-text {
        width: 100%;
        text-align: center;
    }

    .book-title-thumbnail {
        height: 40px;
    }

    .book-title-text {
        font-size: 0.85rem;
    }

    .book-select-all-label {
        font-size: 0.75rem;
    }

    .upgrade-banner {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .main-content {
        gap: 20px;
    }

    .chapter-panel,
    .control-panel {
        padding: 20px;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .editor-actions {
        justify-content: center;
    }
}

/* Hide processed upload section */
.upload-section.hidden {
    display: none;
}

/* Nudge Section */
.nudge-section {
    font-size: 0.9em;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    margin-top: 30px;
    display: none;
    /* Hidden by default, shown by JS */
}

.nudge-section.show {
    display: block;
}

.nudge-suggestions-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.nudge-suggestion {
    background: #f1f3f5;
    padding: 6px 12px;
    /* Reduced top/bottom padding */
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76em;
    /* Reduced font size */
    cursor: default;
    transition: opacity 0.3s ease;
    opacity: 1;
}

.nudge-suggestion.fading-out {
    opacity: 0;
}

.nudge-suggestion.fading-in {
    opacity: 0;
}

.nudge-text {
    color: #495057;
}

.nudge-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    padding: 2px;
    line-height: 1;
}

.nudge-accept {
    color: #20c997;
    /* Lighter green */
}

.nudge-reject {
    color: #800080;
    /* Purple */
}

.nudge-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.custom-nudge-input {
    flex-grow: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.7em;
    /* 30% smaller font */
    height: 26px;
    /* 30% smaller height */
}

.btn-gpay-style {
    background-color: transparent;
    border: 1px solid #5d4037;
    color: #5d4037;
    border-radius: 20px;
    font-weight: 600;
    padding: 0 20px;
}

.btn-gpay-style:hover {
    background-color: #f9f7f6;
}

.applied-nudges-area {
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
}

.applied-nudge {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 8px 12px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-right: 8px;
    margin-bottom: 8px;
    font-weight: 500;
}

.remove-nudge-btn {
    background: none;
    border: none;
    color: #800080;
    /* Purple */
    cursor: pointer;
    font-weight: bold;
}

/* Styles for Multi-Book and Segmented Layout */
.book-section {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 15px;
    transition: box-shadow 0.2s ease;
}

.book-section:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.book-section:last-child {
    margin-bottom: 0;
}

/* Book title header - single row layout with tall thumbnail */
.book-title-header {
    margin-bottom: 12px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #5d4037 0%, #795548 100%);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(93, 64, 55, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
}

/* Thumbnail on left - tall to fill pane height */
.book-title-thumbnail {
    height: 48px;
    width: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* Container for book name and select all on right */
.book-title-row {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}

/* Book name text */
.book-title-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

/* Select all checkbox row */
.book-select-all-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.book-select-all-row .form-check-input {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background-color: rgba(255, 255, 255, 0.2);
    margin: 0;
}

.book-select-all-label {
    font-size: 0.8rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    margin: 0;
    user-select: none;
}

.segment-header {
    font-weight: 600;
    color: #6c757d;
    margin-top: 15px;
    margin-bottom: 10px;
    padding-left: 10px;
    font-size: 0.95rem;
}

.book-separator {
    height: 1px;
    background-color: #e9ecef;
    margin: 25px 0;
}

/* Progress Bar Styles */
.progress-container {
    background: #fff;
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.progress-header h3 {
    color: #5d4037;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.progress-eta {
    color: #666;
    font-size: 0.9rem;
    font-weight: 400;
}

#eta-value {
    font-weight: 600;
    color: #5d4037;
    font-family: 'Courier New', Courier, monospace;
    display: inline-block;
    min-width: 60px;
    text-align: left;
}

.progress-bar-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.progress-bar {
    flex: 1;
    height: 40px;
    background: #f0f0f0;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 20px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.progress-fill.overtime {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

.progress-percent {
    font-weight: 700;
    color: #5d4037;
    font-size: 1.1rem;
    font-family: 'Courier New', Courier, monospace;
    display: inline-block;
    min-width: 50px;
    text-align: right;
}

.progress-message {
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    font-weight: 300;
    min-height: 20px;
    transition: opacity 0.3s ease;
}

/* Mobile responsiveness for progress bar */
@media (max-width: 767px) {
    .progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .progress-bar-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .progress-bar {
        width: 100%;
    }

    .progress-percent {
        align-self: flex-end;
    }
}

/* Authentication Message */
.auth-message {
    background: linear-gradient(135deg, #1865f2 0%, #1557d6 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(24, 101, 242, 0.2);
    animation: slideIn 0.3s ease-out;
}

.auth-message-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.auth-message-content i {
    font-size: 20px;
    opacity: 0.9;
}

.auth-message-content span {
    flex: 1;
    min-width: 200px;
    font-size: 16px;
}

.btn-auth-login {
    background-color: white;
    color: #1865f2;
    padding: 10px 25px;
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: all 0.3s ease;
    display: inline-block;
    border: 2px solid white;
}

.btn-auth-login:hover {
    background-color: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments for auth message */
@media (max-width: 768px) {
    .auth-message-content {
        flex-direction: column;
        text-align: center;
    }

    .auth-message-content span {
        min-width: 100%;
    }
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.3s ease-out;
    border-left: 4px solid #dc3545;
}

.toast.success {
    border-left-color: #28a745;
}

.toast.info {
    border-left-color: #1865f2;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: #28a745;
}

.toast.info .toast-icon {
    color: #1865f2;
}

.toast.warning .toast-icon {
    color: #ffc107;
}

.toast.error .toast-icon {
    color: #dc3545;
}

.toast-content {
    flex: 1;
    color: #333;
    font-size: 14px;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.toast-close:hover {
    color: #333;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast.removing {
    animation: toastSlideOut 0.3s ease-out forwards;
}

@media (max-width: 768px) {
    .toast-container {
        top: 70px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Homepage specific styles */
.home-subjects-section {
    padding: 40px 0;
    background-color: #fff;
}

.home-container {
    width: 80%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

.section-header-row {
    margin-bottom: 10px;
}

.section-action-row {
    display: flex;
    justify-content: flex-end;
    /* Align to right */
    margin-bottom: 20px;
}

.section-title {
    font-family: 'Nata Sans', sans-serif;
    font-size: 2.2rem;
    color: #3e2723;
    /* Darker brown */
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, #5d4037, #8d6e63);
    margin-top: 8px;
    border-radius: 2px;
}

/* Enhanced Expandable '+' Button */
.btn-add-book-icon {
    background: #007bff;
    /* Primary Blue */
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    /* Rounded rectangular */
    text-decoration: none;
    transition: all 0.5s ease;
    /* Slower transition */
    padding: 10px 12px;
    min-width: 45px;
    /* Ensure icon is visible */
    height: 40px;
    overflow: hidden;
    white-space: nowrap;
    color: white;
}

.btn-add-book-icon:hover {
    box-shadow: 0 8px 20px rgba(0, 123, 255, 0.5);
    background: #0069d9;
    /* Darker Blue on hover */
    padding: 10px 20px;
    min-width: 220px;
}

.btn-add-book-icon i {
    font-size: 1.4rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.btn-text {
    font-size: 1rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-weight: 700;
    opacity: 0;
    max-width: 0;
    margin-left: 0;
    transition: opacity 0.5s ease 0.1s, max-width 0.5s ease, margin-left 0.5s ease;
    overflow: hidden;
}

.btn-add-book-icon:hover .btn-text {
    opacity: 1;
    max-width: 200px;
    margin-left: 10px;
}

/* Reuse existing subject grid styles but ensure they work here */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

.subject-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    aspect-ratio: 16/9;
}

.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.subject-image-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.subject-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.subject-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    padding: 20px 15px 10px;
}

.subject-title {
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Compact Quiz Steps */
.quiz-steps-container.compact-steps {
    padding: 30px 0;
    min-height: auto;
}

.compact-steps .steps-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.compact-steps .step-box {
    padding: 15px;
}

.compact-steps .step-number {
    width: 35px;
    height: 35px;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.compact-steps .step-text {
    font-size: 1rem;
}

.compact-steps .final-instruction {
    margin-top: 20px;
    font-size: 1rem;
}

/* Create Question Button */
.create-question-section {
    text-align: center;
    padding: 20px 0 40px;
}

.btn-create-question {
    display: inline-block;
    background: #007bff;
    /* Primary Blue */
    color: white;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
}

.btn-create-question:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
    color: white;
    background: #0069d9;
    /* Darker Blue */
}

@media (max-width: 768px) {
    .section-title {
        font-size: 1.4rem;
    }

    .subject-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }

    .home-container {
        width: 100%;
        padding: 0 15px;
    }
}

/* Subjects Page Wide Layout */
.subjects-page-container {
    width: 100%;
    background-color: #fff;
    padding: 40px 0;
}

.subjects-content-wrapper {
    width: 80%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
}

.subjects-content-wrapper .page-header {
    text-align: center;
    margin-bottom: 40px;
}

.subjects-content-wrapper .header-text h1 {
    font-size: 2.2rem;
    color: #3e2723;
    font-weight: 800;
    margin: 0 0 10px 0;
}

.subjects-content-wrapper .header-text p {
    font-size: 1.1rem;
    color: #666;
    margin: 0;
}

/* Ensure subject grid works in this context */
.subjects-content-wrapper .subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

@media (min-width: 1200px) {
    .subjects-content-wrapper .subject-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 30px;
    }
}

@media (max-width: 768px) {
    .subjects-content-wrapper {
        width: 100%;
        padding: 0 15px;
    }

    .subjects-content-wrapper .subject-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }

    .subjects-content-wrapper .header-text h1 {
        font-size: 1.6rem;
    }

    .subjects-content-wrapper .header-text p {
        font-size: 0.95rem;
    }
}