* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #5d4e37;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 30%, #ffd89b 70%, #d299c2 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><radialGradient id="grad1" cx="50%" cy="50%" r="50%"><stop offset="0%" style="stop-color:rgba(255,107,53,0.6);stop-opacity:1" /><stop offset="100%" style="stop-color:rgba(255,107,53,0);stop-opacity:0" /></radialGradient><radialGradient id="grad2" cx="50%" cy="50%" r="50%"><stop offset="0%" style="stop-color:rgba(255,215,0,0.4);stop-opacity:1" /><stop offset="100%" style="stop-color:rgba(255,215,0,0);stop-opacity:0" /></radialGradient></defs><circle cx="150" cy="150" r="4" fill="url(%23grad1)"><animate attributeName="cy" values="150;850;150" dur="8s" repeatCount="indefinite"/><animate attributeName="r" values="4;8;4" dur="4s" repeatCount="indefinite"/></circle><circle cx="300" cy="80" r="3" fill="rgba(255,140,66,0.5)"><animate attributeName="cy" values="80;920;80" dur="12s" repeatCount="indefinite"/><animate attributeName="cx" values="300;350;300" dur="6s" repeatCount="indefinite"/></circle><circle cx="500" cy="200" r="6" fill="url(%23grad2)"><animate attributeName="cy" values="200;700;200" dur="10s" repeatCount="indefinite"/><animate attributeName="opacity" values="0.3;0.8;0.3" dur="3s" repeatCount="indefinite"/></circle><circle cx="700" cy="120" r="2.5" fill="rgba(255,182,193,0.6)"><animate attributeName="cy" values="120;880;120" dur="9s" repeatCount="indefinite"/></circle><circle cx="850" cy="300" r="5" fill="rgba(255,248,220,0.4)"><animate attributeName="cy" values="300;600;300" dur="7s" repeatCount="indefinite"/><animate attributeName="r" values="5;10;5" dur="5s" repeatCount="indefinite"/></circle><polygon points="100,500 110,520 90,520" fill="rgba(255,215,0,0.3)"><animateTransform attributeName="transform" attributeType="XML" type="rotate" values="0 100 510;360 100 510" dur="15s" repeatCount="indefinite"/><animate attributeName="opacity" values="0.3;0.7;0.3" dur="4s" repeatCount="indefinite"/></polygon><polygon points="800,400 815,425 785,425" fill="rgba(255,107,53,0.4)"><animateTransform attributeName="transform" attributeType="XML" type="rotate" values="360 800 412;0 800 412" dur="12s" repeatCount="indefinite"/></polygon></svg>') repeat;
    pointer-events: none;
    z-index: -1;
    animation: backgroundFloat 20s ease-in-out infinite;
}

@keyframes backgroundFloat {

    0%,
    100% {
        transform: translateX(0px) translateY(0px);
    }

    25% {
        transform: translateX(10px) translateY(-5px);
    }

    50% {
        transform: translateX(-5px) translateY(10px);
    }

    75% {
        transform: translateX(-10px) translateY(-10px);
    }
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><rect x="200" y="200" width="2" height="20" fill="rgba(255,255,255,0.1)" rx="1"><animate attributeName="height" values="20;40;20" dur="6s" repeatCount="indefinite"/><animate attributeName="y" values="200;180;200" dur="6s" repeatCount="indefinite"/></rect><rect x="600" y="300" width="2" height="15" fill="rgba(255,255,255,0.15)" rx="1"><animate attributeName="height" values="15;30;15" dur="4s" repeatCount="indefinite"/><animate attributeName="y" values="300;285;300" dur="4s" repeatCount="indefinite"/></rect><rect x="400" y="500" width="2" height="25" fill="rgba(255,255,255,0.1)" rx="1"><animate attributeName="height" values="25;50;25" dur="8s" repeatCount="indefinite"/><animate attributeName="y" values="500;475;500" dur="8s" repeatCount="indefinite"/></rect></svg>') repeat;
    pointer-events: none;
    z-index: -2;
    opacity: 0.6;
    animation: backgroundFloat 25s ease-in-out infinite reverse;
}

.background-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../static/Manipal.webp') center/cover no-repeat;
    opacity: 0.4;
    pointer-events: none;
    filter: blur(7px) sepia(20%);
}

.navbar {
    background: rgba(255, 248, 220, 0.95);
    backdrop-filter: blur(20px);
    padding: 1rem 2rem;
    box-shadow: 0 4px 30px rgba(218, 165, 32, 0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 228, 196, 0.3);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-size: 2.5em;
    font-weight: 100;
    background: linear-gradient(135deg, #ff6b35, #f7931e, #ffd700, #ff8c42);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    transition: all 0.4s;
    cursor: pointer;
    position: relative;
    letter-spacing: 2px;
    text-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
}

.logo:hover {
    transform: scale(1.08) translateY(-2px);
    filter: drop-shadow(0 8px 25px rgba(255, 107, 53, 0.4));
}

.logo::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #ff6b35, #ffd700, #ff8c42);
    transition: width 0.4s;
}

.logo:hover::after {
    width: 100%;
}

.uniportal-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(15px);
    border-radius: 25px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    animation: brandPulse 6s ease-in-out infinite;
}

@keyframes brandPulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 107, 53, 0.3);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 40px rgba(255, 107, 53, 0.5);
    }
}

.brand-title {
    font-size: 30px;
    font-weight: 500;
    background: linear-gradient(135deg, #ff6b35, #ffd700, #ff8c42, #ff6b35);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 3px;
    position: relative;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: #8b4513;
    font-weight: 600;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    transition: all 0.3s;
    background: linear-gradient(135deg, rgba(255, 228, 196, 0.3), rgba(250, 235, 215, 0.3));
    border: 1px solid rgba(218, 165, 32, 0.2);
}

.nav-links a:hover,
.nav-links a.active {
    background: linear-gradient(135deg, #daa520 0%, #cd853f 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(218, 165, 32, 0.3);
}

.profile-dropdown {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
}

.profile-dropdown:hover {
    background: rgba(218, 165, 32, 0.15);
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #daa520 0%, #cd853f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: rgba(255, 248, 220, 0.98);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(218, 165, 32, 0.2);
    min-width: 200px;
    z-index: 2000;
    padding: 0.5rem 0;
    list-style: none;
    border: 1px solid rgba(255, 228, 196, 0.3);
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    color: #8b4513;
    text-decoration: none;
    transition: all 0.2s;
}

.dropdown-menu a:hover {
    background: rgba(218, 165, 32, 0.1);
    color: #d2691e;
}

.profile-dropdown:focus .dropdown-menu,
.profile-dropdown:hover .dropdown-menu {
    display: block;
    animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.welcome-section {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px 0;
}

.welcome-section h1 {
    font-size: 3.5em;
    margin-bottom: 1rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ec801c, #cd9445, #f09947);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: welcomeGlow 5s ease-in-out infinite alternate;
}

@keyframes welcomeGlow {
    0% {
        filter: brightness(1);
    }

    100% {
        filter: brightness(1.2) drop-shadow(0 0 20px rgba(255, 228, 196, 0.4));
    }
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

.card {
    background: rgba(255, 248, 220, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px rgba(218, 165, 32, 0.15);
    transition: all 0.4s;
    position: relative;
    border: 1px solid rgba(255, 228, 196, 0.3);
}

.card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 35px 70px rgba(218, 165, 32, 0.25);
    background: rgba(255, 248, 220, 0.98);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #daa520, #cd853f, #d2691e);
    border-radius: 24px 24px 0 0;
}

.card h2 {
    color: #d2691e;
    margin-bottom: 2rem;
    font-size: 2em;
    background: linear-gradient(135deg, #d2691e, #cd853f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.date-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.date-tab {
    padding: 1rem 2rem;
    background: rgba(255, 248, 220, 0.9);
    border: 2px solid rgba(218, 165, 32, 0.3);
    border-radius: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.4s;
    color: #d2691e;
    text-transform: uppercase;
}

.date-tab:hover {
    background: rgba(255, 248, 220, 1);
    transform: translateY(-4px);
}

.date-tab.active {
    background: linear-gradient(135deg, #daa520, #cd853f);
    color: white;
    border-color: transparent;
    box-shadow: 0 15px 35px rgba(218, 165, 32, 0.4);
}

.timetable table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.timetable th,
.timetable td {
    padding: 1.2rem;
    text-align: left;
    border-bottom: 1px solid rgba(218, 165, 32, 0.15);
}

.timetable th {
    background: linear-gradient(135deg, rgba(218, 165, 32, 0.2), rgba(205, 133, 63, 0.2));
    color: #d2691e;
    text-transform: uppercase;
}

.lecture-row {
    transition: all 0.3s;
    cursor: pointer;
}

.lecture-row:hover {
    background: linear-gradient(135deg, rgba(255, 228, 196, 0.3), rgba(250, 235, 215, 0.3));
    transform: scale(1.01);
}

.attendance-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
}

.attended {
    background: rgba(144, 238, 144, 0.8);
    color: #2e7d32;
}

.missed {
    background: rgba(255, 182, 193, 0.8);
    color: #c62828;
}

.upcoming {
    background: rgba(255, 248, 220, 0.8);
    color: #d2691e;
}

.event-item {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.4s;
    border-left: 4px solid #ddd;
    margin-bottom: 1rem;
}

.event-item:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.event-item.priority-high {
    border-left-color: #dc3545;
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.08), rgba(255, 255, 255, 0.7));
}

.event-item.priority-medium {
    border-left-color: #ffc107;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.08), rgba(255, 255, 255, 0.7));
}

.event-item.priority-low {
    border-left-color: #28a745;
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.08), rgba(255, 255, 255, 0.7));
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-top: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 147, 251, 0.1));
    padding: 2rem 1.5rem;
    border-radius: 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-6px);
}

.stat-number {
    font-size: 2.5em;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(139, 69, 19, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1003;
    display: none;
}

.modal-content {
    background: rgba(255, 248, 220, 0.95);
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.close-btn {
    float: right;
    cursor: pointer;
    font-size: 1.5rem;
    background: none;
    border: none;
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-right {
        flex-direction: column;
        width: 100%;
    }
}

/* Subject Detail View */
.subject-detail-view {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 450px;
    background: rgba(255, 248, 220, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(218, 165, 32, 0.3);
    border-radius: 24px;
    padding: 2rem;
    z-index: 1002;
    box-shadow: 0 25px 60px rgba(139, 69, 19, 0.25);
    display: none;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: none;
}

.overlay.show {
    opacity: 1;
}

/* Quiz Styles */
.quiz-section,
.quiz-container {
    padding: 1rem 0;
}

.question-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.question-text {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.option {
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8f9fa;
}

.option:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.option.selected {
    border-color: #667eea;
    background: #e7effc;
    color: #4a6fa5;
    font-weight: 600;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

/* --- Study Panel Specific Styles --- */
.results-section {
    margin-top: 2rem;
    padding: 2rem;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.results-content {
    color: #000000;
    line-height: 1.8;
    font-size: 1.15em;
    font-weight: 500;
}

.results-content strong {
    color: #d35400;
}

/* Chat Interface */
.chat-interface {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 500px;
}

.chat-header {
    background: linear-gradient(135deg, #e6b800, #e67e22);
    padding: 1.2rem;
    color: white;
    font-weight: 800;
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: #ffffff;
    background-image: radial-gradient(#f0f0f0 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    align-items: flex-start;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: #f8f9fa;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.message.ai-message .message-avatar {
    background: #e3f2fd;
    color: #1565c0;
}

.message.user-message .message-avatar {
    background: #fff3e0;
    color: #ef6c00;
}

.message-content {
    padding: 1.2rem;
    border-radius: 14px;
    font-size: 1.05rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

/* Fix for "Too Light" - High Contrast for AI */
.message.ai-message .message-content {
    background: #ffffff;
    color: #000000;
    border: 1px solid #e0e0e0;
    border-top-left-radius: 2px;
    font-weight: 500;
}

.message.user-message .message-content {
    background: linear-gradient(135deg, #ffb347, #ffcc33);
    color: #2c0b0e;
    border-top-right-radius: 2px;
}

.chat-input-container {
    padding: 1rem;
    background: #fff;
    border-top: 1px solid #eee;
}

.chat-input {
    display: flex;
    gap: 1rem;
}

.chat-input textarea {
    flex: 1;
    padding: 0.8rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
}

.chat-input textarea:focus {
    outline: none;
    border-color: #daa520;
}

.chat-input button {
    background: #daa520;
    color: white;
    border: none;
    width: 50px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s;
}

.chat-input button:hover {
    background: #b8860b;
}

/* Loading Spinner */
.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #daa520;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}