/* =================================================
   RESET + BASE
================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
}

html,
body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    background: #f2f4f7;
}

/* =================================================
   TOPBAR
================================================= */
.topbar {
    height: 72px;
    background: #1976d2;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: relative;
    z-index: 30;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.28);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    padding-left: 96px;
    /* กันโลโก้ */
}

.menu-icon {
    position: absolute;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    cursor: pointer;
}

/* โลโก้ลอย */
.logo {
    position: absolute;
    left: 56px;
    bottom: -32px;
    height: 80px;
    filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
}

/* ชื่อระบบ */
.title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-left: 32px;
    white-space: nowrap;
}

/* ปุ่ม Login */
.login-btn {
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    padding: 6px 14px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
}

.login-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
}

.login-btn:active {
    transform: translateY(1px);
}

/* =================================================
   LOGO SPACE (กัน layout แตก)
================================================= */
.logo-space {
    height: 40px;
}

/* =================================================
   DASHBOARD LAYOUT
================================================= */
.dashboard-container {
    flex: 1;
    padding: 16px;
}

/* grid 3 คอลัมน์ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.dashboard-card:hover {
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.12),
        0 6px 18px rgba(0, 0, 0, 0.06);
    border-color: #c9ced6;
}

.card-header {
    background: #f8f9fb;
    border-bottom: 1px solid #e3e6ea;
    font-weight: 600;
}

/* ทุก card ต้องมีกรอบแน่น */
/* ===== DASHBOARD CARD (FINAL) ===== */
.dashboard-card {
    background: #ffffff;
    border-radius: 6px;

    /* ⭐ เส้นกรอบที่มองเห็นชัด */
    border: 1px solid #dcdfe3;

    /* ⭐ เงาเบา ๆ แบบราชการ */
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.08),
        0 2px 6px rgba(0, 0, 0, 0.04);

    display: flex;
    flex-direction: column;

    min-height: 320px;
    max-height: 320px;

    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}


/* body ของกราฟ */
.dashboard-card .card-body {
    height: calc(320px - 42px);
    /* หัก header */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.dashboard-card canvas {
    max-width: 100% !important;
    max-height: 100% !important;
}

.card-header {
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.card-menu {
    cursor: pointer;
    color: #999;
}

.card-body {
    padding: 12px;
    flex: 1;
}

/* =================================================
   CHART HEIGHT CONTROL
================================================= */

/* กราฟนิเทศ (line ใหญ่) */
.chart-supervision .card-body {
    height: 300px;
}

/* กราฟอายุ (bar แนวนอน) */
.chart-age .card-body {
    height: 340px;
}

/* กราฟวิทยฐานะ */
.chart-rank .card-body {
    height: 280px;
}

/* pie / donut */
.chart-school-size .card-body,
.chart-digital .card-body {
    height: 260px;
}

/* bar แนวตั้ง */
.chart-subject .card-body {
    height: 280px;
}

/* canvas ต้องกินพื้นที่ */
.dashboard-card canvas {
    width: 100% !important;
    height: 100% !important;
}

/* placeholder */
.chart-placeholder {
    height: 100%;
    border: 2px dashed #cfcfcf;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}

/* =================================================
   FOOTER
================================================= */
.footer {
    height: 40px;
    background: #ffffff;
    border-top: 1px solid #ddd;
    font-size: 12px;
    color: #666;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
}

.footer-left,
.footer-right {
    white-space: nowrap;
}




/* =================================================
   RESPONSIVE
================================================= */
@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .logo {
        height: 64px;
        bottom: -24px;
    }

    .title {
        font-size: 18px;
        margin-left: 24px;
    }
}