/* portal.css - Premium Mobile-First stylesheet for Book features Portal */

:root {
    --primary: #2567af;
    --primary-hover: #1b5391;
    --accent: #20afde;
    --accent-light: #e8f7fd;
    --success: #10b981;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --bg-app: #f8fafc;
    --border: #e2e8f0;
    --text-main: #2b2a29;
    --text-muted: #64748b;
    --radius: 16px;
    --shadow: 0 10px 15px -3px rgba(37, 103, 175, 0.05), 0 4px 6px -2px rgba(37, 103, 175, 0.02);
    --shadow-lg: 0 20px 25px -5px rgba(37, 103, 175, 0.1), 0 8px 10px -6px rgba(37, 103, 175, 0.05);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    padding-bottom: 40px;
}

.portal-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 20px;
    border-bottom: 1px solid var(--border);
}
.back-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.portal-logo {
    max-height: 35px;
    border-radius: 4px;
}

/* Hero Section */
.book-hero {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px 0;
}
.book-cover-placeholder {
    width: 70px;
    height: 95px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(37, 103, 175, 0.2);
}
.book-icon {
    font-size: 32px;
}
.book-meta h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.3;
}
.book-badges {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.book-badge {
    font-size: 10px;
    font-weight: 600;
    background-color: var(--accent-light);
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Grid Menu Cards */
.section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.feature-card {
    background-color: #ffffff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: all 0.2s ease-in-out;
}
.feature-card.active:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}
.feature-card.disabled {
    background-color: #f8fafc;
    border-style: dashed;
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}
.feature-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 16px;
    flex-shrink: 0;
}
.feature-icon.bg-primary { background-color: var(--primary); }
.feature-icon.bg-danger { background-color: var(--danger); }
.feature-icon.bg-success { background-color: var(--success); }
.feature-icon.bg-warning { background-color: var(--warning); }
.feature-icon.bg-accent { background-color: var(--accent); }
.feature-icon.bg-purple { background-color: #8b5cf6; }

.feature-info h4 {
    font-size: 14px;
    font-weight: 700;
}
.feature-info p {
    font-size: 11px;
    color: var(--text-muted);
}

/* Tab selector */
.interactive-nav {
    margin-bottom: 16px;
}
.tab-scroller {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
}
.tab-scroller::-webkit-scrollbar {
    height: 4px;
}
.tab-scroller::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 2px;
}
.nav-tab {
    background-color: #ffffff;
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.nav-tab.active {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* Tool Panels Body */
.interactive-body {
    background-color: #ffffff;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 380px;
    display: flex;
    flex-direction: column;
}
.tool-panel {
    display: none;
    flex: 1;
}
.tool-panel.active {
    display: flex;
    flex-direction: column;
}

/* 1. Chat CSS */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 400px;
}
.chat-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: #f8fafc;
}
.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 85%;
}
.chat-message.bot {
    align-self: flex-start;
}
.chat-message.user {
    align-self: flex-end;
    flex-direction: row;
}
.chat-message .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #ffffff;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 13px;
    flex-shrink: 0;
}
.chat-message.user .avatar {
    background-color: var(--primary);
    color: white;
}
.chat-message .msg-content {
    background-color: #ffffff;
    padding: 12px 16px;
    border-radius: 0 16px 16px 16px;
    font-size: 13px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.chat-message.user .msg-content {
    background-color: var(--primary);
    color: #ffffff;
    border-radius: 16px 0 16px 16px;
    border: none;
}
.chat-input-row {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    background-color: #ffffff;
}
.chat-input-row input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    outline: none;
    font-size: 13px;
}
.chat-input-row input:focus {
    border-color: var(--primary);
}
.chat-input-row button {
    background-color: var(--primary);
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
}

/* Chat loading dots */
.dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #94a3b8;
    border-radius: 50%;
    margin-right: 3px;
    animation: wave 1.3s linear infinite;
}
.dot:nth-child(2) { animation-delay: -1.1s; }
.dot:nth-child(3) { animation-delay: -0.9s; }
@keyframes wave {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* 2. Setup Screen UI */
.setup-quiz-card {
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    margin: auto;
    max-width: 400px;
}
.setup-quiz-card h4 {
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    font-weight: 700;
}
.setup-quiz-card p {
    font-size: 13px;
    color: var(--text-muted);
}
.input-group {
    width: 100%;
    text-align: left;
}
select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    font-size: 13px;
    background-color: #f8fafc;
}
.btn-tool {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px rgba(37, 103, 175, 0.2);
}
.btn-block { width: 100%; justify-content: center; }
.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    box-shadow: none;
    border: 1px solid var(--border);
}

/* Loader styling */
.quiz-player-card {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.quiz-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
    text-align: center;
    margin: auto;
}
.quiz-loading i {
    font-size: 36px;
    color: var(--primary);
}
.quiz-loading p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Quiz Game Elements */
.quiz-progress-bar {
    height: 4px;
    background-color: #f1f5f9;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}
.quiz-progress-fill {
    height: 100%;
    background-color: var(--success);
    width: 0%;
    transition: width 0.3s;
}
.quiz-meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 16px;
}
.quiz-question-box {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    line-height: 1.4;
}
.quiz-options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.quiz-opt-btn {
    text-align: left;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    background-color: #ffffff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    gap: 12px;
    align-items: center;
    transition: all 0.15s;
}
.quiz-opt-btn:hover:not(.disabled) {
    border-color: var(--primary);
    background-color: var(--accent-light);
}
.opt-label {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    color: var(--text-muted);
}
.quiz-opt-btn.correct {
    border-color: var(--success);
    background-color: var(--success-light);
}
.quiz-opt-btn.correct .opt-label {
    background-color: var(--success);
    color: white;
    border-color: var(--success);
}
.quiz-opt-btn.wrong {
    border-color: var(--danger);
    background-color: var(--danger-light);
}
.quiz-opt-btn.wrong .opt-label {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
}
.quiz-opt-btn.disabled {
    cursor: not-allowed;
}

/* Feedback panel */
.quiz-feedback-box {
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    border-left: 4px solid #cbd5e1;
}
.quiz-feedback-box.correct {
    background-color: var(--success-light);
    border-left-color: var(--success);
    color: #15803d;
}
.quiz-feedback-box.wrong {
    background-color: var(--danger-light);
    border-left-color: var(--danger);
    color: #b91c1c;
}
.quiz-feedback-box h5 {
    font-weight: 700;
    margin-bottom: 4px;
}

/* Score Card view */
.quiz-result-box {
    text-align: center;
    padding: 30px 10px;
    margin: auto;
}
.result-icon {
    font-size: 48px;
    color: var(--warning);
    margin-bottom: 16px;
    animation: pop 0.4s ease;
}
.score-display {
    font-size: 24px;
    font-weight: 800;
    font-family: 'Outfit', sans-serif;
    color: var(--primary);
    margin: 10px 0;
}
@keyframes pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 3. Flashcards CSS */
.flashcards-player {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.card-viewport {
    perspective: 1000px;
    width: 100%;
    height: 220px;
    cursor: pointer;
    margin: 20px 0;
}
.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}
.flashcard-inner.flipped {
    transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}
.flashcard-front {
    background-color: #ffffff;
    color: var(--text-main);
}
.flashcard-back {
    background-color: var(--accent-light);
    color: var(--primary);
    transform: rotateY(180deg);
}
.card-hint {
    position: absolute;
    top: 14px;
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}
.flashcard-front h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
}
.flashcard-back p {
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
}
.carousel-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
}
.ctrl-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}
.card-indicator {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* 4. Lesson Plan Layout */
.lesson-plan-output {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.lp-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}
.btn-action-small {
    background-color: #f1f5f9;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-action-small:hover {
    background-color: #e2e8f0;
}
.lp-markdown {
    background-color: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    font-size: 13px;
    overflow-y: auto;
    max-height: 350px;
    line-height: 1.6;
}
.lp-markdown h1, .lp-markdown h2, .lp-markdown h3 {
    color: var(--primary);
    font-family: 'Outfit', sans-serif;
    margin-top: 14px;
    margin-bottom: 6px;
}
.lp-markdown h2 { font-size: 15px; }
.lp-markdown h3 { font-size: 13px; }
.lp-markdown ul {
    padding-left: 20px;
    margin: 8px 0;
}
.lp-markdown li {
    margin-bottom: 4px;
}

/* Interactive Offline message */
.offline-card {
    padding: 40px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: auto;
}
.offline-card i {
    font-size: 40px;
    color: #cbd5e1;
}
.offline-card h4 {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 700;
}
.offline-card p {
    font-size: 12px;
    color: var(--text-muted);
    max-width: 300px;
}
