@import url('https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-slate: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-light: #e2e8f0;
    --radius-xl: 20px;
    --radius-lg: 12px;
    --shadow-soft: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
}

body {
    font-family: 'Prompt', sans-serif;
    background-color: var(--bg-slate);
    color: var(--text-main);
    letter-spacing: 0.2px;
}

/* UI Components */
.glass-panel {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.8);
    padding: 2.5rem;
}

.modern-input {
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    color: var(--text-main);
    transition: all 0.25s ease;
    background-color: #fcfcfc;
}

.modern-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    outline: none;
    background-color: #fff;
}

.btn-modern {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: 0.55rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-modern:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(37, 99, 235, 0.3);
}

.btn-danger-modern {
    background-color: #ef4444;
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: 0.55rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}

.btn-danger-modern:hover { background-color: #dc2626; transform: translateY(-1px); }

.btn-secondary-modern {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-lg);
    padding: 0.55rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-secondary-modern:hover {
    background-color: #e2e8f0;
    color: #1e293b;
    border-color: #94a3b8;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.btn-secondary-modern:active {
    transform: translateY(0);
}

/* Global SweetAlert2 Popup Button Protection (ป้องกัน Tailwind Preflight ล้างสไตล์ปุ่ม Popup) */
.swal2-actions {
    gap: 0.75rem !important;
    margin-top: 1.5rem !important;
}
.modern-confirm-btn, .swal2-confirm {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 0.75rem !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    padding: 0.65rem 1.6rem !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    border: none !important;
    min-width: 110px !important;
    line-height: 1.4 !important;
    text-align: center !important;
    background-color: #2563eb;
    color: #ffffff !important;
}
.modern-confirm-btn.bg-indigo-600 { background-color: #4f46e5 !important; }
.modern-confirm-btn.bg-indigo-600:hover { background-color: #4338ca !important; }
.modern-confirm-btn.bg-emerald-600 { background-color: #059669 !important; }
.modern-confirm-btn.bg-emerald-600:hover { background-color: #047857 !important; }
.modern-confirm-btn.bg-rose-600 { background-color: #e11d48 !important; }
.modern-confirm-btn.bg-rose-600:hover { background-color: #be123c !important; }
.modern-confirm-btn.bg-amber-600 { background-color: #d97706 !important; }
.modern-confirm-btn.bg-amber-600:hover { background-color: #b45309 !important; }
.modern-confirm-btn:hover, .swal2-confirm:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 12px -1px rgba(0, 0, 0, 0.15) !important;
}
.modern-cancel-btn, .swal2-cancel {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 0.75rem !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    padding: 0.65rem 1.6rem !important;
    background-color: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    min-width: 110px !important;
    line-height: 1.4 !important;
    text-align: center !important;
}
.modern-cancel-btn:hover, .swal2-cancel:hover {
    background-color: #e2e8f0 !important;
    color: #1e293b !important;
    border-color: #94a3b8 !important;
    transform: translateY(-1px) !important;
}

/* Top Navbar */
.top-nav {
    background: var(--surface);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* FullCalendar Custom Overrides */
.fc { font-family: 'Prompt', sans-serif !important; }
.fc-toolbar-title { font-weight: 600 !important; font-size: 1.25rem !important; color: var(--text-main); }
.fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid { border-color: var(--border-light) !important; }
.fc-col-header-cell { padding: 10px 0; background-color: #f1f5f9; color: var(--text-muted); font-weight: 500; }
.fc-daygrid-event { border-radius: 6px !important; padding: 4px 8px !important; border: none !important; font-size: 0.85rem; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.fc-button-primary { 
    background: var(--surface) !important; 
    color: var(--text-main) !important; 
    border: 1px solid var(--border-light) !important; 
    border-radius: 8px !important; 
    text-transform: capitalize !important; 
    box-shadow: var(--shadow-sm);
    font-weight: 500 !important;
}
.fc-button-primary:hover { background: var(--bg-slate) !important; }
.fc-button-active { background: var(--primary) !important; color: white !important; border-color: var(--primary) !important; }

/* PWA App Viewer & Mobile Responsive Overrides */
.in-pwa-viewer .top-nav {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}
@media (max-width: 768px) {
    .top-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 0.75rem 1rem;
        margin-bottom: 1rem;
    }
    .layout-container {
        padding: 0 10px !important;
    }
    .glass-panel {
        padding: 1.25rem !important;
    }
}

/* Bookrooms Synced Event Styling (Clean Solid Blue Left Accent) */
.fc-event.event-bookrooms {
    border: 1px solid #bae6fd !important;
    border-left: 4px solid #0284c7 !important;
    background-color: #f0f9ff !important;
    color: #0369a1 !important;
    font-weight: 500 !important;
    border-radius: 4px !important;
    padding: 1px 4px !important;
    box-shadow: 0 1px 2px rgba(2, 132, 199, 0.08) !important;
}

.fc-event.event-bookrooms:hover {
    background-color: #e0f2fe !important;
    border-left-color: #0369a1 !important;
}

.fc-event.event-bookrooms .fc-event-title {
    font-weight: 500 !important;
    color: #0369a1 !important;
}

.fc-event.event-bookrooms .fc-event-time {
    font-weight: 600 !important;
    color: #0284c7 !important;
}

/* e-Meeting Event Styling (Vibrant Emerald Green Accent - เด่น ชัดเจน สวยงาม) */
.fc-event.event-emeeting {
    border: 1px solid #86efac !important;
    border-left: 4px solid #16a34a !important;
    background-color: #f0fdf4 !important;
    color: #14532d !important;
    font-weight: 600 !important;
    border-radius: 4px !important;
    padding: 1px 4px !important;
    box-shadow: 0 1px 3px rgba(22, 163, 74, 0.15) !important;
}

.fc-event.event-emeeting:hover {
    background-color: #dcfce7 !important;
    border-left-color: #15803d !important;
}

.fc-event.event-emeeting .fc-event-title {
    font-weight: 600 !important;
    color: #14532d !important;
}

.fc-event.event-emeeting .fc-event-time {
    font-weight: 700 !important;
    color: #15803d !important;
}

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
}

.source-badge-bookrooms {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.source-badge-emeeting {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.readonly-banner {
    padding: 8px 14px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    color: #0369a1;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
}

/* Day Cell Clickable Styles */
.fc-daygrid-day {
    cursor: pointer;
}

.fc-daygrid-day:hover {
    background-color: #f1f5f9 !important;
    transition: background-color 0.15s ease;
}

.day-agenda-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.day-agenda-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.06) !important;
}

/* User Profile Dropdown Styles */
.user-dropdown-container {
    position: relative;
    display: inline-block;
}

.user-profile-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    padding: 5px 14px 5px 6px;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.user-profile-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.user-avatar-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease;
}

.user-profile-btn:hover .user-avatar-circle {
    transform: scale(1.06);
}

.user-name-text {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1e293b;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.dropdown-arrow {
    font-size: 0.65rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
    margin-left: 2px;
}

.user-dropdown-container.active .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    max-width: calc(100vw - 20px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.15), 0 5px 15px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
    padding: 8px 0;
    z-index: 1000;
    display: none;
    animation: dropdownFade 0.2s ease;
}

.user-dropdown-container.active .user-dropdown-menu {
    display: block;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-header-card {
    padding: 14px 18px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    margin-top: -8px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.dropdown-header-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #0f172a;
}

.dropdown-header-sub {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 3px;
    line-height: 1.35;
}

.dropdown-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 6px 0;
}

.dropdown-section-title {
    padding: 8px 18px 4px 18px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    font-size: 0.88rem;
    color: #334155;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: #0284c7;
    padding-left: 22px;
}

.dropdown-item-danger {
    color: #ef4444;
}

.dropdown-item-danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.dropdown-item .item-icon {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* My Bookings Tab Buttons */
.btn-filter-tab {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-filter-tab:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-filter-tab.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

/* =========================================================
   COMPREHENSIVE MOBILE RESPONSIVE SYSTEM (รองรับทุกอุปกรณ์)
   ========================================================= */

/* ป้องกัน Badge สิทธิ์ตัดคำข้ามบรรทัด */
.role-badge {
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    flex-shrink: 0 !important;
    line-height: 1.2 !important;
}

/* 1. Mobile Navbar & Profile Button (จอเล็กแสดงเฉพาะไอคอน) */
@media (max-width: 640px) {
    .user-profile-btn {
        padding: 3px 8px 3px 3px !important;
        gap: 4px !important;
    }
    .user-avatar-circle {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.85rem !important;
    }
    .user-name-text {
        display: none !important;
    }
    .user-dropdown-menu {
        width: 280px !important;
        max-width: calc(100vw - 16px) !important;
        right: 0 !important;
    }
}

/* 2. FullCalendar Mobile Responsiveness */
@media (max-width: 768px) {
    .fc-header-toolbar {
        flex-direction: column !important;
        gap: 8px !important;
        align-items: center !important;
        margin-bottom: 12px !important;
    }
    .fc-toolbar-chunk {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .fc-toolbar-title {
        font-size: 1.15rem !important;
        text-align: center !important;
    }
    .fc-button {
        padding: 5px 10px !important;
        font-size: 0.78rem !important;
        border-radius: 6px !important;
    }
    .fc-col-header-cell-cushion {
        font-size: 0.75rem !important;
        padding: 3px 1px !important;
    }
    .fc-daygrid-day-number {
        font-size: 0.78rem !important;
        padding: 3px !important;
    }
    .fc-daygrid-event {
        font-size: 0.7rem !important;
        padding: 1px 3px !important;
        margin-bottom: 2px !important;
        border-radius: 4px !important;
    }
    #calendar-container {
        padding: 14px 10px !important;
    }
}

/* 3. Mobile Responsive Modals */
@media (max-width: 640px) {
    .modal-overlay {
        padding: 10px !important;
        align-items: flex-end !important;
    }
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        border-radius: 20px 20px 0 0 !important;
        margin-bottom: 0 !important;
    }
    .modal-header {
        padding: 14px 16px !important;
    }
    .modal-body {
        padding: 16px !important;
        max-height: 70vh !important;
        font-size: 0.9rem !important;
    }
    .modal-footer {
        padding: 12px 16px !important;
        flex-direction: column-reverse !important;
        gap: 8px !important;
    }
    .modal-footer button, .modal-footer a {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }
}

/* 4. Mobile Responsive Forms (add_meeting, edit_meeting) */
@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
    .chips-wrapper {
        gap: 6px !important;
    }
    .role-chip {
        font-size: 0.8rem !important;
        padding: 5px 10px !important;
    }
    .action-bar {
        flex-direction: column-reverse !important;
        gap: 10px !important;
    }
    .action-bar button, .action-bar a {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }
}

/* 5. Mobile Responsive Tables & Toolbars (users, agencies, logs, analytics) */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    .search-box {
        width: 100% !important;
        max-width: 100% !important;
    }
    .analytics-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .stat-grid {
        grid-template-columns: 1fr !important;
    }
}