/**
 * SMANSAL Timetable - Stylesheet
 * Brand colors: Deep Forest Green (#1b4332), Warm Neutrals (#f8f9fa), Restrained Green Accents (#40916c, #d8f3dc)
 */

:root {
    --forest-900: #081c15;
    --forest-800: #133826;
    --forest-700: #1b4332;
    --forest-600: #2d6a4f;
    --forest-500: #40916c;
    --forest-400: #52b788;
    --forest-200: #b7e4c7;
    --forest-100: #d8f3dc;
    --forest-50:  #f0fdf4;

    --surface-bg: #f8f9fa;
    --surface-card: #ffffff;
    --surface-border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --sidebar-width: 270px;
    --topbar-height: 64px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--surface-bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Sidebar Styling */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--forest-800);
    color: #ffffff;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.25s ease-in-out;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background-color: var(--forest-900);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--forest-500), var(--forest-700));
    color: #ffffff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    margin-right: 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.brand-text-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
    line-height: 1.2;
}

.brand-text-sub {
    font-size: 0.72rem;
    color: var(--forest-200);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.sidebar-group-title {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--forest-400);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav-item {
    margin: 0.15rem 0.75rem;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.sidebar-nav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-nav-link.active {
    color: #ffffff;
    background-color: var(--forest-600);
    font-weight: 600;
}

.sidebar-nav-link.disabled-link {
    opacity: 0.65;
    cursor: not-allowed;
}

.sidebar-nav-link .nav-left {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

/* ==============================================================
   Sidebar Accordion Design (Modern Collapsible Groups)
   ============================================================== */
.sidebar-accordion {
    padding: 0.25rem 0;
}

.sidebar-accordion-item {
    margin-bottom: 0.25rem;
}

/* Accordion Trigger Header Button */
.sidebar-accordion-header {
    width: calc(100% - 1.2rem);
    margin: 0.1rem 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.825rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    user-select: none;
}

.sidebar-accordion-header:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
}

.sidebar-accordion-header:focus-visible {
    outline: 2px solid var(--forest-400);
    outline-offset: -1px;
}

/* Expanded state */
.sidebar-accordion-header[aria-expanded="true"] {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.06);
}

/* When the group contains active page */
.sidebar-accordion-header.has-active {
    color: #ffffff;
    background-color: rgba(45, 106, 79, 0.2);
}

.sidebar-accordion-header.has-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3.5px;
    height: 60%;
    background-color: var(--forest-400);
    border-radius: 0 4px 4px 0;
}

/* Header left area */
.sidebar-accordion-header .header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-accordion-header .header-icon {
    font-size: 1.05rem;
    color: var(--forest-300);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, transform 0.2s ease;
}

.sidebar-accordion-header:hover .header-icon,
.sidebar-accordion-header[aria-expanded="true"] .header-icon,
.sidebar-accordion-header.has-active .header-icon {
    color: #ffffff;
}

/* Header right area */
.sidebar-accordion-header .header-right {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

/* Count badge */
.sidebar-accordion-header .header-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    line-height: 1;
}

.sidebar-accordion-header.has-active .header-badge {
    background: rgba(82, 183, 136, 0.3);
    color: var(--forest-100);
    border-color: rgba(82, 183, 136, 0.4);
}

/* Rotating Chevron */
.sidebar-accordion-header .header-chevron {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

.sidebar-accordion-header[aria-expanded="true"] .header-chevron {
    transform: rotate(180deg);
    color: rgba(255, 255, 255, 0.95);
}

/* Sub-nav Tree Container */
.sidebar-subnav {
    list-style: none;
    padding: 0.25rem 0 0.35rem 0;
    margin: 0.15rem 0.6rem 0.35rem 1.65rem;
    border-left: 1.5px solid rgba(255, 255, 255, 0.15);
}

.sidebar-subnav-item {
    margin: 0.15rem 0;
}

.sidebar-subnav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.48rem 0.75rem 0.48rem 0.85rem;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.815rem;
    font-weight: 500;
    position: relative;
    transition: all 0.15s ease-in-out;
}

.sidebar-subnav-link:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.sidebar-subnav-link.active {
    color: #ffffff;
    background-color: var(--forest-600);
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.sidebar-subnav-link.active::before {
    content: "";
    position: absolute;
    left: -0.85rem;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 1.5px;
    background-color: var(--forest-400);
}

.sidebar-subnav-link .nav-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: var(--forest-900);
    font-size: 0.75rem;
    color: var(--forest-200);
}

/* Main Layout Offset */
.app-main-wrapper {
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease-in-out;
}

.app-topbar {
    height: var(--topbar-height);
    background-color: var(--surface-card);
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-content {
    flex: 1;
    padding: 1.75rem 1.5rem;
}

.app-footer {
    background-color: var(--surface-card);
    border-top: 1px solid var(--surface-border);
    padding: 1rem 1.5rem;
    font-size: 0.825rem;
    color: var(--text-secondary);
}

/* Custom Badges */
.badge-phase {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.badge-phase-active {
    background-color: var(--forest-100);
    color: var(--forest-700);
    border: 1px solid var(--forest-200);
}

.badge-phase-planned {
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--forest-200);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Cards & Surfaces */
.card-academic {
    background: var(--surface-card);
    border: 1px solid var(--surface-border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.card-academic-hero {
    background: linear-gradient(135deg, var(--forest-800) 0%, var(--forest-700) 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
}

.card-academic-hero .text-hero-muted {
    color: var(--forest-100);
}

/* Responsive Media Queries */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
    }

    .app-main-wrapper {
        margin-left: 0;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1025;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }
}
