/* ===================================================
   CleanZone - School Cleaning Activity System
   Professional Theme with Thai School Aesthetics
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #1a5632;
    --primary-light: #2d8a4e;
    --primary-dark: #0e3a20;
    --secondary: #d4a843;
    --secondary-light: #f0d078;
    --accent: #e85d3a;
    --bg: #f4f1eb;
    --bg-card: #ffffff;
    --bg-sidebar: #0e3a20;
    --text: #2c2c2c;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e2dc;
    --success: #16a34a;
    --warning: #eab308;
    --danger: #dc2626;
    --info: #2563eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Sarabun', 'Prompt', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, #0a2e18 100%);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

.sidebar-logo {
    font-family: 'Prompt', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--secondary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.sidebar-logo .icon {
    width: 40px; height: 40px;
    background: var(--secondary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

.sidebar-nav { padding: 16px 12px; flex: 1; overflow-y: auto; }

.nav-section-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.35);
    padding: 12px 12px 6px;
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    margin: 2px 0;
    font-size: 0.9rem;
    font-weight: 400;
    transition: var(--transition);
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-link.active {
    background: var(--primary-light);
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(45,138,78,0.3);
}

.nav-link .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary-dark);
}

.user-name { font-size: 0.85rem; font-weight: 500; }
.user-role { font-size: 0.7rem; color: rgba(255,255,255,0.5); }

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 0;
    min-height: 100vh;
}

/* ===== Top Bar ===== */
.topbar {
    background: var(--bg-card);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-family: 'Prompt', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.topbar-breadcrumb {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ===== Content ===== */
.content-area { padding: 28px 32px; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #fafaf8, #f8f6f2);
}

.card-title {
    font-family: 'Prompt', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 24px; }

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}

.stat-icon.green { background: #dcfce7; color: var(--success); }
.stat-icon.blue { background: #dbeafe; color: var(--info); }
.stat-icon.orange { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: var(--danger); }

.stat-number {
    font-family: 'Prompt', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.stat-label { font-size: 0.82rem; color: var(--text-light); margin-top: 2px; }

/* ===== Tables ===== */
.table-container { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

table thead th {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 13px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

table thead th:first-child { border-radius: 8px 0 0 0; }
table thead th:last-child { border-radius: 0 8px 0 0; }

table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

table tbody tr:hover { background: #f8f8f5; }

table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
}

table tbody tr:last-child td:first-child { border-radius: 0 0 0 8px; }
table tbody tr:last-child td:last-child { border-radius: 0 0 8px 0; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }

.btn-secondary { background: var(--secondary); color: var(--primary-dark); }
.btn-secondary:hover { background: var(--secondary-light); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-info { background: var(--info); color: white; }
.btn-info:hover { background: #1d4ed8; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #f0fdf4; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 0.88rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.9rem;
    color: var(--text);
    background: white;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,50,0.1);
}

select.form-control { cursor: pointer; }

textarea.form-control { min-height: 80px; resize: vertical; }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #a16207; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #dbeafe; color: #1d4ed8; }
.badge-secondary { background: #f3f4f6; color: #4b5563; }

/* ===== Alerts ===== */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #dcfce7; color: #15803d; border-left: 4px solid #16a34a; }
.alert-danger { background: #fee2e2; color: #b91c1c; border-left: 4px solid #dc2626; }
.alert-warning { background: #fef3c7; color: #a16207; border-left: 4px solid #eab308; }
.alert-info { background: #dbeafe; color: #1d4ed8; border-left: 4px solid #2563eb; }

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-family: 'Prompt', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.modal-close {
    width: 32px; height: 32px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}

.modal-close:hover { background: #e5e7eb; }

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ===== Checkbox custom ===== */
.check-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
}

.check-item:hover { background: #f0fdf4; }

.check-item input[type="checkbox"] {
    width: 20px; height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* ===== Grid Utilities ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.flex-gap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }

/* ===== Public Page ===== */
.public-page {
    min-height: 100vh;
    background: linear-gradient(160deg, #f4f1eb 0%, #e8e4da 100%);
}

.public-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
    color: white;
    padding: 40px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.public-header::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(212,168,67,0.1) 0%, transparent 60%);
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.public-header h1 {
    font-family: 'Prompt', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    position: relative;
}

.public-header .sub {
    font-size: 1rem;
    opacity: 0.85;
    margin-top: 8px;
    position: relative;
}

.public-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.activity-card {
    background: white;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.activity-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.activity-card-top {
    padding: 20px 22px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
}

.activity-card-top h3 {
    font-family: 'Prompt', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
}

.activity-card-body { padding: 20px 22px; }

.activity-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-light);
    font-size: 0.85rem;
    margin: 8px 0;
}

.activity-meta .icon { font-size: 1rem; }

.qr-section {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px dashed var(--primary-light);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin: 20px 0;
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--primary-dark), var(--primary));
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: rgba(212,168,67,0.08);
    top: -200px; right: -200px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    bottom: -150px; left: -100px;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 44px 40px;
    width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

.login-box h1 {
    font-family: 'Prompt', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 8px;
}

.login-box .subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

/* ===== Attendance specific ===== */
.student-check-list {
    max-height: 500px;
    overflow-y: auto;
}

.student-check-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.student-check-row:hover { background: #f8fdf8; }

.student-check-row.checked { background: #f0fdf4; }

.student-check-row input[type="checkbox"] {
    width: 20px; height: 20px;
    accent-color: var(--primary);
}

.student-code {
    background: #f3f4f6;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: monospace;
    color: var(--primary);
}

/* ===== QR Check-in ===== */
.qr-input-section {
    background: white;
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    box-shadow: var(--shadow);
}

.qr-input-section input {
    font-size: 1.8rem;
    text-align: center;
    padding: 16px;
    letter-spacing: 4px;
    font-weight: 700;
    font-family: 'Prompt', sans-serif;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    width: 300px;
    max-width: 100%;
}

.qr-result {
    margin-top: 20px;
    padding: 20px;
    border-radius: var(--radius);
    display: none;
}

.qr-result.success {
    display: block;
    background: #dcfce7;
    border: 2px solid #16a34a;
    color: #15803d;
}

.qr-result.error {
    display: block;
    background: #fee2e2;
    border: 2px solid #dc2626;
    color: #b91c1c;
}

/* ===== Tab Nav ===== */
.tab-nav {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    font-family: 'Sarabun', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.tab-btn:hover { color: var(--primary); }

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Print Report ===== */
.print-only { display: none; }

@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    
    body { background: white; font-size: 11pt; }
    .sidebar, .topbar { display: none !important; }
    .main-content { margin: 0; padding: 0; }
    .content-area { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    
    .report-header {
        text-align: center;
        padding: 20px 0;
        border-bottom: 3px double #333;
        margin-bottom: 20px;
    }
    
    .report-header h1 { font-size: 16pt; }
    .report-header h2 { font-size: 13pt; font-weight: normal; }
    
    table { page-break-inside: auto; }
    tr { page-break-inside: avoid; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .content-area { padding: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .activity-grid { grid-template-columns: 1fr; }
    .login-box { width: 95%; padding: 30px 24px; }
    .topbar { padding: 12px 16px; }
}

/* ===== Search Box ===== */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 38px;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    color: var(--text);
    transition: var(--transition);
}

.pagination a:hover { background: var(--primary); color: white; border-color: var(--primary); }
.pagination .active { background: var(--primary); color: white; border-color: var(--primary); }

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { color: var(--text-light); margin-bottom: 8px; }
