/* =========================================
   1. VARIABLES & GLOBAL STYLES
   ========================================= */
:root {
    --primary-color: #172751; /* University Navy */
    --secondary-color: #00acc8; /* University Cyan */
    --accent-color: #f59e0b; /* Gold/Yellow accent */
    --text-dark: #333333;
    --text-light: #6c757d;
    --bg-light: #f8f9fa;
    --sidebar-width: 280px;
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Libre Baskerville', serif; /* Keeping consistency with previous request */
    color: var(--primary-color);
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
}

/* =========================================
   COURSE CODE LINK STYLES
   ========================================= */
.course-code-link {
    color: #002855;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 1px solid transparent;
}

.course-code-link:hover {
    color: #00acc8;
    border-bottom-color: #00acc8;
    text-decoration: none;
}

/* =========================================
   2. HEADER & NAVBAR
   ========================================= */
/* Top Bar (White) */
.top-bar {
    background-color: white;
    padding: 1rem 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.logo-img {
    height: 80px;
    width: auto;
}

.logo-text {
    font-family: 'Libre Baskerville', serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: #002855;
    line-height: 1.2;
}

.program-text {
    font-family: 'Libre Baskerville', serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: #00acc8;
}

.header-divider {
    height: 50px;
    width: 1px;
    background-color: #d1d5db;
    margin: 0 1.5rem;
}

/* Main Navigation Bar (Blue) */
.main-navbar {
    background-color: var(--primary-color);
    color: white;
    padding: 0.5rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1040;
}

.navbar-toggler {
    border-color: rgba(255,255,255,0.5);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.75%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* =========================================
   3. SIDEBAR (Desktop Sticky / Mobile Offcanvas)
   ========================================= */
.sidebar-wrapper {
    background-color: white;
    border-right: 1px solid #dee2e6;
}

/* Desktop View */
@media (min-width: 992px) {
    .sidebar-wrapper {
        position: sticky;
        top: 90px; /* Height of header + some gap */
        height: calc(100vh - 100px);
        overflow-y: auto;
        border-radius: 8px;
        box-shadow: 0 0 15px rgba(0,0,0,0.05);
    }
}

.nav-link {
    color: var(--text-dark);
    padding: 12px 20px;
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background-color: #f0f4f8;
    color: var(--primary-color);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
    border-left-color: var(--secondary-color);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-link i {
    width: 25px;
    color: var(--secondary-color);
}

/* =========================================
   4. CONTENT AREA
   ========================================= */
.content-wrapper {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.05);
    min-height: 80vh;
}

.section-title {
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    display: inline-block;
}

/* =========================================
   5. RESPONSIVE TABLES (Card View on Mobile)
   ========================================= */
.course-table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.course-table th {
    background-color: var(--primary-color);
    color: white;
    padding: 12px;
    text-align: left;
}

.course-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
}

.course-table tr:hover {
    background-color: #f8f9fa;
}

/* Mobile Card View Logic */
@media (max-width: 768px) {
    .course-table, 
    .course-table tbody, 
    .course-table tr, 
    .course-table td {
        display: block;
        width: 100%;
    }

    .course-table thead {
        display: none; /* Hide headers on mobile */
    }

    .course-table tr {
        margin-bottom: 15px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        background: white;
        overflow: hidden;
    }

    .course-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 10px 15px;
        border-bottom: 1px solid #eee;
    }

    .course-table td:last-child {
        border-bottom: none;
    }

    .course-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--primary-color);
        text-align: left;
        margin-right: 10px;
        flex-basis: 40%; /* Width of the label */
    }
    
    /* Special styling for the Course Name to stand out */
    .course-table td[data-label="Course Name"] {
        background-color: var(--primary-color);
        color: white;
        font-weight: bold;
        text-align: center;
        display: block;
    }
    
    .course-table td[data-label="Course Name"]::before {
        display: none;
    }
}

/* =========================================
   6. MATRIX CONTAINER & SPINNER
   ========================================= */
#matrix-container {
    min-height: 300px;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.loading-text {
    margin-top: 15px;
    color: var(--text-light);
    font-weight: 500;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* =========================================
   7. FOOTER
   ========================================= */
.main-footer {
    background-color: #111;
    color: #aaa;
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
    font-size: 0.9rem;
}

/* =========================================
   8. DASHBOARD HEADER & LAYOUT
   ========================================= */
.dash-header {
    background: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.07);
    position: relative;
}
.dash-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.dash-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}
.dash-header-logo {
    height: 72px;
    flex-shrink: 0;
}
.dash-header-text {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.dash-header-divider {
    width: 1px;
    height: 48px;
    background: #dee2e6;
    flex-shrink: 0;
}

.logo-text span {
    display: block;
    font-size: 1.3rem;
}

.program-text {
    font-size: 1.3rem;
}

/* =========================================
   9. DASHBOARD SIDEBAR
   ========================================= */
.sidebar-wrapper {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.08);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.sidebar-wrapper h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.sidebar-wrapper .nav-link {
    color: #333;
    padding: 12px 16px;
    border-left: 4px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    margin-bottom: 4px;
    border-radius: 0 4px 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-wrapper .nav-link:hover {
    background-color: #f0f4f8;
    color: #172751;
    text-decoration: none;
}

.sidebar-wrapper .nav-link.active {
    background-color: #172751;
    color: white;
    border-left-color: #00acc8;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar-wrapper .nav-link i {
    color: #00acc8;
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-wrapper .nav-link.active i {
    color: #fbbf24;
}

/* =========================================
   10. CONTENT AREA (Dashboard)
   ========================================= */
.content-area-wrapper {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.08);
    min-height: 500px;
}

#tree-container {
    margin-top: 1.5rem;
}

/* =========================================
   11. TREE VIEW
   ========================================= */
.tree ul {
    padding-left: 24px;
    border-left: 2px solid #e5e7eb;
    margin-left: 12px;
}
.tree li {
    list-style-type: none;
    margin: 12px 0;
    position: relative;
}
.tree li::before {
    content: "";
    position: absolute;
    top: 15px;
    left: -24px;
    border-top: 2px solid #e5e7eb;
    width: 24px;
    height: 1px;
}
.tree-toggle {
    cursor: pointer;
    user-select: none;
    padding: 6px 0;
    transition: color 0.2s ease;
}
.tree-toggle::before {
    content: "\f054";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: #172751;
    display: inline-block;
    margin-right: 8px;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
    font-size: 0.75em;
}
.tree-toggle.open::before {
    transform: rotate(90deg);
}
.tree-toggle:hover {
    color: #00acc8;
}

/* Department links */
.department-link::before {
    content: "\f07b";
    color: #666;
}
.department-link:hover {
    text-decoration: underline;
    color: #0066cc !important;
}
.department-link:hover::before {
    color: #0066cc;
}

/* Program links */
.program-link::before {
    content: "\f07b";
    color: #666;
}
.program-link {
    font-style: normal !important;
}
.program-link:hover {
    text-decoration: underline;
    color: #0066cc !important;
}
.program-link:hover::before {
    color: #0066cc;
}

.tree-content {
    display: none;
}
.tree-content.open {
    display: block;
}

/* Root ul */
.tree > ul {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
}
.tree > ul > li::before {
    display: none;
}

/* =========================================
   12. DASHBOARD RESPONSIVE
   ========================================= */

/* Tablet: <=991px */
@media (max-width: 991px) {
    .sidebar-wrapper {
        position: relative;
        top: 0;
        max-height: none;
        margin-bottom: 1.5rem;
    }
    .content-area-wrapper {
        padding: 1.25rem;
    }
    .content-area-wrapper h1 {
        font-size: 1.4rem !important;
    }
    .dash-header-logo { height: 60px; }
    .logo-text span { font-size: 1.1rem; }
    .program-text { font-size: 1.1rem; }
}

/* Mobile: <=768px */
@media (max-width: 768px) {
    .dash-header { padding: 0.75rem 0; }
    .dash-header-inner { position: relative; }
    .dash-header-left { gap: 0.75rem; }
    .dash-header-logo { height: 52px; }
    .dash-header-text { gap: 0; flex-direction: column; align-items: flex-start; gap: 0.1rem; }
    .dash-header-divider { display: none; }
    .logo-text span { font-size: 0.9rem; }
    .program-text { font-size: 0.78rem; }

    #langSwitcher {
        position: absolute !important;
        top: 0;
        right: 0;
    }
    #langButton span,
    #langButton svg {
        display: none !important;
    }
    #langButton {
        padding: 0.35rem !important;
    }
    #langButton img {
        width: 26px !important;
        height: 26px !important;
    }

    main.container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .sidebar-wrapper {
        padding: 0.75rem !important;
    }
    .sidebar-wrapper h2 {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.4rem;
    }
    .sidebar-wrapper .nav-link {
        padding: 8px 12px;
        font-size: 0.85rem;
        margin-bottom: 2px;
    }
    .sidebar-wrapper .nav-link i {
        font-size: 0.9rem;
        width: 18px;
    }

    .content-area-wrapper {
        padding: 1rem !important;
    }
    .content-area-wrapper h1 {
        font-size: 1.2rem !important;
        margin-bottom: 0.75rem !important;
    }

    .tree-toggle {
        font-size: 0.9rem;
    }
    .tree-toggle.tree-root-toggle {
        font-size: 1rem !important;
    }
    .tree ul {
        padding-left: 16px;
        margin-left: 8px;
    }
    .tree li {
        margin: 8px 0;
    }
    .tree li::before {
        left: -16px;
        width: 16px;
    }
}

/* Small phone: <=480px */
@media (max-width: 480px) {
    .dash-header-logo { height: 44px; }
    .logo-text span { font-size: 0.78rem; letter-spacing: 0.3px; }
    .program-text { font-size: 0.68rem; }
    .sidebar-wrapper .nav-link {
        padding: 7px 10px;
        font-size: 0.8rem;
    }
    .content-area-wrapper {
        padding: 0.75rem !important;
    }
    .content-area-wrapper h1 {
        font-size: 1.05rem !important;
    }
    .tree-toggle {
        font-size: 0.82rem;
    }
    .tree-toggle.tree-root-toggle {
        font-size: 0.92rem !important;
    }
    .tree ul {
        padding-left: 12px;
        margin-left: 6px;
    }
}

/* =========================================
   13. LANGUAGE SWITCHER
   ========================================= */
#langSwitcher {
    position: relative;
    z-index: 1060;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #f3f4f6;
    border: none;
    border-radius: 50px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
}
.lang-btn:hover {
    background-color: #e5e7eb;
}
.lang-btn img {
    width: 40px;
    height: 27px;
    border-radius: 3px;
    object-fit: cover;
}
.lang-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
}

.lang-menu {
    position: absolute;
    right: 0;
    margin-top: 0.5rem;
    width: 12rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid #e5e7eb;
    padding: 0.5rem 0;
    z-index: 1070;
}
.lang-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    transition: background-color 0.2s;
}
.lang-menu a:hover {
    background-color: #f3f4f6;
}
.lang-menu a.lang-active {
    background-color: #eff6ff;
}
.lang-menu a img {
    width: 40px;
    height: 27px;
    border-radius: 3px;
    object-fit: cover;
}
.lang-menu a span {
    flex: 1;
}
.lang-menu a .fa-check {
    color: #16a34a;
}

/* =========================================
   14. DASHBOARD PAGE TITLE
   ========================================= */
.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #172751;
    margin-bottom: 1rem;
    border-bottom: 2px solid #f59e0b;
    padding-bottom: 0.5rem;
    display: inline-block;
}

/* =========================================
   15. SIDEBAR TITLE
   ========================================= */
.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #172751;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #00acc8;
}

/* =========================================
   16. TREE ROOT TOGGLE
   ========================================= */
.tree-root-toggle {
    font-size: 1.25rem;
    font-weight: 700;
    color: #172751;
    display: block;
    margin-bottom: 0.5rem;
}

/* =========================================
   17. ALERT STYLES (API Error / Warning)
   ========================================= */
.alert-api-error {
    background-color: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
}
.alert-api-error .fw-bold {
    font-weight: 700;
}

.alert-api-warning {
    background-color: #fef9c3;
    border-left: 4px solid #eab308;
    color: #854d0e;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
}
.alert-api-warning .fw-bold {
    font-weight: 700;
}

/* =========================================
   18. FACULTY TOGGLE
   ========================================= */
.tree-faculty-toggle {
    font-weight: 600;
}

/* =========================================
   19. DEPARTMENT & PROGRAM TREE TEXT
   ========================================= */
.tree-dept-text {
    color: #4b5563;
}
.tree-dept-text:hover {
    text-decoration: underline;
}
}