/* ============================================================
   Vidyoric — Custom CSS
   (Tailwind handles utilities; this handles custom components)
   ============================================================ */

/* ----------------------------------------------------------
   Google Fonts — fallback (loaded in layout <head> via link)
   ---------------------------------------------------------- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ----------------------------------------------------------
   Sidebar
   ---------------------------------------------------------- */
#sidebar {
    width: 60px;
    min-width: 60px;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.expanded {
    width: 220px !important;
    min-width: 220px !important;
}

#sidebar.expanded .sidebar-label {
    opacity: 1 !important;
    display: inline-block;
}

#sidebar.expanded #toggle-icon-open {
    display: none !important;
}

#sidebar.expanded #toggle-icon-close {
    display: block !important;
}

#sidebar-toggle {
    display: none;
}

@media (min-width: 768px) {
    #sidebar-toggle {
        display: flex !important;
        align-items: center;
        white-space: nowrap;
    }
}

#sidebar.expanded #sidebar-toggle {
    display: flex !important;
    align-items: center;
    white-space: nowrap;
}

/* Sidebar collapsed & expanded logo switching */
.sidebar-logo-collapsed {
    display: flex;
}

.sidebar-logo-expanded {
    display: none;
}

#sidebar.expanded .sidebar-logo-collapsed {
    display: none !important;
}

#sidebar.expanded .sidebar-logo-expanded {
    display: flex !important;
}

/* Mobile sidebar drawer */
@media (max-width: 767px) {
    #sidebar {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 260px !important;
        min-width: 260px !important;
        max-width: 85vw !important;
        transform: translateX(-100%) !important;
        z-index: 50 !important;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    }

    #sidebar.mobile-open {
        transform: translateX(0) !important;
    }

    #sidebar.mobile-open .sidebar-label,
    #sidebar .sidebar-label {
        opacity: 1 !important;
        display: inline-block !important;
    }

    #sidebar.mobile-open .sidebar-logo-collapsed {
        display: none !important;
    }

    #sidebar.mobile-open .sidebar-logo-expanded {
        display: flex !important;
    }

    #sidebar-toggle {
        display: none !important;
    }
}

.nav-active {
    background: #012B5A !important;
    color: #ffffff !important;
    border-left: 3px solid #BD9B61 !important;
    box-shadow: 0 4px 12px rgba(1, 43, 90, 0.35) !important;
}

.nav-active svg {
    color: #BD9B61 !important;
}

/* ----------------------------------------------------------
   Deckzy AI Copilot Drawer & Markdown
   ---------------------------------------------------------- */
#ai-drawer {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.06);
}

#ai-drawer.open {
    width: 390px !important;
    opacity: 1 !important;
}

@media (max-width: 640px) {
    #ai-drawer.open {
        width: 100vw !important;
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 60;
    }
}

.ai-chip {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9999px;
    padding: 5px 11px;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.ai-chip:hover {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(79, 70, 229, 0.1);
}

/* Deckzy Markdown Output Styling */
.deckzy-markdown {
    line-height: 1.55;
    word-break: break-word;
}
.deckzy-markdown p {
    margin-bottom: 0.65rem;
}
.deckzy-markdown p:last-child {
    margin-bottom: 0;
}
.deckzy-markdown h1, .deckzy-markdown h2, .deckzy-markdown h3, .deckzy-markdown h4 {
    font-weight: 700;
    color: #0f172a;
    margin-top: 0.75rem;
    margin-bottom: 0.35rem;
    line-height: 1.25;
}
.deckzy-markdown h3 { font-size: 0.875rem; }
.deckzy-markdown h4 { font-size: 0.8125rem; }
.deckzy-markdown strong {
    font-weight: 700;
    color: #1e1b4b;
}
.deckzy-markdown ul, .deckzy-markdown ol {
    margin-left: 1.25rem;
    margin-bottom: 0.65rem;
}
.deckzy-markdown ul { list-style-type: disc; }
.deckzy-markdown ol { list-style-type: decimal; }
.deckzy-markdown li {
    margin-bottom: 0.25rem;
}
.deckzy-markdown code:not(pre code) {
    background-color: #f1f5f9;
    color: #4338ca;
    padding: 0.15rem 0.35rem;
    border-radius: 0.375rem;
    font-size: 0.78rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 600;
}
.deckzy-markdown pre {
    background-color: #0f172a;
    color: #f8fafc;
    padding: 0.75rem 0.9rem;
    border-radius: 0.625rem;
    font-size: 0.75rem;
    overflow-x: auto;
    margin: 0.65rem 0;
    position: relative;
}
.deckzy-markdown pre code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    line-height: 1.45;
    color: #e2e8f0;
}
.deckzy-markdown blockquote {
    border-left: 3px solid #6366f1;
    background: #f5f3ff;
    padding: 0.5rem 0.75rem;
    border-radius: 0 0.5rem 0.5rem 0;
    margin: 0.5rem 0;
    color: #3730a3;
    font-size: 0.75rem;
}

/* ----------------------------------------------------------
   3D Flip Card
   ---------------------------------------------------------- */
.flip-card {
    perspective: 1200px;
    -webkit-perspective: 1200px;
    position: relative;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
}

.flip-card-front {
    transform: rotateY(0deg);
    z-index: 2;
}

.flip-card-back {
    transform: rotateY(180deg) !important;
    z-index: 1;
}

.flip-card.flipped .flip-card-front {
    z-index: 1;
}

.flip-card.flipped .flip-card-back {
    z-index: 2;
}

/* ----------------------------------------------------------
   Rating Buttons
   ---------------------------------------------------------- */
.rating-btn {
    border: 2px solid transparent;
}

.rating-again {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #e11d48;
}

.rating-again:hover {
    background: #ffe4e6;
    transform: scale(1.05);
}

.rating-hard {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #ea580c;
}

.rating-hard:hover {
    background: #ffedd5;
    transform: scale(1.05);
}

.rating-good {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #16a34a;
}

.rating-good:hover {
    background: #dcfce7;
    transform: scale(1.05);
}

.rating-easy {
    background: #eef2ff;
    border-color: #c7d2fe;
    color: #4f46e5;
}

.rating-easy:hover {
    background: #e0e7ff;
    transform: scale(1.05);
}

/* ----------------------------------------------------------
   Quiz Elements
   ---------------------------------------------------------- */
.quiz-option {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
    font-size: 14px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 12px;
}

.quiz-option:hover:not(.locked) {
    border-color: #6366f1;
    background: #eef2ff;
}

.quiz-option.selected {
    border-color: #6366f1;
    background: #eef2ff;
}

.quiz-option.correct {
    border-color: #16a34a;
    background: #f0fdf4;
    color: #166534;
}

.quiz-option.incorrect {
    border-color: #dc2626;
    background: #fff1f2;
    color: #991b1b;
}

.quiz-option.locked {
    cursor: not-allowed;
}

.option-letter {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
    transition: all 0.2s;
}

.quiz-option.correct .option-letter {
    background: #16a34a;
    color: white;
}

.quiz-option.incorrect .option-letter {
    background: #dc2626;
    color: white;
}

.quiz-dot.answered {
    background: #6366f1;
}

.quiz-dot.correct {
    background: #16a34a;
}

.quiz-dot.incorrect {
    background: #dc2626;
}

.quiz-dot.current {
    background: #6366f1;
    box-shadow: 0 0 0 3px #c7d2fe;
    transform: scale(1.3);
}

/* ----------------------------------------------------------
   Step Pills
   ---------------------------------------------------------- */
.step-pill-video {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 9999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.step-pill-notes {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 9999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.step-pill-cards {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    border-radius: 9999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.step-pill-quiz {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #fce7f3;
    color: #9d174d;
    border: 1px solid #fbcfe8;
    border-radius: 9999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

/* ----------------------------------------------------------
   Badges
   ---------------------------------------------------------- */
.badge-green {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
    border-radius: 9999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

.badge-blue {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: 9999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

.badge-purple {
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #ddd6fe;
    border-radius: 9999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

.badge-rose {
    background: #ffe4e6;
    color: #9f1239;
    border: 1px solid #fecdd3;
    border-radius: 9999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

.badge-yellow {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fef08a;
    border-radius: 9999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

.badge-gray {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

/* ----------------------------------------------------------
   Exam Trap Callout
   ---------------------------------------------------------- */
.exam-trap {
    border-left: 4px solid #f59e0b;
    background: #fffbeb;
    border-radius: 0 16px 16px 0;
}

/* ----------------------------------------------------------
   Markdown / Notes Rendering
   ---------------------------------------------------------- */
.prose-study h1 {
    font-size: 20px;
    font-weight: 800;
    color: #111827;
    margin: 0 0 12px;
}

.prose-study h2 {
    font-size: 17px;
    font-weight: 700;
    color: #1f2937;
    margin: 20px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f3f4f6;
}

.prose-study h3 {
    font-size: 14px;
    font-weight: 700;
    color: #374151;
    margin: 16px 0 8px;
}

.prose-study p {
    margin: 0 0 12px;
    line-height: 1.75;
}

.prose-study ul {
    padding-left: 20px;
    margin: 0 0 12px;
}

.prose-study li {
    margin: 4px 0;
    line-height: 1.65;
}

.prose-study strong {
    color: #111827;
    font-weight: 700;
}

.prose-study em {
    color: #6366f1;
    font-style: italic;
}

.prose-study code {
    background: #f3f4f6;
    color: #e11d48;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 12px;
    font-family: monospace;
}

.prose-study pre {
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    overflow-x: auto;
    font-size: 12px;
    margin: 12px 0;
}

.prose-study blockquote {
    border-left: 4px solid #6366f1;
    background: #eef2ff;
    border-radius: 0 12px 12px 0;
    padding: 12px 16px;
    margin: 12px 0;
}

.katex-display {
    margin: 16px 0;
}

/* ----------------------------------------------------------
   Scrollbar styling
   ---------------------------------------------------------- */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ----------------------------------------------------------
   Misc
   ---------------------------------------------------------- */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

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

.animate-slide-up {
    animation: slideUp 0.3s ease forwards;
}

.max-w-100rem {
    max-width: 100rem !important;
}

/* ----------------------------------------------------------
   Rich Notes & Study Notes Prose Styling
   ---------------------------------------------------------- */
.prose-study {
    line-height: 1.65;
    color: #334155;
    word-break: break-word;
}
.prose-study h1 { font-size: 1.35rem; font-weight: 800; margin-top: 0.85rem; margin-bottom: 0.45rem; color: #0f172a; }
.prose-study h2 { font-size: 1.15rem; font-weight: 700; margin-top: 0.75rem; margin-bottom: 0.4rem; color: #1e293b; }
.prose-study h3 { font-size: 1rem; font-weight: 600; margin-top: 0.65rem; margin-bottom: 0.35rem; color: #334155; }
.prose-study p { margin-bottom: 0.65rem; }
.prose-study ul { list-style-type: disc; padding-left: 1.4rem; margin-bottom: 0.65rem; }
.prose-study ol { list-style-type: decimal; padding-left: 1.4rem; margin-bottom: 0.65rem; }
.prose-study li { margin-bottom: 0.25rem; }
.prose-study blockquote {
    border-left: 4px solid #6366f1;
    background: #f8fafc;
    padding: 0.65rem 1rem;
    margin: 0.75rem 0;
    color: #475569;
    border-radius: 0 10px 10px 0;
}
.prose-study blockquote p { margin-bottom: 0; }
.prose-study table { width: 100%; border-collapse: collapse; margin: 0.85rem 0; font-size: 0.85rem; }
.prose-study th, .prose-study td { border: 1px solid #e2e8f0; padding: 6px 10px; }
.prose-study th { background-color: #f1f5f9; font-weight: 600; text-align: left; }
.prose-study code { background-color: #f1f5f9; color: #e11d48; padding: 2px 5px; border-radius: 4px; font-family: monospace; font-size: 0.875em; }
.prose-study pre { background-color: #0f172a; color: #f8fafc; padding: 12px; border-radius: 10px; overflow-x: auto; margin: 0.75rem 0; }
.prose-study pre code { background-color: transparent; color: inherit; padding: 0; }
.prose-study hr { border: 0; border-top: 1px solid #e2e8f0; margin: 1.25rem 0; }
.prose-study .katex-display { margin: 0.85rem 0; overflow-x: auto; overflow-y: hidden; }

/* Rich Editor UI buttons */
.editor-btn {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    color: #475569;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    transition: all 0.15s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    user-select: none;
}
.editor-btn:hover {
    background-color: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}
.editor-btn:active {
    transform: translateY(0);
}
.palette-btn {
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 12px;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    transition: all 0.15s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
}
.palette-btn:hover {
    background-color: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
    transform: translateY(-1px);
}

/* Fullscreen mode for Rich Notes Editor */
.rich-editor-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    z-index: 99999 !important;
    border-radius: 0 !important;
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
    background: #ffffff !important;
    overflow: hidden !important;
}

.rich-editor-fullscreen .rich-editor-content-area {
    flex: 1 1 0% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0 !important;
}

.rich-editor-fullscreen .rich-editor-pane {
    height: 100% !important;
    flex: 1 1 0% !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    max-height: none !important;
}

.rich-editor-fullscreen textarea.rich-editor-textarea {
    flex: 1 1 0% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: none !important;
    resize: none !important;
}

.rich-editor-fullscreen .rich-editor-scrollable {
    flex: 1 1 0% !important;
    height: 100% !important;
    max-height: none !important;
    overflow-y: auto !important;
}