/* =========================================
   ตัวแปรสีและค่าพื้นฐาน (CSS Variables)
========================================= */
:root {
    --primary-color: #8D38C9; /* สีม่วง มหาวิทยาลัยพะเยา */
    --primary-hover: #7B2FB5;
    --bg-color: #f3f4f6; /* พื้นหลังสีเทาอ่อน */
    --text-color: #1f2937;
    --text-light: #6b7280;
    --white: #ffffff;
    
    /* Status Colors */
    --status-not-submitted: #ef4444; /* สีแดง */
    --status-submitted: #f59e0b;     /* สีเหลือง */
    --status-approved: #10b981;      /* สีเขียว */
    --status-rejected: #6b7280;      /* สีเทา */
    
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-radius: 8px;
    --font-family: 'Prompt', sans-serif;
}

/* =========================================
   Reset & Base Styles
========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    flex: 1; /* ดัน Footer ลงไปล่างสุดเสมอ */
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* =========================================
   Navbar Styles
========================================= */
.navbar {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1rem 0;
    box-shadow: var(--shadow-md);
    position: sticky; /* ล็อกเมนูไว้ด้านบน */
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--white);
    text-decoration: none;
}

.navbar-brand .icon {
    font-size: 2rem;
}

.navbar-brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.navbar-brand p {
    font-size: 0.875rem;
    color: #93c5fd;
    margin: 0;
}

.navbar-menu {
    display: flex;
    gap: 1rem;
}

/* =========================================
   Buttons
========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background-color: var(--white);
    color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #f1f5f9;
}

.btn-outline {
    background-color: transparent;
    color: var(--white);
    border: 1px solid var(--white);
}

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* =========================================
   Toggle Switch (Type Selection)
========================================= */
.type-toggle {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.toggle-group {
    background-color: var(--white);
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    padding: 0.25rem;
}

.toggle-btn {
    padding: 0.75rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    background: transparent;
    outline: none;
}

.toggle-btn.active {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

/* =========================================
   Filter Bar
========================================= */
.filter-bar {
    background: var(--white);
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group label {
    font-weight: 500;
    font-size: 0.9rem;
}

.filter-select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-family);
    min-width: 150px;
}

/* =========================================
   Chart Grid
========================================= */
.dashboard-title {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.2s;
    cursor: pointer;
}

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

.chart-card h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    min-height: 48px; /* เผื่อชื่อกลุ่มสาระยาว 2 บรรทัด */
}

.chart-container {
    position: relative;
    height: 200px;
    width: 100%;
}

.chart-summary {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* =========================================
   Accordion / Subject Status
========================================= */
.status-section {
    margin-top: 3rem;
}

.accordion-item {
    background: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
    overflow: hidden;
}

.accordion-header {
    padding: 1rem 1.5rem;
    background: var(--white);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    transition: background-color 0.2s;
}

.accordion-header:hover {
    background-color: #f9fafb;
}

.accordion-header .indicator {
    transition: transform 0.3s;
}

.accordion-item.active .indicator {
    transform: rotate(180deg);
}

.accordion-content {
    display: none;
    padding: 0 1.5rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.accordion-item.active .accordion-content {
    display: block;
}

.subject-item {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

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

.subject-header {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.status-bar-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.status-bar-label {
    min-width: 80px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.status-bar {
    flex: 1;
    height: 12px;
    background-color: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.status-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
}

/* Status variants */
.status-not_submitted .status-fill { background-color: var(--status-not-submitted); width: 0%; }
.status-submitted .status-fill { background-color: var(--status-submitted); width: 50%; }
.status-approved .status-fill { background-color: var(--status-approved); width: 100%; }
.status-rejected .status-fill { background-color: var(--status-rejected); width: 100%; }

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
}
.badge.not_submitted { background-color: var(--status-not-submitted); }
.badge.submitted { background-color: var(--status-submitted); color: #000;}
.badge.approved { background-color: var(--status-approved); }
.badge.rejected { background-color: var(--status-rejected); }

.lesson-plans-list {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
    font-size: 0.9rem;
}

.lesson-plan-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.25rem;
}

.loading-spinner {
    text-align: center;
    padding: 3rem;
    font-size: 1.2rem;
    color: var(--text-light);
}

/* =========================================
   Footer
========================================= */
.footer {
    background-color: var(--white);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .chart-grid {
        grid-template-columns: 1fr;
    }
}
