/* ================================================================
   SMART SCHEDULING - CSS
   ================================================================ */

/* Modal Overlay */
.scheduling-modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.scheduling-modal {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.scheduling-modal-sm { max-width: 500px; }
.scheduling-modal-lg { max-width: 1000px; }

.scheduling-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 12px 12px 0 0;
}

.scheduling-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.scheduling-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.scheduling-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

.scheduling-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
    line-height: 1;
}
.scheduling-close-btn:hover { color: #e53935; }

/* Buttons */
.scheduling-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.scheduling-btn-sm { padding: 4px 10px; font-size: 12px; }
.scheduling-btn-primary { background: #1976d2; color: #fff; }
.scheduling-btn-primary:hover { background: #1565c0; }
.scheduling-btn-secondary { background: #e0e0e0; color: #333; }
.scheduling-btn-secondary:hover { background: #bdbdbd; }
.scheduling-btn-success { background: #43a047; color: #fff; }
.scheduling-btn-success:hover { background: #388e3c; }
.scheduling-btn-danger { background: #e53935; color: #fff; }
.scheduling-btn-danger:hover { background: #c62828; }
.scheduling-btn-info { background: #0288d1; color: #fff; }
.scheduling-btn-info:hover { background: #0277bd; }

.scheduling-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: #e53935;
    font-size: 14px;
    padding: 4px;
}
.scheduling-btn-icon:hover { color: #b71c1c; }

/* Badges */
.scheduling-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.scheduling-badge-success { background: #e8f5e9; color: #2e7d32; }
.scheduling-badge-warning { background: #fff8e1; color: #f57f17; }
.scheduling-badge-danger { background: #fce4ec; color: #c62828; }
.scheduling-badge-info { background: #e3f2fd; color: #1565c0; }

/* Form */
.scheduling-form-group {
    margin-bottom: 14px;
}
.scheduling-form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 13px;
    color: #555;
}
.scheduling-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    box-sizing: border-box;
}
.scheduling-input:focus {
    border-color: #1976d2;
    outline: none;
    box-shadow: 0 0 0 2px rgba(25,118,210,0.15);
}
.scheduling-input-sm { width: auto; min-width: 150px; }

/* Loading & Empty */
.scheduling-loading {
    text-align: center;
    padding: 20px;
    color: #999;
}
.scheduling-empty {
    text-align: center;
    padding: 20px;
    color: #999;
    font-style: italic;
}

/* Table */
.scheduling-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.scheduling-table th, .scheduling-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    text-align: left;
}
.scheduling-table th {
    background: #f5f5f5;
    font-weight: 600;
    color: #555;
    font-size: 12px;
    text-transform: uppercase;
}
.scheduling-table tr:hover { background: #f8f9fa; }

/* ================================================================
   AVAILABILITY GRID
   ================================================================ */

.avail-grid-wrapper {
    overflow-x: auto;
}

.avail-hint {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
}

.avail-grid {
    border-collapse: collapse;
    width: 100%;
    font-size: 12px;
}
.avail-grid th, .avail-grid td {
    border: 1px solid #e0e0e0;
    text-align: center;
    padding: 0;
}
.avail-grid th {
    background: #f5f5f5;
    padding: 6px 4px;
    font-weight: 600;
    font-size: 12px;
    color: #555;
}

.avail-time-col {
    width: 55px;
    font-size: 11px;
    color: #888;
    padding: 2px 4px !important;
    background: #fafafa;
}

.avail-cell {
    width: calc((100% - 55px) / 7);
    height: 20px;
    cursor: pointer;
    transition: background 0.15s;
}
.avail-cell:hover { background: #e3f2fd; }
.avail-free { background: #c8e6c9 !important; }
.avail-free:hover { background: #a5d6a7 !important; }
.avail-busy { background: #ffcdd2 !important; }
.avail-busy:hover { background: #ef9a9a !important; }

/* Ô bị lock do HS đang có lịch môn khác tại trung tâm (class_schedules) */
.avail-cell.avail-center-locked {
    background: #c0392b !important;
    cursor: not-allowed !important;
    text-align: center;
    line-height: 20px;
    pointer-events: auto; /* giữ để tooltip title vẫn hiện */
}
.avail-cell.avail-center-locked:hover {
    background: #a93226 !important;
}
/* Student search results dropdown (reuse style from conflict tab) */
.student-search-results .student-search-item:last-child {
    border-bottom: none !important;
}

/* ================================================================
   EXTERNAL SCHEDULES TABLE
   ================================================================ */

.ext-schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 8px;
}
.ext-schedule-table th, .ext-schedule-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}
.ext-schedule-table th {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 12px;
}
.ext-schedule-table select, .ext-schedule-table input {
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
}
.ext-schedule-table input[type="text"] { width: 100%; }

/* ================================================================
   LEAVE REQUESTS
   ================================================================ */

.leave-filters {
    margin-bottom: 12px;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ================================================================
   MAKEUP SUGGESTIONS
   ================================================================ */

.makeup-suggestions-box {
    margin-top: 16px;
    padding: 16px;
    background: #f0f7ff;
    border-radius: 8px;
    border: 1px solid #bbdefb;
}

.makeup-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.makeup-slot-card {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.makeup-slot-card:hover {
    border-color: #1976d2;
    box-shadow: 0 2px 8px rgba(25,118,210,0.2);
}
.makeup-slot-day { font-weight: 700; color: #1976d2; font-size: 14px; }
.makeup-slot-time { font-size: 16px; font-weight: 600; margin: 4px 0; }
.makeup-slot-teacher { font-size: 12px; color: #888; }

.substitute-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #fff;
    border-radius: 6px;
    margin-top: 4px;
}

/* ================================================================
   STUDY GROUPS
   ================================================================ */

.study-groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.study-group-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px;
    transition: box-shadow 0.2s;
}
.study-group-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

.study-group-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
    color: #333;
}
.study-group-info {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.study-group-actions {
    display: flex;
    gap: 4px;
}

.group-form {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-top: 12px;
}

.group-members-detail {
    background: #f0f7ff;
    padding: 14px;
    border-radius: 8px;
    margin-top: 12px;
}
.group-members-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
}
.group-members-list li {
    padding: 4px 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
}

/* Student search & selection */
.student-search-results {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 4px;
}
.student-search-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
}
.student-search-item:hover { background: #e3f2fd; }
.student-search-item i { color: #1976d2; margin-right: 4px; }

.selected-students-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 32px;
    padding: 4px 0;
}
.selected-student-tag {
    background: #e3f2fd;
    color: #1565c0;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.selected-student-tag i { font-size: 10px; }

/* ================================================================
   CONFLICT INDICATORS (in calendar cards)
   ================================================================ */

.conflict-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 4px;
}
.conflict-dot-green { background: #4caf50; }
.conflict-dot-yellow { background: #ff9800; }
.conflict-dot-red { background: #e53935; }

/* ================================================================
   AI CHAT STYLES
   ================================================================ */

.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(100vh - 250px);
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
}

/* Config Banner */
.ai-config-banner {
    background: #fff3cd;
    border-bottom: 1px solid #ffc107;
    padding: 12px 16px;
    font-size: 13px;
}

/* Quick Actions */
.ai-quick-actions {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    background: #fff;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    align-items: center;
}

.ai-quick-btn {
    background: #f0f2f5;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    color: #555;
}
.ai-quick-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Chat Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: aiFadeIn 0.3s ease;
}

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

.ai-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-msg-bot {
    align-self: flex-start;
}

.ai-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.ai-msg-bot .ai-msg-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.ai-msg-user .ai-msg-avatar {
    background: #e3e8f0;
    color: #555;
}

.ai-msg-content {
    background: white;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    word-break: break-word;
}

.ai-msg-user .ai-msg-content {
    background: #667eea;
    color: white;
}

.ai-msg-content p { margin: 4px 0; }
.ai-msg-content ul { margin: 6px 0; padding-left: 18px; }
.ai-msg-content li { margin: 2px 0; }

/* Typing indicator */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px !important;
}
.ai-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: aiBounce 1.4s infinite ease-in-out both;
}
.ai-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes aiBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Action Buttons */
.ai-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.ai-action-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

/* Chat Input */
.ai-chat-input-area {
    padding: 10px 14px;
    background: #fff;
    border-top: 1px solid #eee;
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.ai-chat-input:focus {
    border-color: #667eea;
}

.ai-attach-btn, .ai-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-attach-btn {
    background: #f0f2f5;
    color: #555;
}
.ai-attach-btn:hover {
    background: #e0e3e8;
}

.ai-send-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}
.ai-send-btn:hover {
    transform: scale(1.05);
}
.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Timetable Preview Table */
.ai-timetable-preview {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
}
.ai-timetable-preview th,
.ai-timetable-preview td {
    border: 1px solid #e0e0e0;
    padding: 5px 8px;
    text-align: left;
}
.ai-timetable-preview th {
    background: #f5f5f5;
    font-weight: 600;
}
.ai-timetable-preview tr:hover {
    background: #f8f8ff;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .ai-chat-container {
        max-height: calc(100vh - 180px);
    }
    .ai-msg {
        max-width: 92%;
    }
    .ai-quick-actions {
        padding: 8px 10px;
    }
    .ai-quick-btn {
        font-size: 11px;
        padding: 4px 10px;
    }
}
