/* ==========================================================================
   ระบบบันทึกการใช้งาน Chromebook - โรงเรียนวัดนาวง
   Design System: Modern Educational Tech (Navy Blue, Emerald, Gold Accent)
   ========================================================================== */

:root {
    --primary-dark: #0f172a;
    --primary-blue: #1e3a8a;
    --primary-blue-hover: #1e40af;
    --accent-gold: #f59e0b;
    --accent-gold-light: #fef3c7;
    
    --color-emerald: #10b981;
    --color-emerald-light: #d1fae5;
    --color-purple: #8b5cf6;
    --color-purple-light: #ede9fe;
    --color-amber: #f59e0b;
    --color-rose: #ef4444;
    --color-rose-light: #fee2e2;

    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.85);

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #ffffff;

    --border-color: #e2e8f0;
    --border-focus: #3b82f6;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --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);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Prompt', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

a {
    color: var(--primary-blue);
    text-decoration: none;
    transition: var(--transition-fast);
}

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

/* Header / Navbar */
.main-header {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1d4ed8 100%);
    color: var(--text-light);
    padding: 1.25rem 0;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    transform: rotate(-3deg);
    transition: var(--transition-normal);
}

.brand-box:hover .logo-icon {
    transform: rotate(0deg) scale(1.05);
}

.brand-text h1 {
    font-size: 1.4rem;
    color: #ffffff;
    letter-spacing: -0.01em;
}

.brand-text p {
    font-size: 0.85rem;
    color: #93c5fd;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.date-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: #e0f2fe;
    backdrop-filter: blur(4px);
}

/* Stat Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    transition: var(--transition-normal);
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
}

.stat-card.blue::before { background: var(--primary-blue); }
.stat-card.emerald::before { background: var(--color-emerald); }
.stat-card.purple::before { background: var(--color-purple); }
.stat-card.amber::before { background: var(--color-amber); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-card.blue .stat-icon { background: #dbeafe; color: var(--primary-blue); }
.stat-card.emerald .stat-icon { background: var(--color-emerald-light); color: var(--color-emerald); }
.stat-card.purple .stat-icon { background: var(--color-purple-light); color: var(--color-purple); }
.stat-card.amber .stat-icon { background: var(--accent-gold-light); color: var(--accent-gold); }

.stat-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stat-label {
    font-size: 0.825rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-value small {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
}

.stat-value-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary-blue);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* Content Layout Grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* Form Card */
.form-card, .chart-card, .table-card, .quick-export-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.card-header {
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.85rem;
}

.card-header h3, .card-header h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-blue);
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.form-section-title {
    font-family: 'Prompt', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-blue);
    background: #f8fafc;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-blue);
    margin: 1.25rem 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section-title.highlight {
    background: #eff6ff;
    color: #1d4ed8;
    border-left-color: #2563eb;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.col-6 { flex: 1; min-width: 0; }

@media (max-width: 640px) {
    .form-row {
        flex-direction: column;
        gap: 0.85rem;
    }
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.req {
    color: var(--color-rose);
}

.form-control, .form-control-sm {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-family: 'Sarabun', sans-serif;
    font-size: 0.95rem;
    color: var(--text-primary);
    background-color: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.form-control-sm {
    padding: 0.4rem 0.7rem;
    font-size: 0.85rem;
}

.form-control:focus, .form-control-sm:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

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

/* Image Upload Box */
.image-upload-wrapper {
    position: relative;
}

.file-input-hidden {
    display: none;
}

.file-upload-box {
    border: 2px dashed #cbd5e1;
    background: #f8fafc;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition-normal);
}

.file-upload-box:hover {
    border-color: var(--primary-blue);
    background: #eff6ff;
}

.file-upload-box i {
    font-size: 1.8rem;
    color: var(--primary-blue);
}

.file-upload-box span {
    font-size: 0.9rem;
    font-weight: 500;
}

.file-upload-box small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.image-preview-box {
    position: relative;
    display: inline-block;
    max-width: 240px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--primary-blue);
    margin-top: 0.5rem;
}

.image-preview-box img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.btn-remove-img {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.btn-remove-img:hover {
    background: var(--color-rose);
    transform: scale(1.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Prompt', sans-serif;
    font-weight: 500;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition-normal);
    text-align: center;
    font-size: 0.95rem;
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 0.85rem 1.5rem;
    font-size: 1.05rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1e40af, #1d4ed8);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-outline-light {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.25);
}

.btn-emerald {
    background: var(--color-emerald);
    color: #ffffff;
}

.btn-emerald:hover {
    background: #059669;
}

.btn-purple {
    background: var(--color-purple);
    color: #ffffff;
}

.btn-purple:hover {
    background: #7c3aed;
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

/* Side Panel Cards */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.quick-export-card {
    background: linear-gradient(135deg, #f8fafc, #edf2f7);
}

.quick-export-card h4 {
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
}

.quick-export-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.85rem;
}

.export-btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Table Section */
.table-card {
    overflow: hidden;
}

.table-header-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.85rem;
}

.table-tools {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    width: 240px;
}

.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-box input {
    width: 100%;
    padding: 0.45rem 0.75rem 0.45rem 2.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-family: 'Sarabun', sans-serif;
    font-size: 0.875rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-blue);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.data-table th {
    font-family: 'Prompt', sans-serif;
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem 0.85rem;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.85rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--transition-fast);
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-emerald { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-rose { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

.table-footer-info {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: flex-end;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: #f1f5f9;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: var(--primary-blue);
    color: #ffffff;
}

.btn-icon.danger:hover {
    background: var(--color-rose);
    color: #ffffff;
}

/* Modal Popup */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--bg-card);
    width: 100%;
    max-width: 620px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: #f8fafc;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    color: var(--primary-blue);
}

.btn-close-modal {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 0.85rem 1.25rem;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.detail-row {
    margin-bottom: 0.85rem;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-img {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Prompt', sans-serif;
    font-size: 0.9rem;
    animation: slideUp 0.3s ease-out;
}

.toast.success { border-left: 4px solid var(--color-emerald); }
.toast.info { border-left: 4px solid var(--primary-blue); }
.toast.warning { border-left: 4px solid var(--color-amber); }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Footer */
.main-footer {
    margin-top: auto;
    background: #0f172a;
    color: var(--text-muted);
    padding: 1.25rem 0;
    font-size: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.mt-4 { margin-top: 1.5rem; }
.text-center { text-align: center; }
.text-danger { color: var(--color-rose); }
