/* css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Base Light Theme Variables */
    --bg-gradient: linear-gradient(135deg, #f4f0fa 0%, #f0f4f8 50%, #fff0f5 100%);
    --public-bg-gradient: linear-gradient(135deg, #6c78e6 0%, #9066d4 100%); /* พื้นหลังหน้าสาธารณะ (โทนม่วงอมฟ้าตามรูป) */
    
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-solid: #ffffff;
    --glass-border: rgba(255, 255, 255, 1);
    --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    
    --text-primary: #2d3748;
    --text-secondary: #718096;
    
    --accent-purple: #7e57c2;
    --accent-pink: #ec407a;
    --accent-blue: #42a5f5;
    --accent-gray: #a0aec0;
    
    --success-green: #22c55e;
    --danger-red: #ef4444;
    --info-blue: #3b82f6;
    
    --font-main: 'Sarabun', sans-serif;
}

body {
    font-family: var(--font-main);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 11.5pt;
    line-height: 1.6;
}

/* พื้นหลังเฉพาะหน้าแดชบอร์ดสาธารณะ */
body.public-dashboard-bg {
    background: var(--public-bg-gradient);
    padding: 30px 20px;
}

.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Glass & Solid Panels */
.glass-panel {
    background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border); border-radius: 20px; padding: 30px;
    box-shadow: var(--glass-shadow); margin-bottom: 30px;
}
.glass-panel-solid {
    background: var(--glass-solid);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* =========================================
   PUBLIC DASHBOARD UI (เหมือนในรูปภาพ)
========================================= */

/* 1. Header */
.public-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 25px; margin-bottom: 25px;
}
.header-left { display: flex; align-items: center; gap: 15px; }
.school-logo-frame-small {
    width: 60px; height: 60px; border-radius: 50%; background: #f0f4f8;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    border: 2px solid var(--info-blue);
}
.school-logo-frame-small img { width: 100%; height: 100%; object-fit: cover; }
.school-name { font-size: 16pt; font-weight: 700; color: var(--text-primary); margin: 0; line-height: 1.2; }
.school-sub { font-size: 11pt; color: var(--text-secondary); margin: 0; }

.header-right { display: flex; align-items: center; gap: 20px; }
.time-display {
    font-size: 14pt; font-weight: 700; color: var(--info-blue);
    background: #f0f4f8; padding: 8px 20px; border-radius: 30px;
}
.btn-login-circle {
    width: 45px; height: 45px; border-radius: 50%;
    background: #f8f9fa; border: 1px solid #e2e8f0; color: var(--text-secondary);
    font-size: 16px; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.btn-login-circle:hover { background: var(--accent-purple); color: white; transform: scale(1.05); }

/* 2. Summary Stats Cards */
.summary-stats-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 35px;
}
.stat-card {
    display: flex; align-items: center; padding: 25px; gap: 20px;
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-icon-box {
    width: 65px; height: 65px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 30px; color: white; flex-shrink: 0;
}
.bg-blue { background: var(--info-blue); }
.bg-red { background: var(--danger-red); }
.bg-green { background: var(--success-green); }

.stat-info h3 { font-size: 12.5pt; font-weight: 600; color: var(--text-primary); margin: 0 0 5px 0; }
.stat-value { font-size: 28pt; font-weight: 700; line-height: 1; }
.stat-value small { font-size: 12pt; font-weight: 500; color: var(--text-secondary); margin-left: 5px; }
.text-blue { color: var(--info-blue); }
.text-red { color: var(--danger-red); }
.text-green { color: var(--success-green); }

/* 3. Section Title */
.section-title {
    font-size: 16pt; font-weight: 700; color: white; margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px; text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* 4. Student Cards */
.student-cards-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px;
}
.student-status-card {
    background: white; border-radius: 12px; padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08); position: relative;
    border-left: 6px solid #e2e8f0; /* Default border */
    display: flex; flex-direction: column; gap: 10px;
    transition: all 0.3s ease;
}
.border-safe { border-left-color: var(--success-green); }
.border-overdue { border-left-color: var(--danger-red); animation: pulse-border 1.5s infinite; }

@keyframes pulse-border {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.student-name { font-size: 14pt; font-weight: 700; color: var(--text-primary); line-height: 1.3; }
.student-badge {
    background: #e2e8f0; color: var(--text-secondary); font-size: 10pt;
    padding: 3px 10px; border-radius: 20px; font-weight: 600;
}

.student-id { font-size: 11pt; color: var(--text-secondary); }

.time-row {
    display: flex; justify-content: space-between; font-size: 11pt; font-weight: 500;
    margin-top: 5px; padding-top: 10px; border-top: 1px dashed #e2e8f0;
}
.time-row i { margin-right: 5px; width: 14px; text-align: center; }
.text-normal { color: var(--text-secondary); }
.text-danger { color: var(--danger-red); font-weight: 700; }

.reason-pill {
    background: #f3f0ff; color: #7e57c2; font-size: 10.5pt; font-weight: 600;
    padding: 8px 12px; border-radius: 8px; text-align: center; margin-top: 5px;
}

/* =========================================
   ADMIN DASHBOARD UI & อื่นๆ (คงเดิม)
========================================= */
h1 { font-size: 22pt; font-weight: 700; color: var(--accent-purple); margin-bottom: 15px; }
h2 {
    font-size: 16pt; font-weight: 600; color: var(--accent-purple);
    border-left: 6px solid var(--accent-pink); padding-left: 15px; margin-bottom: 25px;
    background: linear-gradient(to right, rgba(236, 64, 122, 0.05) 0%, transparent 100%);
    border-radius: 0 8px 8px 0; padding-top: 5px; padding-bottom: 5px;
}
h3 { font-size: 13pt; font-weight: 500; color: var(--accent-blue); margin-bottom: 12px; }

/* Admin Layout */
.admin-layout { display: flex; gap: 30px; max-width: 1400px; margin: 0 auto; align-items: flex-start; }
.sidebar { width: 280px; flex-shrink: 0; position: sticky; top: 20px; display: flex; flex-direction: column; }
.sidebar-profile { text-align: center; padding-bottom: 20px; border-bottom: 2px dashed #e2e8f0; margin-bottom: 20px; }
.sidebar-menu { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.menu-item { padding: 15px 20px; border-radius: 12px; color: var(--text-secondary); font-weight: 600; font-size: 13pt; cursor: pointer; transition: all 0.3s ease; display: flex; align-items: center; gap: 12px; }
.menu-item:hover { background: rgba(126, 87, 194, 0.05); color: var(--accent-purple); transform: translateX(5px); }
.menu-item.active { background: linear-gradient(135deg, rgba(126, 87, 194, 0.15), rgba(236, 64, 122, 0.05)); color: var(--accent-purple); border-left: 5px solid var(--accent-purple); }
.main-content { flex-grow: 1; min-width: 0; }
.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; animation: fadeIn 0.4s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.form-control { width: 100%; font-family: var(--font-main); font-size: 11.5pt; background: #ffffff; border: 1px solid #cbd5e0; border-radius: 10px; padding: 12px 16px; color: var(--text-primary); transition: all 0.3s ease; }
.form-control:focus { outline: none; border-color: var(--accent-purple); box-shadow: 0 0 0 3px rgba(126, 87, 194, 0.15); }

/* Buttons */
.btn { display: inline-block; font-family: var(--font-main); font-size: 11.5pt; font-weight: 600; padding: 12px 24px; border-radius: 10px; border: none; cursor: pointer; text-align: center; transition: all 0.2s; color: #ffffff; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.15); }
.btn:active { transform: scale(0.97); }
.btn-purple { background: linear-gradient(135deg, #9575cd, #7e57c2); }
.btn-blue { background: linear-gradient(135deg, #64b5f6, #42a5f5); }
.btn-gray { background: linear-gradient(135deg, #b0bec5, #90a4ae); color: #fff; }
.btn-danger { background: linear-gradient(135deg, #ef5350, #e53935); }
.btn-success { background: linear-gradient(135deg, #66bb6a, #43a047); }

/* Circular Action Buttons (Admin Dashboard) */
.action-panel { display: flex; gap: 40px; align-items: center; justify-content: center; padding: 20px; }
.action-item { display: flex; flex-direction: column; align-items: center; gap: 15px; }
.circle-add-btn { width: 75px; height: 75px; border-radius: 50%; background: linear-gradient(135deg, #4caf50, #2e7d32); color: white; font-size: 36px; font-weight: bold; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4); transition: all 0.2s; }
.circle-add-btn:hover { transform: scale(1.08); box-shadow: 0 12px 25px rgba(76, 175, 80, 0.5); }
.circle-return-btn { width: 75px; height: 75px; border-radius: 50%; background: linear-gradient(135deg, #ef5350, #c62828); color: white; font-size: 32px; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; box-shadow: 0 8px 20px rgba(239, 83, 80, 0.4); transition: all 0.2s; }
.circle-return-btn:hover { transform: scale(1.08); box-shadow: 0 12px 25px rgba(239, 83, 80, 0.5); }
.action-label { font-size: 14pt; font-weight: 700; color: var(--text-primary); }

/* Admin Grid */
.two-column-row { display: flex; gap: 30px; flex-wrap: wrap; }
.column-left { flex: 0 0 40%; min-width: 300px; }
.column-right { flex: 1; min-width: 300px; }
.table-responsive { width: 100%; overflow-x: auto; border-radius: 12px; border: 1px solid #e2e8f0; background: #fff; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11pt; }
.data-table th { background: rgba(126, 87, 194, 0.05); color: var(--accent-purple); font-weight: 700; padding: 15px; text-align: left; border-bottom: 2px solid rgba(126, 87, 194, 0.15); }
.data-table td { padding: 15px; border-bottom: 1px solid #edf2f7; color: var(--text-primary); vertical-align: middle; }

/* Dashboard Cards Grid (Admin) */
.dashboard-grid { margin-bottom: 30px; }
.cards-flex-wrapper { display: flex; flex-wrap: wrap; gap: 20px; }
.card-item-container { flex: 1 1 calc(33.33% - 20px); min-width: 250px; border-radius: 16px; padding: 20px; background: #ffffff; border: 1px solid #e2e8f0; box-shadow: 0 8px 20px rgba(0,0,0,0.05); transition: transform 0.3s; }
.card-item-container.status-safe { background: var(--card-green); border-top: 5px solid var(--success-green); }
.card-item-container.status-overdue { background: var(--card-red); border-top: 5px solid var(--danger-red); animation: pulse-light 2s infinite; }
.card-title { font-size: 14pt; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.card-meta { font-size: 11pt; color: var(--text-secondary); margin-bottom: 6px; }
.card-badge { display: inline-block; font-size: 10pt; padding: 4px 12px; border-radius: 20px; font-weight: 600; margin-top: 10px; }
.badge-safe { background: var(--success-green); color: #fff; }
.badge-overdue { background: var(--danger-red); color: #fff; }

/* Modals */
.custom-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(45, 55, 72, 0.7); backdrop-filter: blur(8px); z-index: 100000; display: none; align-items: center; justify-content: center; }
.custom-modal-box { background: #ffffff; border-radius: 20px; width: 600px; max-width: 95%; padding: 35px; box-shadow: 0 20px 50px rgba(0,0,0,0.25); position: relative; border-top: 8px solid var(--accent-purple); }

/* Links */
.forgot-password-link { display: block; margin-top: 15px; color: var(--accent-blue); cursor: pointer; text-decoration: none; font-weight: 600; text-align: center; }
.forgot-password-link:hover { text-decoration: underline; color: #1e88e5; }
.forgot-notification-banner { background: #fff0f6; border-left: 6px solid var(--accent-pink); border-radius: 8px; padding: 15px 20px; margin-bottom: 25px; box-shadow: 0 4px 10px rgba(236, 64, 122, 0.1); color: var(--text-primary); }

/* Responsive */
@media (max-width: 992px) {
    .summary-stats-grid { grid-template-columns: 1fr; }
    .admin-layout { flex-direction: column; }
    .sidebar { width: 100%; position: relative; top: 0; }
    .sidebar-menu { flex-direction: row; flex-wrap: wrap; }
    .menu-item { flex: 1; justify-content: center; text-align: center; font-size: 11pt; }
    .column-left, .column-right { flex: 0 0 100%; }
}