/* ============================================
   Base Styles - Reset & Foundation
   ============================================ */

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

/* Base Elements */
body {
    font-family: 'Sarabun', 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    font-family: inherit;
}

ul, ol {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.flex { display: flex; }
.flex-center { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}
.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hidden { display: none !important; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

/* Toast Animations */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Dark Theme */
body.dark-theme {
    --bg-primary: #17182b;
    --bg-secondary: #222340;
    --bg-card: #222340;
    --text-primary: #f1f2f6;
    --text-secondary: #a4b0be;
    --text-muted: #6b7280;
    --border: #32345c;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
}

/* Dark Theme Enhancements */
body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea {
    background: var(--bg-primary);
    border-color: var(--border);
    color: var(--text-primary);
}

body.dark-theme input:focus,
body.dark-theme select:focus,
body.dark-theme textarea:focus {
    background: var(--bg-secondary);
}

body.dark-theme table {
    background: var(--bg-card);
}

body.dark-theme thead {
    background: linear-gradient(135deg, #4a3fb5, #6C5CE7);
}

body.dark-theme tbody tr:hover {
    background: rgba(108, 92, 231, 0.15);
}

body.dark-theme .modal-box {
    background: var(--bg-card);
}

body.dark-theme .toast {
    background: var(--bg-card);
    color: var(--text-primary);
}

body.dark-theme .sidebar {
    background: #1a1b32;
}

body.dark-theme .sidebar-logo {
    background: linear-gradient(135deg, #4a3fb5, #6C5CE7);
}

body.dark-theme .sidebar-nav a:hover,
body.dark-theme .sidebar-nav a.active {
    background: rgba(108, 92, 231, 0.2);
}

body.dark-theme .welcome-section {
    background: linear-gradient(135deg, #1a1b32, #2d2e5a);
}

body.dark-theme .profile-cover {
    background: linear-gradient(135deg, #1a1b32, #4a3fb5);
}

body.dark-theme .login-bg .bg-shape {
    background: rgba(108, 92, 231, 0.08);
}

/* Plan Badge */
.plan-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.plan-free {
    background: rgba(178, 190, 195, 0.2);
    color: #636e72;
}

.plan-pro {
    background: rgba(108, 92, 231, 0.15);
    color: #6C5CE7;
}

.plan-school {
    background: rgba(0, 184, 148, 0.15);
    color: #00B894;
}

/* Settings Danger Item */
.setting-item.danger:hover {
    background: rgba(225, 112, 85, 0.08);
}

.setting-item.danger:hover .setting-icon {
    color: var(--danger);
}

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

.empty-state p {
    font-size: 15px;
}

/* Toast Types */
.toast-error {
    background: var(--danger) !important;
}

.toast-success {
    background: var(--success) !important;
}

.toast-info {
    background: var(--primary) !important;
}

/* Unread Badge */
.unread-badge {
    display: inline-block;
    padding: 2px 10px;
    background: var(--danger);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

/* Is Read */
.is-read {
    opacity: 0.6;
}

.is-read:hover {
    opacity: 1;
}

/* ============================================
   PJAX Progress Bar (นำทางแบบไม่ reload)
   ============================================ */
#pjax-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, var(--primary), #9d7bff);
    z-index: 99999;
    border-radius: 0 2px 2px 0;
    box-shadow: 0 0 8px rgba(124, 77, 255, 0.6);
    pointer-events: none;
}

/* เปลี่ยนหน้าแบบนุ่มนวล */
main.main-content {
    animation: pjaxFadeIn .18s ease;
}
@keyframes pjaxFadeIn {
    from { opacity: 0.4; }
    to   { opacity: 1; }
}
