/* ---
Modern Maroon Theme for Teaching Load App
--- */

/* --- Font Import --- */

/* --- CSS Variables for Theming --- */
:root {
    --font-sans: 'Sarabun', sans-serif;
    --primary-color: #8C1D2F; /* Deep Maroon */
    --primary-hover: #A82339;
    --primary-dark: #6a1624;
    --primary-bg: #F9EAEB; /* Light Maroon for backgrounds */
    --text-on-primary: #FFFFFF;
    --text-color: #334155; /* slate-700 */
    --text-light: #64748b; /* slate-500 */
    --border-color: #e2e8f0; /* slate-200 */
    --bg-light: #f8fafc; /* slate-50 */
    --bg-white: #ffffff;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.1);
}

/* --- Base Styles --- */
body {
    font-family: var(--font-sans);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- Main App Layout --- */
#app-container {
    display: flex;
    min-height: 100vh;
}
#app-container.hidden {
    display: none;
}
.content-section { display: none; }
.content-section.active { display: block; animation: fadeIn 0.5s ease-in-out; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Sidebar Navigation --- */
.nav-link, .nav-group-summary {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    color: var(--text-light);
    transition: background-color 0.2s, color 0.2s;
    cursor: pointer;
}
.nav-link:hover, .nav-group-summary:hover {
    background-color: var(--primary-bg);
    color: var(--primary-dark);
}
.nav-link.active {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    box-shadow: var(--shadow);
}
.nav-link.active:hover {
    background-color: var(--primary-hover);
}
.nav-link svg, .nav-group-summary svg {
    margin-right: 0.75rem;
    flex-shrink: 0;
}
.nav-group[open] > .nav-group-summary {
    background-color: var(--primary-bg);
    color: var(--primary-dark);
}
.nav-link-sub {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem 0.5rem 2rem; /* Adjusted for icon */
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-light);
    position: relative;
}
.nav-link-sub:hover {
    color: var(--primary-dark);
}
.nav-link-sub.active {
    color: var(--primary-color);
    font-weight: 600;
}
.nav-link-sub svg {
    margin-right: 0.75rem;
    flex-shrink: 0;
    color: #94a3b8; /* slate-400 */
    transition: all 0.2s;
}

.nav-link-sub:hover svg, .nav-link-sub.active svg {
    color: var(--primary-color);
}
.nav-link-sub::before {
    content: none; /* Removed dot */
}

/* --- General UI Components --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.page-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.action-button {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.action-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.action-button-secondary {
    background-color: var(--bg-white);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: calc(0.6rem - 1px) calc(1.25rem - 1px);
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.action-button-danger {
    background-color: #dc2626; /* red-600 */
    color: var(--text-on-primary);
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.action-button-danger:hover {
    background-color: #b91c1c; /* red-700 */
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}


.data-card {
    background-color: var(--bg-white);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.data-table-wrapper {
    display: flex;
    flex-direction: column;
}

.data-table-wrapper .overflow-x-auto {
    flex-grow: 1;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--bg-light);
    transition: all 0.2s;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-white);
    box-shadow: 0 0 0 2px var(--primary-bg);
}

/* --- Table Styles --- */
.styled-table {
    width: 100%;
    text-align: left;
    font-size: 0.875rem;
}
.styled-table thead {
    background-color: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}
.styled-table th {
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.styled-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}
.styled-table tbody tr:last-child {
    border-bottom: none;
}
.styled-table tbody tr:hover {
    background-color: var(--primary-bg);
}
.styled-table td {
    padding: 1rem;
    vertical-align: middle;
}

/* --- Pagination Styles --- */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem 1rem;
    gap: 0.5rem;
}
.pagination-btn {
    border: 1px solid var(--border-color);
    background-color: var(--bg-white);
    color: var(--text-light);
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.pagination-btn:hover:not(:disabled) {
    background-color: var(--primary-bg);
    color: var(--primary-dark);
    border-color: var(--primary-bg);
}
.pagination-btn.active {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    border-color: var(--primary-color);
    font-weight: 600;
}
.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* --- Form & Modal Styles --- */
.form-field-group {
    display: flex;
    flex-direction: column;
}
.form-field-group label {
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-light);
}
.form-field-group input,
.form-field-group select {
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--bg-light);
    transition: all 0.2s;
}
.form-field-group input:focus,
.form-field-group select:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-bg);
    border-color: var(--primary-color);
    background-color: var(--bg-white);
}

/* --- Timetable --- */
.timetable-grid {
    display: grid;
    grid-template-columns: 100px repeat(10, 1fr);
    gap: 2px;
    grid-auto-rows: minmax(80px, auto);
}
.timetable-slot {
    position: relative;
    background-color: #f8fafc;
    border-radius: 4px;
    padding: 4px;
    font-size: 0.75rem;
    line-height: 1.2;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.timetable-header {
    font-weight: 600;
    text-align: center;
    padding: 8px 4px;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    font-size: 0.8rem;
}
.timetable-day-header {
    font-weight: 600;
    font-size: 0.9rem;
    color: #475569;
    text-align: center;
    padding: 8px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
}
.timetable-class-item {
    width: 100%;
    height: 100%;
    background-color: var(--primary-bg);
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    padding: 6px 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: var(--primary-dark);
}

/* --- Flatpickr Week Highlight --- */
.flatpickr-day.in-hover-week {
    background: #fde6e9 !important; 
    border-color: #fde6e9 !important;
    cursor: pointer;
}
.flatpickr-day.in-selected-week {
    background: var(--primary-bg);
    border-color: var(--primary-bg);
    color: var(--primary-dark);
}
.flatpickr-day.selected.in-selected-week, 
.flatpickr-day.startRange.in-selected-week, 
.flatpickr-day.endRange.in-selected-week {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--text-on-primary) !important;
}

/* --- Toast Notification Styles --- */
#toast-container {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 24rem;
}
.toast {
    background-color: #10B981; /* Emerald-500 */
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s cubic-bezier(0.215, 0.610, 0.355, 1);
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast.hide {
    opacity: 0;
}

.toast.success {
    background-color: #10B981; /* Emerald-500 */
    color: white;
}

.toast.warning {
    background-color: #FBBF24; /* Amber-400 */
    color: #422006; /* Amber-900 text for better contrast */
}

/* --- Responsive Mobile Menu Styles --- */
#sidebar.is-open {
    transform: translateX(0);
}
@media (min-width: 768px) {
    #sidebar {
        transform: translateX(0) !important;
    }
}

/* --- Select2 Theme Overrides --- */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--border-color) !important;
    border-radius: 0.5rem !important;
    padding: 0.25rem 0.5rem;
    min-height: 42px;
    background-color: var(--bg-light);
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 40px !important;
}
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--multiple {
    box-shadow: 0 0 0 2px var(--primary-bg);
    border-color: var(--primary-color) !important;
    background-color: var(--bg-white);
}
.select2-dropdown {
    border-radius: 0.5rem !important;
    border-color: var(--border-color) !important;
    z-index: 9999 !important;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--primary-color) !important;
    color: var(--text-on-primary) !important;
}
.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--primary-bg) !important;
    color: var(--primary-dark) !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--primary-bg) !important;
    border: 1px solid var(--primary-color) !important;
    color: var(--primary-dark) !important;
    border-radius: 0.5rem !important;
    padding: 3px 6px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--primary-dark) !important;
    margin-right: 5px !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: var(--primary-color) !important;
}
.select2-container .select2-selection--single .select2-selection__rendered {
    padding-left: 0.5rem !important;
    padding-right: 1.5rem !important;
    line-height: 30px;
}

/* --- Timetable Visual Editor Styles --- */
.editor-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    align-items: start;
}

.subject-palette {
    position: sticky;
    top: 1.5rem;
    background-color: var(--bg-white);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1rem;
    max-height: 80vh;
    overflow-y: auto;
}

.unscheduled-subject {
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    user-select: none;
    border-left: 4px solid #cbd5e1; /* slate-300 */
}
.unscheduled-subject .subject-name {
    font-weight: bold;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}
.unscheduled-subject .subject-details {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}
.unscheduled-subject.draggable {
    cursor: grab;
}
.unscheduled-subject.draggable:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.unscheduled-subject.is-dragging {
    cursor: grabbing;
    opacity: 0.8;
    background: var(--primary-bg);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}
.unscheduled-subject.disabled {
    cursor: not-allowed;
    background-color: #f1f5f9; /* slate-100 */
    opacity: 0.7;
}
.unscheduled-subject.all-placed {
    background-color: #f1f5f9; /* slate-100 */
    opacity: 0.6;
}
.unscheduled-subject.all-placed .subject-name {
    text-decoration: line-through;
}

.timetable-editor-grid {
    display: grid;
    grid-template-columns: 80px repeat(10, 1fr);
    
    /* แก้ไขจาก: 40px repeat(5, 80px) */
    /* เป็น: */
    grid-template-rows: 40px 40px repeat(5, 80px);

    gap: 2px;
    background-color: var(--border-color);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
}
.editor-grid-header, .editor-grid-day {
    background-color: #f1f5f9; /* slate-100 */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.25rem;
}
.editor-grid-slot {
    background-color: var(--bg-white);
    transition: background-color 0.1s ease-in-out;
    position: relative;
    padding: 2px;
    cursor: pointer;
}
.editor-grid-slot.drop-active {
    background-color: #dcfce7 !important; /* green-100 */
    outline: 2px dashed #22c55e; /* green-500 */
    outline-offset: -2px;
}
.editor-grid-slot.conflict-preview {
    background-color: #fee2e2; /* red-100 */
    cursor: not-allowed;
    position: relative;
}
.editor-grid-slot.conflict-preview::after {
    content: '✖';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: #ef4444; /* red-500 */
    opacity: 0.5;
    z-index: 10;
}

.item-content {
  flex-grow: 1;
  margin-top: 1px;
  min-height: 0;
}
.subject-code {
  font-weight: 700;
  flex-grow: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.teacher-name {
  font-size: 0.75rem;
  color: #64748b;
}

.item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  flex-shrink: 0;
}
.room-assignment-btn {
  font-size: 0.8rem;
  color: #2563eb;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.room-assignment-btn:hover { text-decoration: underline; }

.action-icon {
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: none; border: none; cursor: pointer;
}

.action-icon:hover {
  background-color: #f1f5f9;
}

.group-management-icon-btn {
  font-size: 1.25rem;
  color: #4b5563;
}
.group-management-icon-btn.co-teaching { color: #2563eb; }

.scheduled-item {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 4px 6px;
  border-radius: 6px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  cursor: grab;
}

.scheduled-item:active {
    cursor: grabbing;
}

.scheduled-item:hover {
  z-index: 10;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.item-header {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.item-header .remove-item-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 1.5rem;
  font-weight: bold;
  opacity: 0;
  padding: 0;
  line-height: 1;
  transition: opacity 0.2s ease-in-out;
}

/* --- Skeleton Loading Styles --- */
@keyframes skeleton-loading {
    0% { background-color: #e2e8f0; }
    100% { background-color: #f1f5f9; }
}

.skeleton {
    animation: skeleton-loading 1s linear infinite alternate;
    border-radius: 0.25rem;
}

.skeleton-table-row td {
    padding: 1rem;
    vertical-align: middle;
}

.skeleton-table-row .skeleton {
    height: 20px;
    width: 90%;
    border-radius: 0.25rem;
}


@media (max-width: 1024px) {
    .editor-container {
        grid-template-columns: 1fr;
    }
    .subject-palette {
        position: relative;
        top: 0;
        max-height: none;
    }
}

.wizard-step {
    background-color: var(--bg-white);
    padding: 1.5rem 2rem;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}
.wizard-step h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.wizard-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    font-weight: 700;
    margin-right: 0.75rem;
}

.progress-bar-bg {
    background-color: #e2e8f0;
    border-radius: 9999px;
    height: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background-color: #cbd5e1;
    border-radius: 9999px;
    transition: width 0.3s ease-in-out, background-color 0.3s ease-in-out;
}

.progress-bar-fill.is-in-progress {
    background-color: var(--primary-color);
}

.progress-bar-fill.is-complete {
    background-color: #22c55e;
}

.unscheduled-subject.draggable {
    border-left-color: var(--primary-color);
}

.unscheduled-subject.all-placed {
    border-left-color: #22c55e;
}

.scheduled-item .room-assignment-btn {
    color: var(--primary-color);
    font-weight: 500;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.scheduled-item:hover .room-assignment-btn {
    opacity: 1;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    user-select: none;
}

.action-button-group {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.action-icon-btn {
    background-color: transparent;
    border: none;
    padding: 0.375rem;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
}

.action-icon-btn svg {
    width: 1.125rem;
    height: 1.125rem;
}

.action-icon-btn.assign:hover {
    background-color: #ffd2f7;
    color: #81299c;
}

.action-icon-btn.delete:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

#term-selector optgroup {
    font-weight: bold;
    color: var(--primary-dark);
}

#term-selector option {
    font-weight: normal;
    color: var(--text-color);
    padding: 0.25rem 0.5rem;
}


.toggle-switch-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8fafc;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

input:focus + .toggle-slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.scheduled-item.locked {
  background-color: #e5e7eb;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(156, 163, 175, 0.15),
    rgba(156, 163, 175, 0.15) 8px
  );
  opacity: 0.8;
  border: 1px solid #d1d5db;
  cursor: not-allowed;
}

.scheduled-item.locked:hover {
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transform: none;
}

.scheduled-item.locked .subject-code,
.scheduled-item.locked .teacher-name {
  color: #374151;
}

.scheduled-item.locked .subject-code {
  color: #475569;
}

.scheduled-item.locked .action-icon:hover,
.scheduled-item.locked .room-assignment-btn:hover {
  background-color: transparent;
  text-decoration: none;
}

.scheduled-item.locked .lock-item-btn:hover {
  background-color: transparent;
}

.scheduled-item:hover .lock-item-btn {
    opacity: 1;
}

.scheduled-item.locked .lock-item-btn {
    color: var(--primary-dark);
    opacity: 1;
}

.editor-grid-slot.slot-suitable {
    background-color: #f0fdf4;
    border: 1px dashed #4ade80;
}

.editor-grid-slot.slot-warning-room {
    background-color: #fefce8;
    border: 1px dashed #facc15;
}
.editor-grid-slot.slot-conflict {
    background-color: #fef2f2;
    cursor: not-allowed;
}

.constraint-panel-content {
    animation: fadeIn 0.3s ease-in-out;
}

.constraint-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.blueprint-item.bg-yellow-200 {
    background-color: #fef08a;
}

@keyframes animate-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-in {
    animation: animate-fade-in 0.5s ease-in-out;
}

.wizard-container {
    max-width: 1400px;
    margin: 0 auto;
}

@keyframes highlight-fade {
  from {
    background-color: #dbeafe;
  }
  to {
    background-color: transparent;
  }
}

tr.highlight-new {
  animation: highlight-fade 3s ease-in-out;
  background-color: #dbeafe !important; 
}

.scheduled-item .insertion-controls {
    position: absolute;
    top: 50%;
    left: -12px;
    right: -12px;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.scheduled-item:hover .item-header .remove-item-btn { opacity: 1; }

.scheduled-item:hover .insertion-controls {
    opacity: 1;
    pointer-events: auto;
}

.insert-slot-btn {
    background-color: #3b82f6;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: background-color 0.2s;
}

.insert-slot-btn:hover {
    background-color: #2563eb;
}

.insert-slot-btn:disabled {
    background-color: #d1d5db;
    cursor: not-allowed;
}

.insert-left {
    transform: translateX(-50%);
}

.insert-right {
    transform: translateX(50%);
}

.editor-grid-slot.blackout-active {
    background-color: #e5e7eb;
    background-image: repeating-linear-gradient(
        45deg,
        #d1d5db,
        #d1d5db 10px,
        #e5e7eb 10px,
        #e5e7eb 20px
    );
    cursor: not-allowed;
    border: 1px solid #9ca3af;
}

.editor-grid-slot.blackout-active.conflict-preview::after,
.editor-grid-slot.blackout-active.slot-conflict::after {
    content: '✖';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    color: #ef4444;
    opacity: 0.7;
    z-index: 10;
    text-shadow: 0 0 3px white;
}

.scheduled-item .subject-name {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
}

/* --- [REFACTORED] Minimalist Print Styles --- */
.pdf-export-mode {
    font-size: 10px; /* ลดขนาดตัวอักษรลงอีก */
    color: #000000;
}

.pdf-export-mode .timetable-grid {
    grid-auto-rows: minmax(50px, auto); /* ลดความสูงของแถว */
    gap: 1px;
    border: 1px solid #000;
}

.pdf-export-mode .timetable-header,
.pdf-export-mode .timetable-day-header,
.pdf-export-mode .timetable-slot {
    background-color: #ffffff !important;
    border: 0.5px solid #cccccc; /* ใช้เส้นบางๆ */
    padding: 2px 4px;
    font-size: 9px;
    border-radius: 0;
}

.pdf-export-mode .timetable-class-item {
    background-color: #ffffff !important;
    border: none;
    border-radius: 0;
    box-shadow: none;
    color: #000000;
    padding: 2px;
    height: 100%;
    width: 100%;
}

.pdf-export-mode .timetable-class-item strong,
.pdf-export-mode .timetable-class-item p {
    font-size: 9px !important;
    line-height: 1.1 !important;
    margin-top: 1px;
}

/* ซ่อน Element ที่ไม่ต้องการทั้งหมด */
.pdf-export-mode .summary-table-container,
.pdf-export-mode .mt-8,
.pdf-export-mode .mt-6,
.pdf-export-mode .action-button-secondary {
    display: none !important;
}

@keyframes wave {
 0% { background-position: 0% 50%; }
 50% { background-position: 100% 50%; }
 100% { background-position: 0% 50%; }
}

.editor-grid-slot.slot-co-teach {
  position: relative;
  background-color: #dbeafe;
  overflow: hidden;
  cursor: copy;
  outline: 2px dashed #3b82f6;
  outline-offset: -2px;
}

.editor-grid-slot.slot-co-teach::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: sweep 2.5s infinite linear;
}

@keyframes sweep {
  from { left: -100%; }
  to { left: 100%; }
}

/* --- [MODIFIED] Workload Settings Table UI --- */
.workload-rules-table td {
    padding: 0.5rem;
    vertical-align: middle;
}
.workload-rules-table input {
    width: 100%;
    text-align: center;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
}
.workload-rules-table input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-bg);
    border-color: var(--primary-color);
}
.workload-rules-table input.total-auto-calc {
    background-color: #f1f5f9; /* slate-100 */
    font-weight: 600;
    color: var(--text-color);
    border-style: dashed;
}

/* --- [NEW] Tooltip Styles --- */
.tooltip-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 9999px;
    background-color: #e2e8f0; /* slate-200 */
    color: #64748b; /* slate-500 */
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.5rem;
    cursor: help;
    transition: all 0.2s;
}

.tooltip-trigger:hover {
    background-color: var(--primary-color);
    color: white;
}

.tooltip-trigger::before, .tooltip-trigger::after {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
    z-index: 1000;
}

.tooltip-trigger::before {
    content: attr(data-tooltip);
    background-color: #1e293b; /* slate-800 */
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    width: max-content;
    max-width: 250px;
    margin-bottom: 8px; /* Space for the arrow */
    text-align: center;
}

.tooltip-trigger::after {
    content: '';
    border: 5px solid transparent;
    border-top-color: #1e293b; /* slate-800 */
    margin-bottom: -2px;
}

.tooltip-trigger:hover::before, .tooltip-trigger:hover::after {
    opacity: 1;
    visibility: visible;
}

[data-role-required] {
    display: none;
}

/* นำโค้ดนี้ไปเพิ่มที่ท้ายไฟล์ public/css/style.css */

/* --- [FIX] Prevent Menu Flicker on Load --- */
#main-nav.permissions-loading .nav-link,
#main-nav.permissions-loading .nav-group {
    display: none;
}

main.overflow-y-auto {
    overflow-y: scroll;
}

/* public/css/style.css */

/* --- [NEW] Styles for Upgraded Subject Library --- */

.library-subject-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.library-subject-item:hover {
    background-color: var(--primary-bg);
}

.library-subject-checkbox {
    width: 1rem;
    height: 1rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.library-subject-info {
    flex-grow: 1;
}

/* --- [NEW] Styles for Student Group Wizard Display --- */
.wizard-group-display {
    margin-top: 1rem;
}

.wizard-level-title {
    font-size: 1rem; /* 16px */
    font-weight: 700;
    color: var(--primary-dark);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.wizard-year-group {
    margin-bottom: 1rem;
}

.wizard-year-title {
    font-size: 0.875rem; /* 14px */
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

.wizard-group-pill {
    display: block;
    padding: 0.5rem;
    border-radius: 0.375rem; /* rounded-md */
    background-color: #eef2ff; /* indigo-50 */
    color: #3730a3; /* indigo-800 */
    font-size: 0.8rem;
    text-align: center;
    font-weight: 500;
    border: 1px solid #e0e7ff; /* indigo-200 */
}

/* --- [NEW] Styles for Refactored Leave Form --- */

.leave-schedule-item {
    display: flex;
    align-items: flex-start; /* Align items to the top */
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-white);
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.leave-schedule-item:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-bg);
}

.leave-schedule-item.selected {
    background-color: var(--primary-bg);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

.leave-schedule-checkbox {
    margin-top: 0.25rem; /* Align checkbox with the first line of text */
    margin-right: 0.75rem;
    height: 1.25rem;
    width: 1.25rem;
    flex-shrink: 0;
    border-radius: 0.25rem;
    border-color: #94a3b8;
    color: var(--primary-color);
}

.leave-schedule-info {
    display: flex;
    flex-direction: column;
}

.leave-subject-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
}

.leave-subject-level {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-on-primary);
    background-color: var(--primary-color);
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    margin-left: 0.5rem;
}

.leave-details,
.leave-groups {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

.leave-groups {
    word-break: break-word;
}

/* --- [NEW] Workload Bar Styles for Summary Page --- */

.workload-bar-container {
    width: 100%;
    margin-top: 4px;
}

.workload-bar {
    position: relative;
    width: 100%;
    height: 8px;
    background-color: #e2e8f0; /* slate-200 */
    border-radius: 8px;
    overflow: hidden;
}

.workload-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 8px;
    transition: width 0.3s ease-in-out;
}

.workload-bar-over {
    position: absolute;
    top: 0;
    left: 100%;
    height: 100%;
    background-color: #ef4444; /* red-500 */
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    transition: width 0.3s ease-in-out;
}

/* ตรวจสอบว่ามีคลาสนี้ใน style.css ของคุณ */
/* (จากไฟล์ที่ให้มา มีอยู่แล้ว) */

.action-button-secondary {
    background-color: var(--bg-white);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: calc(0.6rem - 1px) calc(1.25rem - 1px);
    border-radius: 0.5rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.action-button-secondary:hover {
    background-color: var(--primary-bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* public/css/style.css */

/* --- New Time Slot UI for Makeup Lessons --- */

.time-slots-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem; /* 12px */
  padding: 0.5rem; /* 8px */
  border: 1px solid #e2e8f0; /* slate-200 */
  border-radius: 0.5rem; /* rounded-lg */
  background-color: #f8fafc; /* slate-50 */
  max-height: 250px;
  overflow-y: auto;
}

.time-slot {
  display: flex;
  flex-direction: column;
  padding: 0.75rem; /* 12px */
  border-radius: 0.375rem; /* rounded-md */
  border: 1px solid transparent;
  transition: all 0.2s ease-in-out;
  text-align: center;
}

.time-slot-period {
  font-weight: 600; /* semibold */
  font-size: 1rem; /* text-base */
}

.time-slot-time {
  font-size: 0.875rem; /* text-sm */
  color: #64748b; /* slate-500 */
}

.time-slot-status {
  margin-top: 0.5rem; /* 8px */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem; /* text-xs */
  font-weight: 500; /* medium */
}
.time-slot-status svg {
  margin-right: 0.25rem; /* 4px */
}
.time-slot-status span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Available Slot Styles --- */
.time-slot.available {
  background-color: #ffffff; /* white */
  border-color: #cbd5e1; /* slate-300 */
  cursor: pointer;
}
.time-slot.available:hover {
  border-color: #6366f1; /* primary */
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); /* ring-primary-light */
  transform: translateY(-2px);
}
.time-slot.available .time-slot-status {
  color: #16a34a; /* green-600 */
}

/* --- Selected Slot Style --- */
.time-slot.available.selected {
  border-color: #4f46e5; /* primary-dark */
  background-color: #eef2ff; /* primary-bg */
  color: #312e81; /* primary-darkest */
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.time-slot.available.selected .time-slot-status {
    color: #4f46e5;
    font-weight: 700;
}


/* --- Unavailable Slot Styles --- */
.time-slot.unavailable {
  background-color: #f1f5f9; /* slate-100 */
  border-color: #e2e8f0; /* slate-200 */
  opacity: 0.7;
  cursor: not-allowed;
}
.time-slot.unavailable .time-slot-period,
.time-slot.unavailable .time-slot-time {
  color: #94a3b8; /* slate-400 */
}
.time-slot.unavailable .time-slot-status {
  color: #ef4444; /* red-500 */
}

/* --- [NEW] Subject Color Coding System --- */

/* Define a palette of 12 accessible and pleasant colors */
:root {
    --subject-color-1: #3b82f6; --subject-bg-1: #dbeafe; /* Blue */
    --subject-color-2: #16a34a; --subject-bg-2: #dcfce7; /* Green */
    --subject-color-3: #f97316; --subject-bg-3: #ffedd5; /* Orange */
    --subject-color-4: #8b5cf6; --subject-bg-4: #ede9fe; /* Violet */
    --subject-color-5: #d946ef; --subject-bg-5: #fce7f3; /* Fuchsia */
    --subject-color-6: #14b8a6; --subject-bg-6: #ccfbf1; /* Teal */
    --subject-color-7: #eab308; --subject-bg-7: #fefce8; /* Yellow */
    --subject-color-8: #ec4899; --subject-bg-8: #fce7f3; /* Pink */
    --subject-color-9: #6366f1; --subject-bg-9: #e0e7ff; /* Indigo */
    --subject-color-10: #0ea5e9; --subject-bg-10: #e0f2fe; /* Sky */
    --subject-color-11: #f43f5e; --subject-bg-11: #ffe4e6; /* Rose */
    --subject-color-12: #65a30d; --subject-bg-12: #ecfccb; /* Lime */
}

/* Base style for all colored items */
.subject-color-base {
    background-color: var(--subject-bg);
    border-left: 4px solid var(--subject-color);
    color: var(--subject-text-color);
}

/* Generate classes for each color in the palette */
.subject-color-1 { --subject-color: var(--subject-color-1); --subject-bg: var(--subject-bg-1); --subject-text-color: #1e3a8a; }
.subject-color-2 { --subject-color: var(--subject-color-2); --subject-bg: var(--subject-bg-2); --subject-text-color: #14532d; }
.subject-color-3 { --subject-color: var(--subject-color-3); --subject-bg: var(--subject-bg-3); --subject-text-color: #7c2d12; }
.subject-color-4 { --subject-color: var(--subject-color-4); --subject-bg: var(--subject-bg-4); --subject-text-color: #4c1d95; }
.subject-color-5 { --subject-color: var(--subject-color-5); --subject-bg: var(--subject-bg-5); --subject-text-color: #86198f; }
.subject-color-6 { --subject-color: var(--subject-color-6); --subject-bg: var(--subject-bg-6); --subject-text-color: #0f766e; }
.subject-color-7 { --subject-color: var(--subject-color-7); --subject-bg: var(--subject-bg-7); --subject-text-color: #854d0e; }
.subject-color-8 { --subject-color: var(--subject-color-8); --subject-bg: var(--subject-bg-8); --subject-text-color: #9d174d; }
.subject-color-9 { --subject-color: var(--subject-color-9); --subject-bg: var(--subject-bg-9); --subject-text-color: #312e81; }
.subject-color-10 { --subject-color: var(--subject-color-10); --subject-bg: var(--subject-bg-10); --subject-text-color: #0c4a6e; }
.subject-color-11 { --subject-color: var(--subject-color-11); --subject-bg: var(--subject-bg-11); --subject-text-color: #881337; }
.subject-color-12 { --subject-color: var(--subject-color-12); --subject-bg: var(--subject-bg-12); --subject-text-color: #365314; }

/* Apply styles to scheduled items */
.scheduled-item.subject-color-base {
    background-color: var(--subject-bg);
    border: 1px solid var(--subject-bg);
    border-left: 4px solid var(--subject-color);
}
.scheduled-item.subject-color-base .subject-code,
.scheduled-item.subject-color-base .teacher-name {
    color: var(--subject-text-color);
}
.scheduled-item.subject-color-base .room-assignment-btn {
    color: var(--subject-color);
    font-weight: 600;
}

/* Apply styles to unscheduled items in the palette */
.unscheduled-subject.subject-color-base {
    border-left-color: var(--subject-color);
    background-color: var(--subject-bg);
}
.unscheduled-subject.subject-color-base .subject-name {
    color: var(--subject-text-color);
}
.unscheduled-subject.all-placed.subject-color-base {
    border-left-color: #22c55e;
    background-color: #f1f5f9;
}
.unscheduled-subject.all-placed.subject-color-base .subject-name {
    color: var(--text-color);
}

/* public/css/style.css */

/* --- [NEW] Hover Highlight Interaction --- */
.scheduled-item.subject-highlight,
.unscheduled-subject.subject-highlight {
    transform: scale(1.03);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.7); /* A pleasant blue glow */
    z-index: 20;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
}

/* Add a subtle lift effect for items in the palette */
.unscheduled-subject.subject-highlight {
    transform: translateY(-2px) scale(1.02);
}

/* Ensure the base elements have a relative position for z-index to work correctly */
.scheduled-item, .unscheduled-subject {
    position: relative;
}

/* Add to your main stylesheet e.g., styles.css */

/* --- Holiday Calendar Upgrades --- */
.flatpickr-day.has-holiday {
    position: relative;
    color: #b91c1c; /* A slightly darker red for the date number */
    font-weight: bold;
}

.holiday-dot {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background-color: #ef4444; /* Red dot */
    border-radius: 50%;
}

/* Highlight effect when hovering list item */
.flatpickr-day.is-hovered {
    background-color: #e0f2fe; /* Light blue background */
    border-color: #0ea5e9;
    color: #0369a1;
}
.flatpickr-day.is-hovered .holiday-dot {
    background-color: #0369a1; /* Darker blue dot on hover */
}


/* --- Holiday List Upgrades --- */
.holiday-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.holiday-list-item:hover {
    background-color: #f8fafc; /* Very light grey on hover */
}

.date-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background-color: #f1f5f9; /* Light grey background for the badge */
    margin-right: 12px;
    border: 1px solid #e2e8f0;
}

.date-badge .day-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-badge .day-number {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

/* Styling for conflicting schedule items */
.scheduled-item.item-conflict-error {
    border: 2px solid #ef4444; /* red-500 */
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    animation: pulse-red 1.5s infinite;
}

.conflict-indicator {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 20px;
    height: 20px;
    background-color: #ef4444; /* red-500 */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    z-index: 10;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    }
    50% {
        box-shadow: 0 0 16px rgba(239, 68, 68, 0.8);
    }
    100% {
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    }
}
/* public/css/style.css */
/* --- [NEW] Hide sidebar in editor mode --- */
#app-container.editor-mode #sidebar {
    display: none;
}

/* public/css/style.css */
/* --- [NEW] Timetable Editor Scaling Adjustments --- */

/* 1. ลดขนาด Palette ด้านซ้าย */
#timetableEditor-section .editor-container {
    /* จากเดิม 280px เหลือ 240px */
    grid-template-columns: 240px 1fr;
}

#timetableEditor-section .unscheduled-subject .subject-name {
    font-size: 0.8rem; /* ลดขนาดชื่อวิชาใน Palette เล็กน้อย */
}

#timetableEditor-section .unscheduled-subject .subject-details {
    font-size: 0.7rem; /* ลดขนาดรหัสวิชาใน Palette เล็กน้อย */
}

/* 2. ปรับสเกลตารางสอนหลักให้เล็กลง */
#timetableEditor-section .timetable-editor-grid {
    /* ลดความกว้างคอลัมน์วัน และกำหนดความกว้างขั้นต่ำของคาบให้เล็กลง */
    grid-template-columns: 60px repeat(10, minmax(75px, 1fr));
    /* ลดความสูงของแถวหัวตารางและแถวคาบเรียน */
    grid-template-rows: 35px 35px repeat(5, 75px);
}

/* 3. ลดขนาดฟอนต์รหัสวิชาในคาบเรียน และองค์ประกอบอื่นๆ */
#timetableEditor-section .scheduled-item {
    padding: 3px 5px; /* ลดช่องว่างภายใน */
}

#timetableEditor-section .scheduled-item .subject-code {
    font-size: 0.75rem; /* 12px - ขนาดใหม่ของรหัสวิชา */
    font-weight: 600; /* ลดความหนาลงเล็กน้อย */
}

#timetableEditor-section .scheduled-item .teacher-name {
     font-size: 0.7rem; /* 11.2px */
}

#timetableEditor-section .scheduled-item .room-assignment-btn {
    font-size: 0.7rem; /* 11.2px */
}

#timetableEditor-section .editor-grid-header,
#timetableEditor-section .editor-grid-day {
    font-size: 0.8rem; /* ลดขนาดฟอนต์หัวตาราง */
}

/* --- [NEW] Adjust font size for selected teachers in the palette --- */
#timetableEditor-section #subject-palette .select2-selection__choice {
    font-size: 0.75rem; /* 12px */
    padding: 2px 5px; /* ลดช่องว่างภายในเล็กน้อยเพื่อให้สมดุล */
}

/* --- [NEW] Portal Timetable Item Standardization --- */
.timetable-class-item {
    display: flex;
    flex-direction: column;
    justify-content: center; /* จัดให้อยู่กึ่งกลางแนวตั้ง */
    align-items: center; /* จัดให้อยู่กึ่งกลางแนวนอน */
    text-align: center;
    height: 100%; /* ทำให้เต็มความสูงของช่อง */
    padding: 4px;
    overflow: hidden; /* ซ่อนส่วนที่ล้น */
    line-height: 1.2; /* ลดระยะห่างระหว่างบรรทัด */
    font-size: 11px; /* ลดขนาดฟอนต์เริ่มต้น */
}

.timetable-class-item strong {
    font-size: 12px; /* ทำให้รหัสวิชาเด่นขึ้นเล็กน้อย */
}

/* เพิ่มส่วนนี้เพื่อให้แน่ใจว่า tr ในตารางสรุปมี border ที่ถูกต้อง */
.styled-table tbody tr {
    border-bottom: 1px solid #e2e8f0; /* slate-200 */
}

/* --- [NEW] Portal Timetable Mobile View --- */
.mobile-day-card {
    background-color: var(--bg-white);
    border-radius: 0.75rem; /* rounded-xl */
    box-shadow: var(--shadow);
    overflow: hidden;
}

.mobile-day-header {
    background-color: var(--primary-bg);
    color: var(--primary-dark);
    padding: 0.75rem 1.25rem; /* 12px 20px */
    font-weight: 700;
    font-size: 1.125rem; /* text-lg */
}

.mobile-class-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.mobile-class-item:last-child {
    border-bottom: none;
}

.mobile-class-time {
    flex-shrink: 0;
    width: auto; /* 1. ปรับความกว้างอัตโนมัติ */
    text-align: left; /* 2. จัดข้อความชิดซ้าย */
    padding-right: 0.75rem; /* 12px */
    margin-right: 0.75rem; /* 12px - เพิ่มระยะห่างให้เส้นคั่น */
    border-right: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-light);
}

.mobile-class-details {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem; /* 4px */
}

.mobile-class-details span:not(:last-child)::after {
    content: "|";
    color: #cbd5e1; /* slate-300 */
    margin-left: 0.5rem; /* 8px */
    margin-right: 0.25rem; /* 4px */
}

.mobile-class-time p:first-child {
    font-weight: 600;
    color: var(--text-color);
}

.mobile-class-info p.font-bold {
    white-space: normal; /* อนุญาตให้ข้อความขึ้นบรรทัดใหม่ */
    word-break: break-word; /* ช่วยตัดคำยาวๆ กรณีจำเป็น */
}

/* 2. สำหรับบรรทัด "รายละเอียด": ยังคงแสดงบรรทัดเดียวพร้อม ... */
.mobile-class-info p.text-xs {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ภายในไฟล์: iTimetable/public/css/style.css */

/* --- [FIX] Portal Full-Width Layout --- */
#timetable-display, 
#portal-content-wrapper, 
.timetable-grid {
    width: 100%;
}

/* === Holiday Summary Badges === */
.day-summary-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* 12px */
    background-color: #f1f5f9; /* slate-100 */
    border: 1px solid #e2e8f0; /* slate-200 */
    border-radius: 9999px; /* rounded-full */
    padding: 0.25rem 0.75rem; /* py-1 px-3 */
    font-size: 0.875rem; /* text-sm */
    transition: all 0.2s ease-in-out;
}

.day-summary-badge .day-name {
    font-weight: 600; /* font-semibold */
    color: #475569; /* slate-600 */
}

.day-summary-badge .day-count {
    font-weight: 700; /* font-bold */
    color: #0f172a; /* slate-900 */
    background-color: white;
    padding: 0.125rem 0.5rem; /* py-0.5 px-2 */
    border-radius: 9999px; /* rounded-full */
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

/* Style for weekends */
.day-summary-badge.is-weekend {
    background-color: #fef3c7; /* amber-100 */
    border-color: #fde68a; /* amber-200 */
}

.day-summary-badge.is-weekend .day-name {
    color: #92400e; /* amber-800 */
}

.day-summary-badge.is-weekend .day-count {
    color: #92400e; /* amber-800 */
}

.flatpickr-day .holiday-dot {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    background-color: #ef4444; /* Tailwind red-500 */
    border-radius: 50%;
}

.action-button-disabled {
    background-color: #e5e7eb; /* gray-200 */
    color: #9ca3af; /* gray-400 */
    padding: 0.6rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: not-allowed;
}

.action-button-disabled svg {
    color: #9ca3af; /* gray-400 */
}

/* ... โค้ดเดิม ... */

/* --- [NEW] Grid Layout for Toggle Switches --- */
.toggle-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr); /* Default to 1 column on small screens */
    gap: 1rem; /* 16px */
}

@media (min-width: 768px) { /* md breakpoint */
    .toggle-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on medium screens */
    }
}

@media (min-width: 1280px) { /* xl breakpoint */
    .toggle-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 columns on large screens */
    }
}

/* SmartSchool/public/css/style.css */

/* --- Org Chart Styles --- */
.org-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    gap: 2rem; /* เพิ่มระยะห่างระหว่าง Layer ผู้อำนวยการ และรองผู้อำนวยการ */
}

.executive-card-wrapper {
    text-align: center;
}

.executive-card {
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    min-width: 220px;
    display: inline-block;
    white-space: nowrap;
    border-top: 4px solid var(--primary-color);
    position: relative;
    margin: 0 auto;
}

.executive-card-wrapper.placeholder .executive-card {
    border-top: 4px solid #cbd5e1;
    color: #94a3b8;
}

.director-node {
    /* ไม่มีสไตล์พิเศษที่จำเป็นสำหรับเส้นอีกต่อไป */
}

/* ลบโค้ดทั้งหมดที่เกี่ยวข้องกับเส้นเชื่อมต่อ */
/*
.director-node .executive-card-wrapper::after,
.connecting-lines-group,
.deputy-container::before,
.deputy-container::after,
.deputy-container .executive-card-wrapper::before {
    display: none;
}
*/

.deputy-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem; /* ระยะห่างระหว่างการ์ดของรองผู้อำนวยการ */
    width: 100%;
}

.executive-card .card-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.executive-card:hover .card-actions {
    opacity: 1;
}