/* Main styles for the Tutor AI application */

/* CSS Variables for Theme Support */
:root {
    --bg-primary: #212529;
    --bg-secondary: #343a40;
    --sidebar-bg: #ffffff;
    --sidebar-text: #495057;
    --text-primary: #ffffff;
    --text-secondary: #6c757d;
    --border-color: rgba(255, 255, 255, 0.1);
    --sidebar-border: rgba(0, 0, 0, 0.1);
}

[data-bs-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: rgba(0, 0, 0, 0.1);
}

/* Sidebar Layout Styles */
.main-container {
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    background-color: var(--sidebar-bg) !important;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.sidebar-header {
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    font-weight: 600;
}

.sidebar .nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #212529;
}

.sidebar .nav-link.active {
    background-color: #e3c7ff !important;
    color: #6945c1 !important;
    font-weight: 600;
}

.sidebar .nav-section-title {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
    padding-top: 0.5rem;
}

.sidebar .nav-section {
    background-color: rgba(0, 0, 0, 0.03);
    padding: 0.5rem 0;
    border-radius: 0.25rem;
}

.sidebar .navbar-brand {
    color: #6945c1 !important;
    font-weight: 700;
}

.sidebar .btn-close-white {
    filter: invert(1);
}

.sidebar .dropdown-menu {
    background-color: #ffffff;
    border: 1px solid var(--sidebar-border);
    margin-left: 1rem;
    margin-right: 1rem;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.sidebar .dropdown-item {
    color: var(--sidebar-text);
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
}

.sidebar .dropdown-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #212529;
}

.sidebar .dropdown-header {
    color: #6c757d;
    font-weight: 600;
}

.sidebar .dropdown-divider {
    border-color: var(--sidebar-border);
}

.sidebar .dropdown-toggle {
    color: var(--sidebar-text) !important;
}

.sidebar .dropdown-toggle::after {
    filter: invert(1);
}

.main-content {
    margin-left: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.brand-text {
    font-weight: bold;
    font-size: 1.2rem;
}

/* Custom Info Panel */
.context-info-panel {
    background-color: #6945c1 !important;
    border: none !important;
    color: white !important;
}

.context-info-panel .text-white {
    color: white !important;
}

.context-info-panel i {
    color: rgba(255, 255, 255, 0.9) !important;
}

.username-text {
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

/* Mobile Top Bar */
.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-topbar .btn {
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    transition: all 0.3s ease;
}

.mobile-topbar .btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.mobile-topbar .brand-text {
    font-weight: 700;
    font-size: 1.1rem;
}

.mobile-topbar .navbar-brand {
    text-decoration: none;
    transition: all 0.3s ease;
}

.mobile-topbar .navbar-brand:hover {
    transform: scale(1.02);
    color: #ffd700 !important;
}

/* Responsive Design */
@media (max-width: 991.98px) {
    .sidebar {
        width: 100%;
        max-width: 280px;
        z-index: 1055 !important;
        left: auto !important;
        right: 0 !important;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* Ensure content doesn't get cut off on mobile */
    .main-content .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Fix backdrop interaction */
    .offcanvas-backdrop {
        z-index: 1050 !important;
    }

    /* Ensure sidebar content is clickable */
    .sidebar .nav-link {
        position: relative;
        z-index: 1060;
        pointer-events: auto;
    }

    .sidebar .sidebar-content {
        position: relative;
        z-index: 1060;
    }
}

/* Offcanvas adjustments for larger screens */
@media (min-width: 992px) {
    .sidebar.offcanvas-lg {
        position: fixed !important;
        transform: none !important;
        visibility: visible !important;
    }

    .mobile-topbar {
        display: none !important;
    }
}

/* Theme Toggle Button Styles */
#theme-toggle {
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

#theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] #theme-toggle {
    background-color: var(--bs-dark);
    border-color: var(--bs-secondary);
    color: #ffc107;
}

[data-bs-theme="light"] #theme-toggle {
    background-color: var(--bs-light);
    border-color: var(--bs-secondary);
    color: #6f42c1;
}

/* Ensure the body fills the entire height */
html,
body {
    height: 100%;
    margin: 0;
}

/* Main container */
.main-container {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* Content area */
.content {
    flex: 1;
    padding: 20px 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Navbar styles */
.navbar-brand img {
    height: 30px;
    margin-right: 10px;
}

/* Main content area to ensure proper flex layout */
.main-content {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Footer styles */
footer {
    background-color: var(--bs-dark) !important;
    color: var(--bs-light) !important;
    padding: 8px 0 !important;
    width: 100% !important;
    margin-top: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    flex-shrink: 0;
}

footer .container-fluid {
    max-width: 100%;
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
}

footer p {
    line-height: 1.4;
    margin-bottom: 0 !important;
}

footer .text-muted {
    opacity: 0.65;
}

footer a:hover {
    opacity: 0.9;
    text-decoration: underline !important;
}

/* Login and registration forms */
.auth-form {
    max-width: 400px;
    margin: 40px auto;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.auth-form h2 {
    margin-bottom: 20px;
    text-align: center;
}

/* Dashboard cards */
.dashboard-card {
    height: 100%;
    transition: transform 0.3s;
    border-radius: 10px;
    overflow: hidden;
}

.dashboard-card:hover {
    transform: translateY(-5px);
}

.dashboard-card .card-body {
    padding: 20px;
}

.dashboard-card .card-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.dashboard-card .card-value {
    font-size: 2rem;
    font-weight: bold;
}

/* Chat interface */
.chat-container {
    height: calc(100vh - 200px);
    min-height: 400px;
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.chat-header {
    padding: 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.chat-input {
    padding: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.message {
    margin-bottom: 15px;
    max-width: 80%;
}

.message-user {
    background-color: var(--bs-primary);
    color: white;
    border-radius: 15px 15px 0 15px;
    padding: 10px 15px;
    margin-left: auto;
}

.message-tutor {
    background-color: var(--bs-secondary);
    color: white;
    border-radius: 15px 15px 15px 0;
    padding: 10px 15px;
}

.message-time {
    font-size: 0.8rem;
    margin-top: 5px;
    opacity: 0.8;
}

/* Subject selector */
.subject-selector {
    margin-bottom: 20px;
}

.subject-item {
    cursor: pointer;
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 5px;
    transition: background-color 0.3s;
}

.subject-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.subject-item.active {
    background-color: var(--bs-primary);
    color: white;
}

/* Performance dashboard */
.performance-chart {
    height: 300px;
    margin-bottom: 30px;
}

.performance-score {
    font-size: 3rem;
    font-weight: bold;
    text-align: center;
}

.score-label {
    text-align: center;
    margin-bottom: 20px;
}

/* Admin dashboard */
.admin-dashboard .card {
    margin-bottom: 20px;
}

.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 20px;
}

/* Tables */
.data-table {
    width: 100%;
    margin-bottom: 20px;
}

.data-table th {
    background-color: var(--bs-secondary);
    color: white;
}

/* Forms */
.form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}



/* Typewriter effect for chat messages */
.typewriter {
    overflow: hidden;
    border-right: .15em solid rgba(255, 255, 255, 0.7);
    white-space: nowrap;
    margin: 0 auto;
    animation: typewriter-cursor 0.75s step-end infinite;
}

@keyframes typewriter-cursor {

    from,
    to {
        border-color: transparent
    }

    50% {
        border-color: rgba(255, 255, 255, 0.7)
    }
}



/* Topic badge styling */
.topic-badge {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 4px 8px;
    margin-bottom: 8px;
    font-size: 0.85em;
    display: inline-block;
}

.topic-badge i {
    margin-right: 4px;
}

/* Smooth message appearance */
.message-container {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Fix for dropdown z-index issue */
.navbar .dropdown-menu {
    z-index: 1100 !important;
    position: absolute !important;
}

.navbar .dropdown {
    position: relative;
    z-index: 1100;
}

/* Responsive styles */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 150px);
    }


    .message {
        max-width: 90%;
    }
}

/* Global Mobile Top Bar Override (Purple) */
.mobile-topbar,
.mobile-topbar.bg-dark {
    background-color: #6945c1 !important;
}