/* 
 * ESDCAYA Online Supervision System
 * Modern Educational Supervision Design
 */

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

:root {
    --primary-color: #1e40af;
    --secondary-color: #3b82f6;
    --accent-color: #f59e0b;
    --header-bg-color: #1a365d;
    --header-text-color: #ffffff;
    --menu-bg-color: #0f172a;
    --menu-text-color: #e2e8f0;
    --footer-bg-color: #0f172a;
    --footer-text-color: #94a3b8;
    --font-main: 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: var(--font-main);
    background-color: #f8fafc;
    color: #1e293b;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1 0 auto;
    overflow-x: hidden;
}

/* Dynamic Header */
.custom-header {
    background: var(--header-bg-color);
    color: var(--header-text-color);
    padding: 1.25rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    border-bottom: 3px solid var(--accent-color);
    z-index: 1030;
}

.custom-header a {
    color: var(--header-text-color);
    text-decoration: none;
}

/* Header Banner Image (Full Banner Mode) */
.custom-header-banner-container {
    position: relative;
    width: 100%;
    overflow: visible !important;
    background-color: var(--header-bg-color);
    border-bottom: 3px solid var(--accent-color);
    z-index: 1030;
}

.custom-header-banner-img {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    display: block;
}

.header-floating-user {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 1050;
}

.header-floating-user .dropdown-menu,
.custom-header .dropdown-menu {
    z-index: 1060 !important;
}

@media (max-width: 767.98px) {
    .custom-header-banner-img {
        max-height: 140px;
    }
    .header-floating-user {
        top: 8px;
        right: 8px;
    }
}

/* ========================================================
   iPhone iOS Style Mini Calendar Widget
   ======================================================== */
.ios-calendar-widget {
    background: #ffffff;
    border-radius: 1.25rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(226, 232, 240, 0.9);
    padding: 0.85rem;
    transition: all 0.3s ease;
}

.ios-calendar-widget:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.ios-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.65rem;
    margin-bottom: 0.65rem;
    border-bottom: 1px solid #f1f5f9;
}

.ios-widget-title-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.ios-app-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #ff3b30 0%, #ff2d55 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 3px 8px rgba(255, 59, 48, 0.25);
    line-height: 1;
}

.ios-app-icon .ios-app-icon-month {
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.95;
}

.ios-app-icon .ios-app-icon-day {
    font-size: 0.95rem;
    font-weight: 800;
}

.ios-calendar-month-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    line-height: 1.2;
}

.ios-calendar-subtext {
    font-size: 0.72rem;
    color: #64748b;
    margin: 0;
}

/* iOS Mini Calendar Grid */
.ios-calendar-grid {
    width: 100%;
    margin-bottom: 0.75rem;
}

.ios-weekdays-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 0.35rem;
}

.ios-weekday-cell {
    font-size: 0.65rem;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
}

.ios-days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    text-align: center;
}

.ios-day-cell {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 500;
    color: #334155;
    border-radius: 50%;
    cursor: default;
    transition: all 0.15s ease;
    user-select: none;
    max-width: 32px;
    max-height: 32px;
    margin: 0 auto;
}

.ios-day-cell.other-month {
    color: #cbd5e1;
    opacity: 0.45;
}

.ios-day-cell.today {
    background: #ff3b30;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 3px 8px rgba(255, 59, 48, 0.35);
}

.ios-day-cell.has-event:not(.today) {
    font-weight: 700;
    color: #1e40af;
    background-color: #eff6ff;
}

.ios-day-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #2563eb;
    position: absolute;
    bottom: 2px;
}

.ios-day-cell.today .ios-day-dot {
    background-color: #ffffff;
}

/* iOS Schedule List (Cards inside widget) */
.ios-schedule-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed #e2e8f0;
}

.ios-schedule-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: #334155;
    margin: 0;
}

.ios-schedule-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.ios-schedule-card {
    background: #f8fafc;
    border: 1px solid #edf2f7;
    border-radius: 0.75rem;
    padding: 0.5rem 0.65rem;
    transition: all 0.2s ease;
    text-decoration: none;
    display: block;
    color: inherit;
}

.ios-schedule-card:hover {
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    border-color: #cbd5e1;
    transform: translateY(-1px);
    color: inherit;
}

.ios-date-badge {
    background: linear-gradient(135deg, #ff3b30 0%, #e11d48 100%);
    color: #ffffff;
    border-radius: 8px;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-block;
    box-shadow: 0 2px 6px rgba(255, 59, 48, 0.25);
    line-height: 1.2;
}

.ios-schedule-school {
    font-weight: 700;
    font-size: 0.92rem;
    color: #0f172a;
}

.ios-schedule-topic {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.25rem;
    line-height: 1.35;
}

.ios-schedule-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.4rem;
}

/* Header Banner Background Cover Mode */
.custom-header.has-bg-banner {
    background-position: center center;
    background-size: cover;
    background-repeat: no-repeat;
    position: relative;
}

.custom-header.has-bg-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.78) 0%, rgba(15, 23, 42, 0.88) 100%);
    pointer-events: none;
}

.custom-header.has-bg-banner > .container {
    position: relative;
    z-index: 2;
}

/* Dynamic Menu Navbar */
.custom-navbar {
    background-color: var(--menu-bg-color) !important;
    border-bottom: 2px solid var(--accent-color);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.16);
    padding: 0.35rem 0 !important;
    transition: background-color 0.3s ease;
}

.custom-navbar .navbar-nav {
    gap: 0.25rem;
    align-items: center;
}

.custom-navbar .nav-link {
    color: var(--menu-text-color) !important;
    font-weight: 500;
    font-size: 0.92rem;
    white-space: nowrap !important;
    padding: 0.48rem 0.8rem !important;
    border-radius: 50rem;
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.custom-navbar .nav-link i {
    font-size: 1rem;
    opacity: 0.9;
    transition: transform 0.2s ease;
}

.custom-navbar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
    transform: translateY(-1px);
}

.custom-navbar .nav-link:hover i {
    transform: scale(1.18);
}

.custom-navbar .nav-link.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
    font-weight: 600;
    border-color: rgba(255, 255, 255, 0.25);
}

.custom-navbar .btn-dashboard-nav {
    white-space: nowrap !important;
    font-size: 0.88rem;
    letter-spacing: 0.2px;
    transition: all 0.2s ease;
}

.custom-navbar .btn-dashboard-nav:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.45) !important;
}

.custom-navbar .navbar-brand {
    color: #ffffff !important;
    font-weight: 700;
}

/* Custom Footer */
.custom-footer {
    background-color: var(--footer-bg-color);
    color: var(--footer-text-color);
    padding: 2.5rem 0 1.5rem;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.custom-footer a {
    color: var(--footer-text-color);
    text-decoration: none;
    transition: color 0.2s;
}

.custom-footer a:hover {
    color: #ffffff;
}

/* Buttons with Dynamic Brand Colors */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.btn-primary:hover {
    filter: brightness(0.9);
}

.btn-secondary {
    background-color: var(--secondary-color) !important;
    border-color: var(--secondary-color) !important;
}

.badge-primary {
    background-color: var(--primary-color) !important;
}

.text-primary-custom {
    color: var(--primary-color) !important;
}

.bg-primary-custom {
    background-color: var(--primary-color) !important;
    color: #ffffff;
}

/* Cards & Content Blocks */
.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid #e2e8f0;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.page-header-box {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #ffffff;
    padding: 2.5rem 2rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 25px -5px rgba(30, 64, 175, 0.25);
}

/* Admin Sidebar */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.admin-sidebar {
    width: 270px;
    background-color: var(--menu-bg-color);
    color: var(--menu-text-color);
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    z-index: 1050;
}

.admin-sidebar .sidebar-brand {
    padding: 1.25rem 1rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-sidebar .nav-link {
    color: var(--menu-text-color);
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    border-radius: 0.5rem;
    margin: 0.15rem 0.75rem;
    transition: all 0.2s;
    min-height: 42px;
}

.admin-sidebar .nav-link:hover,
.admin-sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.admin-sidebar .nav-link i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.admin-content {
    flex-grow: 1;
    background-color: #f1f5f9;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - 270px);
    min-width: 0;
}

.admin-topbar {
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-main {
    padding: 1.75rem;
    flex-grow: 1;
}

/* Sidebar Backdrop for Mobile & iPad */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Stat Card */
.stat-card {
    border-radius: 0.75rem;
    padding: 1.25rem;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

/* Responsive Table Wrapper with Touch Support */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    border-radius: 0.5rem;
}

/* Certificate Responsive Container */
.certificate-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (iPads & Mobile Phones)
   ========================================================================== */

/* Tablet & iPad Portrait / Mobile (< 992px) */
@media (max-width: 991.98px) {
    /* Admin offcanvas slide drawer */
    .admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 285px;
        max-width: 85vw;
        height: 100vh;
        z-index: 1050;
        transform: translateX(-100%);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.35);
        overflow-y: auto;
    }

    .admin-sidebar.show {
        transform: translateX(0);
    }

    .admin-content {
        width: 100% !important;
        min-width: 0 !important;
    }

    .admin-topbar {
        padding: 0.65rem 1rem;
        position: sticky;
        top: 0;
        z-index: 1020;
    }

    .admin-main {
        padding: 1.25rem 1rem;
    }

}

/* Public navigation collapse styling (< 1200px) */
@media (max-width: 1199.98px) {
    .custom-navbar .navbar-collapse {
        background-color: var(--menu-bg-color);
        padding: 1.25rem;
        border-radius: 1rem;
        margin-top: 0.65rem;
        box-shadow: 0 14px 35px rgba(0, 0, 0, 0.35);
        border: 1px solid rgba(255, 255, 255, 0.12);
    }

    .custom-navbar .navbar-nav {
        gap: 0.25rem !important;
        align-items: stretch !important;
    }

    .custom-navbar .nav-link {
        padding: 0.65rem 1rem !important;
        border-radius: 0.5rem !important;
        width: 100%;
        display: flex !important;
        align-items: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .custom-navbar .nav-link:last-child {
        border-bottom: none;
    }

    .custom-navbar .border-top-mobile {
        border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
        padding-top: 0.75rem !important;
        margin-top: 0.5rem !important;
    }
}

/* Mobile Devices & Small Tablets (< 768px) */
@media (max-width: 767.98px) {
    /* Header typography & logo */
    .custom-header {
        padding: 0.75rem 0;
    }

    .custom-header h1 {
        font-size: 1.15rem !important;
    }

    .site-logo-img {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
    }

    .site-logo-img i {
        font-size: 1.5rem !important;
    }

    .site-org-sub {
        font-size: 0.75rem !important;
        max-width: 190px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hero / Page Header Box */
    .page-header-box {
        padding: 1.25rem 1rem;
        margin-bottom: 1.25rem;
        border-radius: 0.75rem;
    }

    .page-header-box h1,
    .page-header-box h2 {
        font-size: 1.35rem !important;
    }

    .page-header-box p {
        font-size: 0.9rem !important;
    }

    /* Stat Cards */
    .stat-card {
        padding: 0.85rem;
        gap: 0.75rem;
    }

    .stat-icon {
        width: 46px;
        height: 46px;
        font-size: 1.35rem;
        border-radius: 0.5rem;
    }

    .stat-card h3 {
        font-size: 1.35rem !important;
    }

    .stat-card small {
        font-size: 0.75rem;
    }

    /* FullCalendar on Mobile */
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch !important;
    }

    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .fc .fc-toolbar-title {
        font-size: 1.1rem !important;
        text-align: center;
    }

    .fc .fc-button {
        padding: 0.35rem 0.6rem !important;
        font-size: 0.8rem !important;
    }

    .fc .fc-col-header-cell-cushion {
        font-size: 0.75rem;
        padding: 2px !important;
    }

    .fc-daygrid-event {
        font-size: 0.72rem !important;
        padding: 1px 2px !important;
    }

    /* Certificate on Mobile */
    #certificateContainer {
        padding: 1.5rem 1rem !important;
        border-width: 6px !important;
        min-height: auto !important;
    }

    #certificateContainer > div {
        padding: 1rem 0.5rem !important;
        min-height: auto !important;
    }

    #certificateContainer h3 {
        font-size: 1.1rem !important;
    }

    #certificateContainer h5 {
        font-size: 0.9rem !important;
    }

    #certificateContainer h2 {
        font-size: 1.3rem !important;
    }

    /* Tables on mobile */
    .table th, .table td {
        font-size: 0.84rem;
        padding: 0.5rem 0.6rem;
    }

    /* Prevent auto zoom on iOS inputs */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Modal padding */
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-body {
        padding: 1rem !important;
    }
}

/* Extra Small Phones (< 576px) */
@media (max-width: 575.98px) {
    .admin-main {
        padding: 0.85rem 0.5rem;
    }

    .stat-card {
        padding: 0.65rem 0.5rem;
        gap: 0.5rem;
    }

    .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 1.15rem;
    }

    .stat-card h3 {
        font-size: 1.15rem !important;
    }

    .stat-card small {
        font-size: 0.7rem;
    }
}

/* Printable Certificate & Report */
@media print {
    .no-print, .admin-sidebar, .admin-topbar, .custom-header, .custom-navbar, .custom-footer, .btn, .sidebar-backdrop {
        display: none !important;
    }
    body, .admin-content, .admin-main {
        background: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    .print-container {
        width: 100% !important;
        margin: 0 !important;
        padding: 15mm !important;
    }
}

/* =========================================================
   Facebook-Style News & Supervision Feed (ข่าวประชาสัมพันธ์และการนิเทศ)
   ========================================================= */
.fb-feed-container {
    max-width: 720px;
    margin: 0 auto;
}

.fb-feed-card {
    background: #ffffff;
    border-radius: 1rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    margin-bottom: 1.75rem;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fb-feed-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.fb-post-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem 0.75rem 1.25rem;
}

.fb-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #e2e8f0;
}

.fb-author-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
    margin-bottom: 2px;
}

.fb-post-time {
    font-size: 0.8rem;
    color: #64748b;
}

.fb-post-caption {
    padding: 0 1.25rem 0.85rem 1.25rem;
    color: #1e293b;
    font-size: 0.95rem;
    line-height: 1.55;
}

.fb-post-caption h5 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
}

/* Facebook Photo Collage Grid */
.fb-photo-grid {
    position: relative;
    width: 100%;
    background: #0f172a;
    cursor: pointer;
    overflow: hidden;
}

.fb-photo-grid img {
    object-position: center;
}

/* 1 Photo */
.fb-grid-1 {
    max-height: 420px;
    display: flex;
    justify-content: center;
    background: #f1f5f9;
}
.fb-grid-1 img {
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    object-position: center;
    display: block;
}

/* 2 Photos */
.fb-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    height: 300px;
}
.fb-grid-2 .fb-photo-item {
    height: 100%;
    overflow: hidden;
}
.fb-grid-2 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.fb-grid-2 .fb-photo-item:hover img {
    transform: scale(1.03);
}

/* 3 Photos: 1 Big Left, 2 Stacked Right */
.fb-grid-3 {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2px;
    height: 320px;
}
.fb-grid-3-col {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    height: 100%;
}
.fb-grid-3 .fb-photo-item {
    height: 100%;
    overflow: hidden;
}
.fb-grid-3 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.fb-grid-3 .fb-photo-item:hover img {
    transform: scale(1.03);
}

/* 4 Photos: 2x2 Grid */
.fb-grid-4 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    height: 330px;
}
.fb-grid-4 .fb-photo-item {
    height: 100%;
    overflow: hidden;
}
.fb-grid-4 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.fb-grid-4 .fb-photo-item:hover img {
    transform: scale(1.03);
}

/* 5+ Photos: 2 on top, 3 on bottom with +N overlay */
.fb-grid-5 {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 350px;
}
.fb-grid-5-top {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    height: 55%;
}
.fb-grid-5-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 2px;
    height: 45%;
}
.fb-grid-5 .fb-photo-item {
    position: relative;
    height: 100%;
    overflow: hidden;
}
.fb-grid-5 img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.fb-grid-5 .fb-photo-item:hover img {
    transform: scale(1.03);
}

.fb-more-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    color: #ffffff;
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    transition: background 0.2s ease;
}
.fb-photo-item:hover .fb-more-overlay {
    background: rgba(15, 23, 42, 0.75);
}

/* Stats Bar (Like count & Comments count) */
.fb-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 1.25rem;
    font-size: 0.88rem;
    color: #64748b;
    border-bottom: 1px solid #f1f5f9;
}

.fb-reaction-icons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fb-reaction-icon-badge {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #ffffff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.fb-reaction-icon-badge.like {
    background: #1877f2;
}
.fb-reaction-icon-badge.love {
    background: #e11d48;
}

/* Action Bar */
.fb-action-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    padding: 0.25rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
}

.fb-btn-action {
    background: transparent;
    border: none;
    padding: 0.55rem 0.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.92rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background 0.15s ease, color 0.15s ease;
    cursor: pointer;
    text-decoration: none;
    position: relative;
}

.fb-btn-action:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.fb-btn-action.active-like {
    color: #1877f2 !important;
}

.fb-btn-action.active-love {
    color: #e11d48 !important;
}

/* Reaction Popover (Flyout) */
.fb-reaction-popover {
    position: absolute;
    bottom: 110%;
    left: 10px;
    background: #ffffff;
    border-radius: 2rem;
    padding: 4px 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.18);
    border: 1px solid #e2e8f0;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 100;
    animation: fbPopUp 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fb-reaction-group:hover .fb-reaction-popover,
.fb-reaction-popover.show {
    display: flex;
}

@keyframes fbPopUp {
    from { opacity: 0; transform: translateY(10px) scale(0.85); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.fb-react-choice {
    background: transparent;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
    transition: transform 0.2s ease;
    border-radius: 50%;
}
.fb-react-choice:hover {
    transform: scale(1.35) translateY(-4px);
}

/* Comments Section */
.fb-comments-section {
    padding: 1rem 1.25rem 1.25rem 1.25rem;
    background: #fafafa;
}

.fb-comments-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.fb-comment-item {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
}

.fb-comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #e2e8f0;
}

.fb-comment-bubble {
    background: #f1f5f9;
    padding: 0.65rem 1rem;
    border-radius: 1.15rem;
    max-width: 85%;
    font-size: 0.9rem;
    position: relative;
}

.fb-comment-author {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.88rem;
    margin-bottom: 2px;
}

.fb-comment-text {
    color: #334155;
    word-break: break-word;
    line-height: 1.45;
}

.fb-comment-meta {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
    padding-left: 0.5rem;
}

/* Comment Input Box */
.fb-comment-input-box {
    display: flex;
    gap: 0.65rem;
    align-items: center;
}

.fb-comment-input-box .form-control {
    border-radius: 1.5rem;
    padding: 0.5rem 1.15rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    font-size: 0.92rem;
}
.fb-comment-input-box .form-control:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    border-color: #2563eb;
}

.fb-btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.fb-login-notice {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    padding: 0.85rem 1rem;
    text-align: center;
    color: #64748b;
    font-size: 0.88rem;
}

/* ========================================================
   Home Photo Feed (index.php) - ขยายเต็มความกว้างเท่าการ์ดอื่น
   ======================================================== */
.home-fb-feed {
    width: 100%;
    max-width: 100%;
    margin: 0;
}
.home-fb-feed .fb-feed-card {
    width: 100%;
    max-width: 100%;
    border-radius: 1rem;
    margin: 0 0 1.5rem 0 !important;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    background: #ffffff;
}
.home-fb-feed .fb-post-header {
    padding: 0.75rem 1.15rem 0.5rem;
    gap: 0.75rem;
}
.home-fb-feed .fb-avatar {
    width: 42px;
    height: 42px;
}
.home-fb-feed .fb-author-name {
    font-size: 0.96rem;
    margin-bottom: 2px;
}
.home-fb-feed .fb-post-time {
    font-size: 0.8rem;
}
.home-fb-feed .fb-post-caption {
    padding: 0 1.15rem 0.65rem;
}
.home-fb-feed .fb-post-caption h5 {
    font-size: 1.08rem;
    margin-bottom: 0.35rem;
}
.home-fb-feed .fb-post-caption .post-text {
    font-size: 0.9rem;
    line-height: 1.55;
    color: #475569;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.home-fb-feed .fb-photo-grid img,
.home-fb-feed .fb-photo-item img,
.home-fb-feed .fb-grid-1 img {
    object-position: center;
    object-fit: cover;
}

.home-fb-feed .fb-grid-1 {
    max-height: 440px;
}
.home-fb-feed .fb-grid-1 img {
    max-height: 440px;
}
.home-fb-feed .fb-grid-2 {
    height: 340px;
}
.home-fb-feed .fb-grid-3 {
    height: 380px;
}
.home-fb-feed .fb-grid-4 {
    height: 400px;
}
.home-fb-feed .fb-grid-5 {
    height: 420px;
}
.home-fb-feed .fb-more-overlay {
    font-size: 1.5rem;
}
.home-fb-feed .fb-stats-bar {
    padding: 0.6rem 1.15rem;
    font-size: 0.86rem;
}
.home-fb-feed .fb-action-bar {
    padding: 0.3rem 0.65rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.home-fb-feed .fb-btn-action {
    padding: 0.5rem 0.5rem;
    font-size: 0.9rem;
}

/* ========================================================
   Responsive Adjustments for iPad & Mobile (ทุกอุปกรณ์)
   ======================================================== */
@media (max-width: 991.98px) {
    .fb-feed-container {
        max-width: 100%;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
    .fb-grid-1 { max-height: 320px; }
    .fb-grid-1 img { max-height: 320px; }
    .fb-grid-2 { height: 240px; }
    .fb-grid-3 { height: 250px; }
    .fb-grid-4 { height: 260px; }
    .fb-grid-5 { height: 270px; }
    .fb-more-overlay { font-size: 1.35rem; }

    .home-fb-feed {
        max-width: 540px;
    }
    .home-fb-feed .fb-grid-1 { max-height: 320px; }
    .home-fb-feed .fb-grid-1 img { max-height: 320px; }
    .home-fb-feed .fb-grid-2 { height: 240px; }
    .home-fb-feed .fb-grid-3 { height: 270px; }
    .home-fb-feed .fb-grid-4 { height: 290px; }
    .home-fb-feed .fb-grid-5 { height: 310px; }
}

@media (max-width: 767.98px) {
    .fb-feed-card {
        border-radius: 0.75rem;
        margin-bottom: 1rem;
    }
    .fb-post-header {
        padding: 0.65rem 0.85rem 0.45rem;
        gap: 0.5rem;
    }
    .fb-avatar {
        width: 36px;
        height: 36px;
    }
    .fb-author-name {
        font-size: 0.88rem;
    }
    .fb-post-time {
        font-size: 0.75rem;
    }
    .fb-post-caption {
        padding: 0 0.85rem 0.45rem;
        font-size: 0.88rem;
    }
    .fb-post-caption h5 {
        font-size: 0.96rem;
    }
    .fb-grid-1 { max-height: 240px; }
    .fb-grid-1 img { max-height: 240px; }
    .fb-grid-2 { height: 180px; }
    .fb-grid-3 { height: 200px; }
    .fb-grid-4 { height: 220px; }
    .fb-grid-5 { height: 230px; }
    .fb-more-overlay { font-size: 1.15rem; }
    .fb-stats-bar {
        padding: 0.45rem 0.85rem;
        font-size: 0.78rem;
    }
    .fb-action-bar {
        padding: 0.2rem 0.35rem;
    }
    .fb-btn-action {
        font-size: 0.78rem;
        padding: 0.35rem 0.25rem;
        gap: 0.25rem;
    }
    .fb-btn-action i {
        font-size: 0.95rem !important;
    }

    .home-fb-feed {
        max-width: 100%;
    }
    .home-fb-feed .fb-grid-1 { max-height: 250px; }
    .home-fb-feed .fb-grid-1 img { max-height: 250px; }
    .home-fb-feed .fb-grid-2 { height: 200px; }
    .home-fb-feed .fb-grid-3 { height: 220px; }
    .home-fb-feed .fb-grid-4 { height: 240px; }
    .home-fb-feed .fb-grid-5 { height: 250px; }

    #photoLightboxModal .modal-body {
        min-height: 250px !important;
        padding: 0.5rem !important;
    }
    #photoLightboxModal #lightboxImage {
        max-height: 52vh !important;
    }
}

/* 5 Items per Row Grid Utility for Document Rows */
@media (min-width: 1200px) {
    .row-cols-xl-5 > * {
        flex: 0 0 auto;
        width: 20%;
    }
}

/* Line Clamping and Standard Thai Word-break Utilities */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    text-wrap: pretty;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    text-wrap: balance;
    text-wrap: pretty;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    text-wrap: pretty;
}

.doc-row-title {
    font-size: 0.98rem;
    line-height: 1.45;
    word-break: break-word;
    text-wrap: balance;
    text-wrap: pretty;
}

