:root {
    --text-color: #ffffff;
    --primary-glow: #00d4ff;
    --secondary-glow: #ff00c3;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --input-bg: rgba(255, 255, 255, 0.05);
    --accent-color: #4facfe;

    /* Timetable Grid */
    --grid-gap: 8px;
    --slot-height: 50px;
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    background: #0f0c29;
    background: linear-gradient(to right, #24243e, #302b63, #0f0c29);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite ease-in-out alternate;
}

.blob-1 {
    top: 10%;
    left: 20%;
    width: 300px;
    height: 300px;
    background: var(--primary-glow);
    animation-delay: 0s;
}

.blob-2 {
    bottom: 20%;
    right: 15%;
    width: 350px;
    height: 350px;
    background: var(--secondary-glow);
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 45%;
    width: 200px;
    height: 200px;
    background: #7928ca;
    animation-delay: -2s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(20px, 40px) scale(1.1);
    }
}

/* Glassmorphism Utilities */
.glass-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 10;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    padding: 30px;
    margin-bottom: 30px;
}

.glass-input,
.glass-button {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 16px;
    font-family: inherit;
    color: white;
    outline: none;
    transition: all 0.3s ease;
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.glass-button {
    cursor: pointer;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.glass-button:active {
    transform: scale(0.95) translateY(0);
}

/* Premium Shimmer Effect */
@keyframes shimmer {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }

    100% {
        transform: translateX(100%) rotate(45deg);
    }
}

.course-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 200%;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: rotate(45deg);
    animation: shimmer 4s infinite linear;
    pointer-events: none;
}

.glass-button.primary {
    background: rgba(79, 172, 254, 0.2);
    border-color: rgba(79, 172, 254, 0.4);
}

.glass-button.primary:hover {
    background: rgba(79, 172, 254, 0.4);
}

.glass-button.secondary {
    background: rgba(255, 255, 255, 0.1);
}

.glass-button.danger {
    background: rgba(255, 50, 50, 0.15);
    border-color: rgba(255, 50, 50, 0.3);
}

.glass-button.danger:hover {
    background: rgba(255, 50, 50, 0.3);
}

/* App Header */
.app-header {
    text-align: center;
    margin-bottom: 50px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.app-header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #e0e0e0 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.app-header p {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Controls Section */
.controls-section h2,
.timetable-section h2 {
    margin-bottom: 25px;
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
}

.input-group input {
    width: 100%;
}

/* Time Slots */
.time-slots-container {
    margin-bottom: 25px;
}

.slot-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

.slot-row .day-select {
    flex: 2;
}

.slot-row input[type="time"] {
    flex: 1;
}

.remove-slot-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.remove-slot-btn:hover {
    color: #ff4757;
}

#add-slot-btn {
    margin-top: 10px;
    width: 100%;
    font-size: 0.9rem;
}

/* Selected List */
.selected-courses-container {
    margin: 20px 0;
}

.selected-list {
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 10px;
}

.selected-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    transition: transform 0.2s;
}

.selected-item:hover {
    transform: translateX(5px);
    background: rgba(255, 255, 255, 0.1);
}

.selected-item .info {
    display: flex;
    flex-direction: column;
}

.selected-item .info strong {
    color: var(--primary-glow);
    font-size: 0.9rem;
}

.selected-item .info span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.remove-btn {
    background: none;
    border: none;
    color: rgba(255, 100, 100, 0.7);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.remove-btn:hover {
    color: #ff6b6b;
}

.empty-state {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    padding: 30px;
    font-style: italic;
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.big-btn {
    flex: 2;
    padding: 15px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Timetable Grid */
.timetable-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Updated Timetable Grid for Fixed Rows */
.timetable-grid {
    display: grid;
    /* 1 col for time label + 5 cols for days */
    grid-template-columns: 100px repeat(5, 1fr);
    /* Auto rows */
    grid-auto-rows: minmax(80px, auto);
    gap: 8px;
    overflow-x: auto;
}

.break-cell {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    letter-spacing: 2px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.time-label {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.8rem;
    padding: 10px;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.break-label {
    background: rgba(255, 255, 255, 0.05);
}

.grid-cell {
    position: relative;
    /* Ensure height is respected */
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.grid-header {
    text-align: center;
    padding: 10px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.time-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.course-card {
    position: absolute;
    /* Width and left handled by JS */
    top: 0;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.85rem;
    color: white;

    /* Stronger Glass Effect */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);

    /* Content Layout */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: hidden;
    z-index: 5;

    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);

    /* Smooth Pop Animation */
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transform-origin: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes popIn {
    0% {
        transform: scale(0.6);
        opacity: 0;
        filter: blur(10px);
    }

    100% {
        transform: scale(1);
        opacity: 1;
        filter: blur(0);
    }
}

.course-card.expanded {
    height: auto !important;
    min-height: 100%;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000 !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    background: rgba(40, 40, 60, 0.98) !important;
    backdrop-filter: blur(20px);
}

.expand-btn {
    position: absolute;
    bottom: 3px;
    right: 3px;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 9px;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.expand-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: scale(1.15);
}

.course-card:hover .expand-btn {
    display: flex;
}

.course-card:hover {
    transform: scale(1.03) translateY(-2px);
    z-index: 100 !important;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
}

.course-card .course-name {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 4px;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.course-card .course-venue {
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 2px;
    padding: 3px 7px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 5px;
    text-shadow: none;
    max-width: 100%;
    width: fit-content;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* Enhanced Export Mode */
.course-card.export-mode {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 1);
}

/* When expanded, allow venue to wrap vertically */
.course-card.expanded .course-venue {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    display: block;
}

/* Export mode: Similar to expanded but optimized for static image */
.course-card.export-mode {
    /* Ensure card height adjusts to content for image */
    height: auto !important;
    min-height: 100%;
    padding: 10px 12px 10px 10px;
    /* Extra right padding for safety */
    overflow: visible;
    /* Allow natural flow */
    max-width: 100%;
    /* Constrain to parent */
}

.course-card.export-mode .course-name {
    margin-bottom: 6px;
    font-size: 0.9rem;
    /* Ensure name doesn't overflow */
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.course-card.export-mode .course-venue {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    /* More aggressive breaking */
    hyphens: auto;
    max-width: 100%;
    width: 100%;
    /* Force full width usage */
    display: block;
    font-size: 0.65rem;
    /* Smaller for better fit */
    line-height: 1.3;
    padding: 4px 6px;
    box-sizing: border-box;
}

/* Tooltip on hover (optional enhancement via pseudoelement or title attr) */


/* Responsive */
@media (max-width: 768px) {
    .slot-row {
        flex-direction: column;
        align-items: stretch;
        background: rgba(255, 255, 255, 0.05);
        padding: 10px;
        border-radius: 12px;
    }

    .remove-slot-btn {
        align-self: flex-end;
        margin-top: -30px;
    }

    .timetable-grid {
        min-width: 600px;
        /* Force scroll on small screens */
    }
}

/* Search Dropdown & Divider */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.glass-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(30, 30, 50, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-top: 5px;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.glass-dropdown.hidden {
    display: none;
}

.dropdown-item {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dropdown-item strong {
    color: var(--primary-glow);
    display: block;
    font-size: 0.95rem;
}

.dropdown-item span {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    font-weight: 600;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
    padding: 0 10px;
}

/* --- AI Features Styles --- */

/* Search Enhancement */
.search-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.voice-btn {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.voice-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.voice-btn.recording {
    background: rgba(255, 107, 107, 0.3);
    border-color: #ff6b6b;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0);
    }
}

.quick-filters {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.filter-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip:hover {
    background: rgba(255, 255, 255, 0.15);
}

.filter-chip.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

/* Conflict Panel */
.conflict-panel {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    animation: slideDown 0.4s ease-out;
}

.conflict-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: #ff6b6b;
}

.conflict-item {
    font-size: 0.85rem;
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.conflict-item:last-child {
    border-bottom: none;
}

/* AI Sections */
.ai-section {
    margin: 20px 0;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ai-badge {
    background: linear-gradient(135deg, #00d4ff 0%, #ff00c3 100%);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.recommendation-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 0;
}

.recommendation-card {
    min-width: 200px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.recommendation-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-5px);
}

.recommendation-card .code {
    color: var(--primary-glow);
    font-weight: 700;
    font-size: 0.9rem;
}

.recommendation-card .reason {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 5px;
}

/* AI Glow Animation */
.ai-glow {
    position: relative;
    overflow: hidden;
}

.ai-glow::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(transparent, var(--primary-glow), transparent, var(--secondary-glow), transparent);
    animation: rotate 4s linear infinite;
    z-index: -1;
    opacity: 0.3;
}

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

    to {
        transform: rotate(360deg);
    }
}

/* Insights & Analytics Panels */
.ai-insights-panel,
.analytics-panel {
    animation: fadeIn 0.5s ease-out;
}

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

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.6;
}

.close-btn:hover {
    opacity: 1;
}

.insights-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.insight-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
}

.insight-card.success {
    border-left: 4px solid #4ecdc4;
}

.insight-card.warning {
    border-left: 4px solid #ffde59;
}

.insight-card.danger {
    border-left: 4px solid #ff6b6b;
}

.insight-card h4 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.insight-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.insight-card .detail {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Charts & Dashboard */
.analytics-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 900px) {
    .analytics-content {
        grid-template-columns: 1fr;
    }
}

.balance-card {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 8px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.score-circle .score {
    font-size: 2.2rem;
    font-weight: 800;
}

.workload-chart {
    display: flex;
    align-items: flex-end;
    gap: 15px;
    height: 200px;
    padding: 20px 0;
}

.chart-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 60%;
    border-radius: 8px 8px 0 0;
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-height: 4px;
    position: relative;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
}

.chart-bar:hover {
    filter: brightness(1.2);
    transform: scaleX(1.1);
}

.chart-label {
    font-size: 0.7rem;
    opacity: 0.6;
}

/* Export Menu */
.export-controls {
    position: relative;
}

.export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 220px;
    background: rgba(30, 30, 50, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px;
    margin-top: 10px;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.export-option {
    width: 100%;
    padding: 12px 15px;
    background: none;
    border: none;
    color: white;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.export-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Hidden Utilities */
.hidden {
    display: none !important;
}

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

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

@keyframes liquidOpen {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
        filter: blur(5px);
    }

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

.ai-insights-panel,
.analytics-panel,
.ai-section:not(.hidden) {
    animation: liquidOpen 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes alertPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(255, 107, 107, 0);
    }

    100% {
        transform: scale(1);
    }
}

.conflict-panel {
    animation: alertPulse 2s infinite ease-in-out;
}