/* =============================================
   ระบบนิเทศครูผู้สอน — Global Stylesheet
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #3b82f6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-dark: #0f172a;
    --bg-card: rgba(255,255,255,0.06);
    --border: rgba(255,255,255,0.12);
    --text-primary: #f1f5f9;
    --text-secondary: rgba(255,255,255,0.6);
    --text-muted: rgba(255,255,255,0.4);
    --sidebar-width: 260px;
    --header-height: 64px;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Sarabun', 'Inter', sans-serif;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-dark);
    line-height: 1.6;
}

/* =============================================
   Layout
   ============================================= */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(255,255,255,0.04);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-icon {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    margin-bottom: 10px;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.sidebar-brand h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}
.sidebar-brand p {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-user {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(99,102,241,0.08);
}
.user-avatar {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.user-info-row {
    display: flex; align-items: center; gap: 10px;
}
.user-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
    margin-top: 2px;
    display: inline-block;
}
.badge-teacher { background: rgba(34,197,94,0.15); color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.badge-supervisor { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}
.nav-section-title {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 0 8px;
    margin-bottom: 8px;
    margin-top: 16px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    margin-bottom: 2px;
}
.nav-link:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}
.nav-link.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(59,130,246,0.15));
    color: var(--primary-light);
    border: 1px solid rgba(99,102,241,0.2);
}
.nav-link .nav-icon { font-size: 18px; }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}
.btn-logout {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 10px 12px;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: 10px;
    color: #fca5a5;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
}
.btn-logout:hover {
    background: rgba(239,68,68,0.2);
    color: #f87171;
}

/* =============================================
   Main Content
   ============================================= */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--header-height);
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 28px;
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(10px);
}
.page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.current-week-badge {
    background: rgba(99,102,241,0.15);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 0.8rem;
    color: var(--primary-light);
}

.page-content { padding: 28px; flex: 1; }

/* =============================================
   Cards
   ============================================= */
.card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
}
.card-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.card-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.card-icon.purple { background: rgba(99,102,241,0.2); }
.card-icon.blue { background: rgba(59,130,246,0.2); }
.card-icon.green { background: rgba(34,197,94,0.2); }
.card-icon.orange { background: rgba(245,158,11,0.2); }
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 0.82rem; color: var(--text-muted); }

/* =============================================
   Stats Grid
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex; align-items: flex-start; gap: 16px;
    transition: all 0.3s;
}
.stat-card:hover { border-color: rgba(99,102,241,0.3); transform: translateY(-2px); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* =============================================
   Buttons
   ============================================= */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Sarabun', sans-serif;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(99,102,241,0.4); }
.btn-outline {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }
.btn-success { background: rgba(34,197,94,0.15); border: 1px solid rgba(34,197,94,0.25); color: #4ade80; }
.btn-danger { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.2); color: #fca5a5; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* =============================================
   Forms
   ============================================= */
.form-section { margin-bottom: 28px; }
.form-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    color: rgba(255,255,255,0.75);
    margin-bottom: 8px;
}
.form-label .required { color: #f87171; margin-left: 3px; }
.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'Sarabun', sans-serif;
    transition: all 0.3s;
    outline: none;
}
.form-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 38px;
    cursor: pointer;
    color-scheme: dark;
}
.form-select option {
    background: #1e1b4b;
    color: #f1f5f9;
    font-family: 'Sarabun', sans-serif;
    padding: 8px 12px;
}
.form-select option:hover,
.form-select option:checked {
    background: #6366f1;
    color: #ffffff;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--primary);
    background: rgba(99,102,241,0.08);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-input::placeholder, .form-textarea::placeholder { color: rgba(255,255,255,0.3); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-help { font-size: 0.8rem; color: var(--text-muted); margin-top: 5px; }

/* =============================================
   Table
   ============================================= */
.table-wrapper { overflow-x: auto; border-radius: 12px; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.data-table thead tr {
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid var(--border);
}
.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-secondary);
    vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* =============================================
   Badges
   ============================================= */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-success { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-info { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-gray { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* =============================================
   Alert / Flash
   ============================================= */
.flash-message {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px;
    font-size: 0.92rem;
    animation: slideDown 0.3s ease;
}
.flash-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.25); color: #86efac; }
.flash-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.flash-info { background: rgba(59,130,246,0.12); border: 1px solid rgba(59,130,246,0.25); color: #93c5fd; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* =============================================
   Reports List
   ============================================= */
.report-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 14px;
    transition: all 0.3s;
}
.report-card:hover { border-color: rgba(99,102,241,0.25); transform: translateY(-1px); }
.report-week-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(59,130,246,0.15));
    border: 1px solid rgba(99,102,241,0.2);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.8rem;
    color: var(--primary-light);
    font-weight: 500;
    margin-bottom: 10px;
}
.report-subject { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.report-meta { font-size: 0.82rem; color: var(--text-muted); }
.report-images-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.report-thumb {
    width: 64px; height: 64px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s;
}
.report-thumb:hover { transform: scale(1.05); }

/* =============================================
   Image Upload
   ============================================= */
.upload-zone {
    border: 2px dashed rgba(99,102,241,0.3);
    border-radius: 14px;
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(99,102,241,0.04);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99,102,241,0.1);
}
.upload-zone-icon { font-size: 40px; display: block; margin-bottom: 12px; }
.upload-zone p { color: var(--text-muted); font-size: 0.9rem; }
.upload-zone strong { color: var(--primary-light); }
.upload-previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.preview-item {
    position: relative;
    width: 90px; height: 90px;
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.preview-remove {
    position: absolute;
    top: -6px; right: -6px;
    width: 22px; height: 22px;
    background: var(--danger);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: white;
    border: none;
    line-height: 1;
}

/* =============================================
   Empty State
   ============================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 56px; display: block; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 0.88rem; }

/* =============================================
   Lightbox
   ============================================= */
.lightbox-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.lightbox-overlay.active { display: flex; }
.lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.lightbox-close {
    position: absolute;
    top: 20px; right: 20px;
    width: 40px; height: 40px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    color: white;
    display: flex; align-items: center; justify-content: center;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 16px; }
}

/* =============================================
   Utility
   ============================================= */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary-light); }
.text-success { color: #4ade80; }
.text-danger { color: #f87171; }
.fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 600px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
