/* ============================================
   APPOINTMENTS MODULE
   ============================================ */

/* Page layout */
.appt-page { padding: 1.5rem; max-width: 1200px; margin: 0 auto; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.appt-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.appt-header-left { display: flex; align-items: center; gap: 1rem; }
.appt-header-left h2 { margin: 0; font-size: 1.4rem; }
.appt-header-right { display: flex; gap: 0.5rem; }

.back-link { text-decoration: none; color: #555; font-size: 0.9rem; }
.back-link:hover { color: #333; }

/* Tabs */
.appt-tabs { display: flex; gap: 0; border-bottom: 2px solid #e0e0e0; margin-bottom: 1.5rem; }
.appt-tab { background: none; border: none; padding: 0.6rem 1.2rem; font-size: 0.9rem; cursor: pointer; color: #666; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; }
.appt-tab:hover { color: #333; }
.appt-tab.active { color: #2A9D8F; border-bottom-color: #2A9D8F; font-weight: 600; }

/* Appointment cards */
.appt-list { display: flex; flex-direction: column; gap: 0.75rem; }
.appt-card { display: flex; align-items: stretch; background: #fff; border: 1px solid #e8e8e8; border-radius: 10px; overflow: hidden; transition: box-shadow 0.15s; }
.appt-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.appt-card.status-cancelled { opacity: 0.7; }
.appt-card.status-rescheduled { opacity: 0.7; }

.appt-card-date { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; min-width: 70px; background: #f8f9fa; border-right: 1px solid #e8e8e8; }
.appt-date-day { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.appt-date-month { font-size: 0.8rem; text-transform: uppercase; color: #666; }
.appt-date-year { font-size: 0.7rem; color: #999; }

.appt-card-info { flex: 1; padding: 0.8rem 1rem; }
.appt-card-title { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
.appt-role-badge { font-size: 0.7rem; background: #e8e8e8; padding: 0.1rem 0.5rem; border-radius: 10px; color: #555; }
.appt-card-time { font-size: 0.85rem; color: #555; margin-bottom: 0.3rem; }
.appt-card-notes { font-size: 0.82rem; color: #777; font-style: italic; }
.appt-card-cancel-reason { font-size: 0.82rem; color: #c0392b; margin-top: 0.3rem; }

.appt-card-actions { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; padding: 0.8rem 1rem; gap: 0.4rem; }
.appt-status-badge { font-size: 0.7rem; padding: 0.2rem 0.6rem; border-radius: 10px; font-weight: 600; }
.appt-status-badge.status-0 { background: #d4edda; color: #155724; }
.appt-status-badge.status-1 { background: #f8d7da; color: #721c24; }
.appt-status-badge.status-2 { background: #fff3cd; color: #856404; }
.appt-status-badge.status-3 { background: #e8e8e8; color: #555; }

.appt-loading, .appt-empty { text-align: center; padding: 3rem; color: #888; }

/* ---- Settings Page ---- */
.appt-settings-layout { display: grid; grid-template-columns: 1fr 2fr; gap: 1.5rem; }
.settings-card { background: #fff; border: 1px solid #e8e8e8; border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.settings-card h3 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.settings-hint { font-size: 0.82rem; color: #888; margin-bottom: 1rem; }

.pattern-form { display: flex; flex-direction: column; gap: 0.75rem; }
.appt-page .form-row { display: flex; flex-direction: column; gap: 0.3rem; }
.appt-page .form-row label { font-size: 0.82rem; font-weight: 600; color: #444; }
.appt-page .form-row select, .appt-page .form-row input[type="time"], .appt-page .form-row input[type="date"], .appt-page .form-row textarea {
    padding: 0.45rem 0.6rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.9rem;
}
.appt-page .form-row select:focus, .appt-page .form-row input:focus, .appt-page .form-row textarea:focus { outline: none; border-color: #2A9D8F; }
.appt-page .form-row textarea { resize: vertical; font-family: inherit; }
.form-row-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.pattern-preview { background: #f0faf7; border: 1px solid #c3e6e0; border-radius: 6px; padding: 0.5rem 0.75rem; font-size: 0.82rem; color: #1a7a6a; }

.pattern-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid #f0f0f0; }
.pattern-item:last-child { border-bottom: none; }
.pattern-info { font-size: 0.9rem; }
.pattern-duration { font-size: 0.78rem; color: #888; margin-left: 0.5rem; }

/* Calendar */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.calendar-header h3 { margin: 0; font-size: 1rem; }
.btn-nav { background: none; border: 1px solid #ddd; border-radius: 6px; padding: 0.3rem 0.6rem; cursor: pointer; font-size: 0.9rem; }
.btn-nav:hover { background: #f0f0f0; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.5rem; }
.calendar-day { min-height: 120px; }
.calendar-day-header { text-align: center; padding: 0.3rem; border-bottom: 1px solid #e8e8e8; margin-bottom: 0.4rem; }
.day-name { font-weight: 600; font-size: 0.8rem; display: block; }
.day-date { font-size: 0.75rem; color: #888; }

.calendar-slot { padding: 0.25rem 0.4rem; border-radius: 4px; margin-bottom: 0.25rem; font-size: 0.72rem; cursor: pointer; transition: opacity 0.15s; }
.calendar-slot:hover { opacity: 0.8; }
.slot-available { background: #d4edda; color: #155724; }
.slot-booked { background: #fff3cd; color: #856404; }
.slot-blocked { background: #e8e8e8; color: #666; }
.slot-time { display: block; font-weight: 600; }
.slot-student { display: block; font-size: 0.68rem; }
.slot-label { display: block; font-size: 0.68rem; font-style: italic; }
.calendar-empty { text-align: center; color: #ccc; font-size: 0.75rem; padding-top: 1rem; }

/* ---- Booking Page ---- */
.booking-layout { display: flex; flex-direction: column; gap: 1rem; max-width: 700px; }
.booking-card { background: #fff; border: 1px solid #e8e8e8; border-radius: 10px; padding: 1.5rem; }

.staff-list { display: flex; flex-direction: column; gap: 0.5rem; }
.staff-card { display: flex; align-items: center; gap: 1rem; padding: 0.75rem; border: 1px solid #e8e8e8; border-radius: 8px; cursor: pointer; transition: all 0.15s; }
.staff-card:hover { border-color: #2A9D8F; background: #f0faf7; }
.staff-avatar { width: 40px; height: 40px; border-radius: 50%; background: #2A9D8F; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; }
.staff-avatar.lg { width: 50px; height: 50px; font-size: 1.3rem; }
.staff-info { flex: 1; }
.staff-info strong { display: block; }
.staff-role { font-size: 0.82rem; color: #888; }

.booking-staff-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid #e8e8e8; }

/* Slot pills */
.slot-date-group { margin-bottom: 1rem; }
.slot-date-label { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.5rem; color: #333; }
.slot-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.slot-pill { background: #f0f0f0; border: 1px solid #ddd; border-radius: 20px; padding: 0.35rem 0.9rem; font-size: 0.82rem; cursor: pointer; transition: all 0.15s; }
.slot-pill:hover { border-color: #2A9D8F; background: #f0faf7; }
.slot-pill.selected { background: #2A9D8F; color: #fff; border-color: #2A9D8F; }
.no-slots-msg { color: #888; font-style: italic; padding: 1rem 0; }

/* Booking confirmation */
.booking-confirm { border-left: 4px solid #2A9D8F; }
.confirm-details { display: flex; flex-direction: column; gap: 0.4rem; }
.confirm-row { display: flex; gap: 1rem; font-size: 0.9rem; }
.confirm-label { font-weight: 600; min-width: 60px; color: #555; }

.booking-success { text-align: center; border-left: 4px solid #27ae60; }
.success-icon { font-size: 2.5rem; color: #27ae60; margin-bottom: 0.5rem; }
.success-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.5rem; }

/* ---- Buttons ---- */
.btn-primary { background: #2A9D8F; color: #fff; border: none; border-radius: 6px; padding: 0.5rem 1.2rem; font-size: 0.9rem; cursor: pointer; font-weight: 600; transition: background 0.15s; }
.btn-primary:hover { background: #238b7e; }
.btn-primary:disabled { background: #b0b0b0; cursor: not-allowed; }
.btn-primary.btn-lg { padding: 0.7rem 2rem; font-size: 1rem; margin-top: 1rem; }
.btn-outline { background: none; border: 1px solid #ddd; border-radius: 6px; padding: 0.5rem 1.2rem; font-size: 0.9rem; cursor: pointer; color: #555; text-decoration: none; }
.btn-outline:hover { background: #f0f0f0; border-color: #ccc; }
.btn-outline-sm { background: none; border: 1px solid #ddd; border-radius: 4px; padding: 0.25rem 0.6rem; font-size: 0.78rem; cursor: pointer; color: #555; }
.btn-outline-sm:hover { background: #f0f0f0; }
.btn-danger { background: #dc3545; color: #fff; border: none; border-radius: 6px; padding: 0.5rem 1.2rem; font-size: 0.9rem; cursor: pointer; }
.btn-danger:hover { background: #c82333; }
.btn-danger:disabled { background: #b0b0b0; cursor: not-allowed; }
.btn-danger-sm { background: none; border: 1px solid #e8a0a0; border-radius: 4px; padding: 0.25rem 0.6rem; font-size: 0.78rem; cursor: pointer; color: #c0392b; }
.btn-danger-sm:hover { background: #fef2f2; }

/* ---- Modal ---- */
.appt-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid #e0e0e0; }
.appt-modal-header h3 { margin: 0; font-size: 1.05rem; }
.appt-modal-body { padding: 1.25rem; }
.appt-modal-body label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.3rem; color: #333; }
.appt-modal-body textarea { width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 6px; font-size: 0.9rem; font-family: inherit; box-sizing: border-box; resize: vertical; }
.appt-modal-body textarea:focus { outline: none; border-color: #2A9D8F; }
.appt-modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.25rem; border-top: 1px solid #e0e0e0; }

/* Toast */
.toast-message { position: fixed; bottom: 2rem; right: 2rem; padding: 0.75rem 1.25rem; border-radius: 8px; font-size: 0.9rem; z-index: 10000; box-shadow: 0 4px 16px rgba(0,0,0,0.15); }
.toast-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.toast-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .appt-settings-layout { grid-template-columns: 1fr; }
    .calendar-grid { grid-template-columns: repeat(3, 1fr); }
    .appt-card { flex-direction: column; }
    .appt-card-date { flex-direction: row; gap: 0.5rem; border-right: none; border-bottom: 1px solid #e8e8e8; }
    .appt-card-actions { flex-direction: row; }
}

/* ============================================
   FACULTY THEMING
   ============================================ */

/* ---- NDA (Navy/Teal) ---- */
.theme-nda .appt-page { color: #333; }
.theme-nda .appt-header { border-bottom: 2px solid #1e3c72; padding-bottom: 1rem; }
.theme-nda .appt-tab.active { color: #00b894; border-bottom-color: #00b894; }
.theme-nda .btn-primary { background: #00b894; }
.theme-nda .btn-primary:hover { background: #00a085; }
.theme-nda .appt-card-date { background: #1e3c72; color: white; }
.theme-nda .appt-date-month { color: rgba(255,255,255,0.7); }
.theme-nda .appt-date-year { color: rgba(255,255,255,0.5); }
.theme-nda .slot-pill.selected { background: #00b894; border-color: #00b894; }
.theme-nda .slot-pill:hover { border-color: #00b894; background: #e6faf5; }
.theme-nda .staff-card:hover { border-color: #00b894; background: #e6faf5; }
.theme-nda .staff-avatar { background: #1e3c72; }
.theme-nda .booking-confirm { border-left-color: #00b894; }
.theme-nda .pattern-preview { background: #e6faf5; border-color: #a3e4d7; color: #00a085; }
.theme-nda .sig-input:focus { border-color: #00b894; }
.theme-nda .back-link { color: #1e3c72; }
.theme-nda .settings-card h3 { color: #1e3c72; }
.theme-nda .calendar-slot.slot-available { background: #d4edda; color: #155724; }
.theme-nda .calendar-slot.slot-booked { background: #1e3c72; color: white; }

/* ---- NMA (Dark/Crimson) ---- */
.theme-nma .appt-page { color: #333; }
.theme-nma .appt-header { border-bottom: 2px solid #2d3748; padding-bottom: 1rem; }
.theme-nma .appt-tab.active { color: #ff4757; border-bottom-color: #ff4757; }
.theme-nma .btn-primary { background: #ff4757; }
.theme-nma .btn-primary:hover { background: #e84050; }
.theme-nma .appt-card-date { background: #2d3748; color: white; }
.theme-nma .appt-date-month { color: rgba(255,255,255,0.7); }
.theme-nma .appt-date-year { color: rgba(255,255,255,0.5); }
.theme-nma .slot-pill.selected { background: #ff4757; border-color: #ff4757; }
.theme-nma .slot-pill:hover { border-color: #ff4757; background: #fff0f1; }
.theme-nma .staff-card:hover { border-color: #ff4757; background: #fff0f1; }
.theme-nma .staff-avatar { background: #2d3748; }
.theme-nma .booking-confirm { border-left-color: #ff4757; }
.theme-nma .pattern-preview { background: #fff0f1; border-color: #ffb3b8; color: #e84050; }
.theme-nma .sig-input:focus { border-color: #ff4757; }
.theme-nma .back-link { color: #2d3748; }
.theme-nma .settings-card h3 { color: #2d3748; }
.theme-nma .calendar-slot.slot-available { background: #d4edda; color: #155724; }
.theme-nma .calendar-slot.slot-booked { background: #ff4757; color: white; }

/* ---- BOM (Light/Red) ---- */
.theme-bom .appt-page { color: #333; }
.theme-bom .appt-header { border-bottom: 2px solid #e53e3e; padding-bottom: 1rem; }
.theme-bom .appt-tab.active { color: #e53e3e; border-bottom-color: #e53e3e; }
.theme-bom .btn-primary { background: #e53e3e; }
.theme-bom .btn-primary:hover { background: #d32f2f; }
.theme-bom .appt-card-date { background: #e53e3e; color: white; }
.theme-bom .appt-date-month { color: rgba(255,255,255,0.8); }
.theme-bom .appt-date-year { color: rgba(255,255,255,0.6); }
.theme-bom .slot-pill.selected { background: #e53e3e; border-color: #e53e3e; }
.theme-bom .slot-pill:hover { border-color: #e53e3e; background: #fef2f2; }
.theme-bom .staff-card:hover { border-color: #e53e3e; background: #fef2f2; }
.theme-bom .staff-avatar { background: #e53e3e; }
.theme-bom .booking-confirm { border-left-color: #e53e3e; }
.theme-bom .pattern-preview { background: #fef2f2; border-color: #f5c6cb; color: #d32f2f; }
.theme-bom .sig-input:focus { border-color: #e53e3e; }
.theme-bom .back-link { color: #333; }
.theme-bom .settings-card h3 { color: #333; }
.theme-bom .calendar-slot.slot-available { background: #d4edda; color: #155724; }
.theme-bom .calendar-slot.slot-booked { background: #e53e3e; color: white; }

/* ---- Top Bar Theming ---- */
.appt-page .top-bar {
    color: white;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    margin-top: -1.5rem;
    padding-left: calc(50vw - 50% + 1.5rem);
    padding-right: calc(50vw - 50% + 1.5rem);
}
.appt-page .top-bar .top-bar-logo { color: white; }
.appt-page .top-bar .top-bar-user { color: rgba(255,255,255,0.8); }
.appt-page .top-bar .back-to-dash { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.85rem; }
.appt-page .top-bar .back-to-dash:hover { color: white; }

.appt-page.theme-nda .top-bar { background: linear-gradient(to right, #151f6d, #0d6b9f) !important; }
.appt-page.theme-nma .top-bar { background: linear-gradient(135deg, #1a1a2e, #16213e) !important; }
.appt-page.theme-bom .top-bar { background: linear-gradient(135deg, #b71c1c, #d32f2f) !important; }

/* ---- Tab text fix ---- */
.theme-nda .appt-tab.active { color: #1e3c72; border-bottom-color: #1e3c72; }
.theme-nma .appt-tab.active { color: #2d3748; border-bottom-color: #ff4757; }
.theme-bom .appt-tab.active { color: #b71c1c; border-bottom-color: #e53e3e; }

/* ---- NDA Settings page - navy accents ---- */
.theme-nda .btn-primary { background: #1e3c72; }
.theme-nda .btn-primary:hover { background: #152d5a; }
.theme-nda .pattern-preview { background: #eef2f9; border-color: #b8c9e0; color: #1e3c72; }
.theme-nda .slot-pill.selected { background: #1e3c72; border-color: #1e3c72; }
.theme-nda .slot-pill:hover { border-color: #1e3c72; background: #eef2f9; }
.theme-nda .staff-card:hover { border-color: #1e3c72; background: #eef2f9; }
.theme-nda .booking-confirm { border-left-color: #1e3c72; }
.theme-nda .booking-success { border-left-color: #1e3c72; }
.theme-nda .success-icon { color: #1e3c72; }