/* =========================================================
   TECH COLLEGE - COMPONENTS CSS
   (Headers, Buttons, Tables, Cards, Forms, Modals, Charts)
========================================================= */

/* --- 1. Top App Header --- */
.app-header {
    background: var(--bg-card);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    margin-bottom: 25px;
}
.profile-wrapper { display: flex; align-items: center; gap: 12px; }
.avatar-box {
    width: 45px; height: 45px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 20px;
    box-shadow: 0 4px 10px rgba(6, 182, 212, 0.3);
}
.user-meta h4 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.role-tag { font-size: 11px; background: var(--primary-light); color: var(--primary-dark); padding: 2px 8px; border-radius: 20px; font-weight: 600; display: inline-block; }

/* --- 2. Page Header Actions (แถบชื่อหน้าเพจ & ปุ่มย้อนกลับ) --- */
.page-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}
.section-title { color: #1e293b; margin: 0; font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.icon-primary { color: var(--primary); }

/* --- 3. Buttons & Badges --- */
.btn-logout {
    width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
    background: white; color: var(--secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.btn-logout:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; transform: rotate(90deg); }

.btn-primary { background: var(--primary); color: white; border: none; padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-save { background: #10b981; color: #ffffff; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; transition: all 0.3s; }
.btn-save:hover { background: #059669; }
.btn-save:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-cancel { padding: 10px 20px; border-radius: 8px; border: 1px solid #cbd5e1; background: #ffffff; color: #475569; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn-cancel:hover { background: #f1f5f9; }

.btn-back-premium {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; background: var(--bg-card);
    color: var(--text-main); border-radius: 10px; font-weight: 600; font-size: 0.95rem;
    text-decoration: none; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.btn-back-premium:hover { background: #f1f5f9; color: var(--primary); border-color: var(--primary-light); transform: translateX(-3px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }

.btn-upload-small { background: #f1f5f9; color: #3b82f6; border: 1px solid #cbd5e1; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; transition: all 0.2s; display: inline-flex; align-items: center; gap: 5px; }
.btn-upload-small:hover { background: #e0f2fe; border-color: #3b82f6; }
.btn-remove-small { background: #fee2e2; color: #ef4444; border: 1px solid #fca5a5; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; transition: all 0.2s; display: inline-flex; align-items: center; }
.btn-remove-small:hover { background: #fecaca; }

.btn-icon-edit, .btn-icon-del { width: 32px; height: 32px; border-radius: 8px; border: none; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon-edit { background: #f1f5f9; color: var(--text-main); }
.btn-icon-edit:hover { background: var(--primary-light); color: var(--primary-dark); }
.btn-icon-del { background: #fef2f2; color: #ef4444; }
.btn-icon-del:hover { background: #fecaca; }

.badge { padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; display: inline-block; }
.badge-success { background: #dcfce7; color: #16a34a; }
.badge-danger { background: #fee2e2; color: #ef4444; }

/* --- 4. Action Bar & Data Tables --- */
.action-bar { background: var(--bg-card); padding: 15px; border-radius: 12px; box-shadow: var(--shadow-sm); margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }
.search-box { position: relative; width: 100%; max-width: 350px; }
.search-box i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input { width: 100%; padding: 10px 15px 10px 40px; border: 1px solid var(--border); border-radius: 8px; outline: none; transition: 0.2s; }
.search-input:focus { border-color: var(--primary); }

.table-responsive { width: 100%; overflow-x: auto; background: var(--bg-card); border-radius: 12px; box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; min-width: 800px; }
.data-table th, .data-table td { padding: 15px 20px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: 0.9rem; }
.data-table tr:hover { background: #f8fafc; }

.user-info-row { display: flex; align-items: center; gap: 15px; }
.avatar { width: 35px; height: 35px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.user-details { display: flex; flex-direction: column; }
.user-name { font-weight: 600; color: var(--text-main); }
.user-email { font-size: 0.85rem; color: var(--text-muted); }
.action-buttons { display: flex; gap: 8px; justify-content: flex-end; }

/* --- 5. Cards & Grids --- */
.section-label { font-size: 14px; color: var(--text-muted); font-weight: 500; margin: 25px 0 15px 5px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 30px; }
.stat-card-web { background: white; padding: 20px; border-radius: 20px; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.03); transition: transform 0.2s; }
.stat-card-web:active { transform: scale(0.98); }
.stat-val { font-size: 2rem; font-weight: 700; font-family: 'Outfit', sans-serif; color: var(--primary); line-height: 1; }
.stat-lbl { font-size: 0.85rem; color: #64748b; margin-top: 5px; }

.menu-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 15px; }
.menu-item { background: var(--bg-card); border-radius: 16px; padding: 15px 10px; text-align: center; text-decoration: none; color: var(--text-main); box-shadow: var(--shadow-sm); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); border: 1px solid transparent; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.menu-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-card); border-color: var(--primary-light); }
.menu-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 5px; }
.menu-title { font-size: 12px; font-weight: 500; line-height: 1.3; color: var(--text-main); white-space: nowrap; }

/* --- 6. Forms & Inputs --- */
.setting-form-card-wide { background: #ffffff; border-radius: 12px; padding: 30px; box-shadow: var(--shadow-sm); margin-bottom: 25px; width: 100%; }
.form-group { margin-bottom: 20px; }
.form-row { display: flex; gap: 15px; }
.form-row .half { flex: 1; }
.form-label, label { display: block; margin-bottom: 8px; font-weight: 500; color: #334155; }
.form-control, .input-modern { width: 100%; padding: 10px 15px; border: 1px solid #cbd5e1; border-radius: 8px; font-family: 'Sarabun', sans-serif; transition: all 0.3s; background: #fff; }
.form-control:focus, .input-modern:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1); }
.form-help-text { color: #64748b; margin-top: 5px; display: block; font-size: 0.85rem;}
.form-divider { border: 0; border-top: 1px solid #e2e8f0; margin: 20px 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-actions-right { text-align: right; }

.color-picker { appearance: none; width: 50px; height: 50px; border: none; border-radius: 8px; cursor: pointer; overflow: hidden; }
.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border: none; border-radius: 8px; }
.color-code-display { font-family: monospace; font-size: 1.1rem; color: #475569; background: #f1f5f9; padding: 5px 10px; border-radius: 6px; }

.control-panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 20px; background: #f8fafc; padding: 20px; border-radius: 10px; border: 1px solid #e2e8f0; }
.image-slots-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 20px; }
.image-slot-item { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 15px; display: flex; flex-direction: column; }
.slot-label { font-weight: 600; color: #64748b; margin-bottom: 10px; font-size: 0.9rem; text-align: center; }
.slot-actions { display: flex; justify-content: center; gap: 10px; margin-top: 15px; }
.slot-link-input { margin-top: 15px; padding-top: 15px; border-top: 1px dashed #e2e8f0; }
.img-link-input { font-size: 0.85rem; padding: 8px 12px; }

.image-preview-box { margin-top: 15px; padding: 15px; border: 2px dashed #cbd5e1; border-radius: 8px; text-align: center; background: #f8fafc; }
.image-preview-placeholder { color: #94a3b8; font-size: 0.9rem; }
.preview-img-hidden { display: none; }
.image-preview-box img { max-height: 100px; max-width: 100%; object-fit: contain; }
.file-input-hidden { display: none; }

/* --- 7. Modals & Cropper --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; visibility: hidden; transition: 0.3s; backdrop-filter: blur(4px); padding: 20px; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-sheet { background: #fff; width: 100%; max-width: 550px; border-radius: 16px; padding: 25px; transform: translateY(20px); transition: 0.3s; max-height: 90vh; overflow-y: auto;}
.modal-overlay.active .modal-sheet { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.modal-header h3 { margin: 0; font-size: 1.2rem; }
.icon-btn-plain { border: none; background: none; cursor: pointer; font-size: 1.2rem; color: #94a3b8; transition: 0.2s; }
.icon-btn-plain:hover { color: #ef4444; }

.crop-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.75); z-index: 10000; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.crop-modal-content { background: #ffffff; width: 90%; max-width: 800px; border-radius: 12px; box-shadow: var(--shadow-card); overflow: hidden; display: flex; flex-direction: column; }
.crop-modal-header { padding: 15px 20px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; }
.crop-modal-header h3 { margin: 0; color: #1e293b; font-size: 1.2rem; }
.btn-icon-close { background: transparent; border: none; font-size: 1.5rem; color: #94a3b8; cursor: pointer; transition: color 0.3s; }
.btn-icon-close:hover { color: #ef4444; }
.crop-modal-body { padding: 20px; background: #f8fafc; height: 50vh; min-height: 300px; }
.cropper-container-wrapper { width: 100%; height: 100%; }
.cropper-container-wrapper img { display: block; max-width: 100%; }
.crop-modal-footer { padding: 15px 20px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 10px; }

/* --- 8. Analytics Charts --- */
.analytics-section { margin-bottom: 30px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 20px; margin-top: 15px; }
.chart-card { background: #ffffff; border-radius: 16px; padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid #f1f5f9; display: flex; flex-direction: column; }
.chart-card-title { font-size: 1rem; font-weight: 600; color: #1e293b; margin: 0 0 15px 0; display: flex; align-items: center; gap: 8px; }
.chart-container { position: relative; height: 250px; width: 100%; flex-grow: 1; }

/* --- 9. Loading Overlay --- */
.loading-overlay-fullscreen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #ffffff; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.spinner-ring { width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- 10. Footer Fix --- */
.footer-content { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 30px; padding: 20px 0; width: 100%; }
.footer-logos { display: flex; align-items: center; flex-wrap: wrap; gap: 20px; justify-content: center; }
.footer-logo-img { height: 45px; width: auto; max-width: 120px; object-fit: contain; display: block; transition: transform 0.3s ease; }
.footer-logo-img:hover { transform: scale(1.05); }

/* --- 11. Premium Menu Navigation Styles --- */
.nav-links { display: flex; gap: 20px; align-items: center; list-style: none; margin: 0; padding: 0; }
.nav-links a { text-decoration: none; font-weight: 500; position: relative; color: rgba(255, 255, 255, 0.9); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: inline-block; }
.navbar-solid .nav-links a { color: var(--text-main, #1e293b); }
.nav-style-1 a { padding-bottom: 6px; }
.nav-style-1 a::after { content: ''; position: absolute; width: 100%; height: 2px; bottom: 0; left: 0; background-color: var(--primary); transform: scaleX(0); transform-origin: bottom right; transition: transform 0.3s ease-out; }
.nav-style-1 a:hover::after, .nav-style-1 a.active::after { transform: scaleX(1); transform-origin: bottom left; }
.nav-style-1 a:hover, .nav-style-1 a.active { color: var(--primary) !important; }

/* =========================================================
   RESPONSIVE DESIGN (Mobile-First Alignment)
   คำสั่ง Media Query ต้องอยู่ล่างสุดเสมอ
========================================================= */
@media (max-width: 1200px) { 
    .menu-grid { grid-template-columns: repeat(4, 1fr); } 
}
@media (max-width: 768px) { 
    /* Layouts */
    .page-header-actions { flex-direction: column-reverse; align-items: flex-start; gap: 15px; margin-top: 15px; }
    .action-bar { flex-direction: column; align-items: stretch; gap: 15px; }
    .search-box { max-width: 100%; }
    .form-row { flex-direction: column; gap: 0; }
    
    /* Grids & Cards */
    .menu-grid { grid-template-columns: repeat(3, 1fr); }
    .menu-title { white-space: normal; } 
    .stat-grid { gap: 10px; }
    .chart-grid { grid-template-columns: 1fr; }
    .chart-container { height: 220px; }
    
    /* Footer */
    .footer-content { flex-direction: column; text-align: center; justify-content: center; }
}
@media (max-width: 480px) { 
    .menu-grid { grid-template-columns: repeat(2, 1fr); } 
}