:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --dark-text: #333;
    --card-radius: 15px;
    --mobile-padding: 15px;
    --desktop-padding: 30px;
}

@media (min-width: 768px) {
    .d-mobile-cards {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .d-pc-table {
        display: none !important;
    }
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: #f0f4f8;
    font-size: 16px;
    margin: 0;
    padding: 0;
}

/* Modern UI Wrappers */
.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--mobile-padding);
    padding-bottom: 100px;
}

@media (min-width: 768px) {
    .page-wrapper {
        padding: var(--desktop-padding);
        padding-bottom: 100px;
    }
}

/* Base App Container (Keeping for compatibility during migration) */
.app-container {
    width: 100%;
    min-height: 100vh;
    padding-bottom: 100px;
    margin: 0 auto;
    background-color: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, .08);
    overflow: hidden;
}

@media (min-width: 769px) {
    .app-container {
        max-width: 1100px;
        margin: 20px auto;
        min-height: auto;
    }
}

/* Premium Cards */
.form-card,
.cal-card,
.premium-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
    margin-bottom: 20px;
}

@media (max-width: 767px) {
    .premium-card {
        border-radius: 15px;
    }
}

.cal-card {
    padding: 20px;
}

.form-header {
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    color: #fff;
    padding: 18px 24px;
}

.form-body {
    padding: 24px;
}

/* Form Elements */
.form-label {
    font-weight: 600;
    font-size: .9rem;
    color: #374151;
}

.form-control,
.form-select {
    border-radius: 10px;
    border: 1.5px solid #e2e8f0 !important;
    font-family: 'Sarabun', sans-serif;
    padding: 10px;
}

.form-control:focus,
.form-select:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15) !important;
}

/* Premium Buttons */
.btn-premium {
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    color: #fff !important;
    border: none;
    border-radius: 10px;
    padding: 10px 28px;
    font-weight: 600;
    transition: opacity .2s;
}

.btn-premium:hover {
    opacity: .88;
}

/* Helpers */
.text-premium {
    color: #1e293b;
    font-weight: 700;
}

.bg-premium {
    background: #f8fafc;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: white;
    padding: 12px 0 calc(22px + env(safe-area-inset-bottom, 15px));
    display: flex;
    justify-content: space-around;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.08);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #aaa;
    text-decoration: none;
    font-size: 0.75rem;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 3px;
}

/* Category Grid & Cards */
.category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 15px 0;
}

@media (min-width: 769px) {
    .category-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

.building-card {
    height: 100px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    color: white;
    display: flex;
    align-items: flex-end;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    text-decoration: none;
}

.building-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.7));
}

.building-card span {
    position: relative;
    z-index: 1;
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Building Image Previews */
.building-preview,
.building-preview-url {
    width: 100%;
    height: 150px;
    border-radius: 12px;
    object-fit: cover;
    background-size: cover;
    background-position: center;
    border: 2px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}

.img-new-preview {
    width: 100%;
    max-height: 200px;
    border-radius: 12px;
    object-fit: cover;
    margin-top: 10px;
    border: 2px dashed #3182ce;
    display: none;
}

@media (max-width: 768px) {

    .building-preview,
    .building-preview-url {
        height: 120px;
    }
}

/* Room Management specific */
.room-thumb {
    width: 80px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    transition: transform .2s;
}

.room-thumb:hover {
    transform: scale(1.1);
}

.no-img {
    width: 60px;
    height: 60px;
    background: #f1f5f9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #94a3b8;
}

.img-preview-wrapper {
    width: 60px;
    height: 60px;
    background: #f1f5f9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1.5px dashed #cbd5e1;
    position: relative;
    margin-top: 5px;
}

.img-preview-wrapper i {
    font-size: 1.5rem;
    color: #94a3b8;
}

.img-preview {
    padding: var(--mobile-padding);
    /* Added variable for mobile-first */
    height: 100vh;
    width: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    display: none;
}

:root {
    --mobile-padding: 15px;
    --desktop-padding: 30px;
}

@media (min-width: 768px) {
    .page-wrapper {
        padding: var(--desktop-padding);
    }

    .d-mobile-cards {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .d-pc-table {
        display: none !important;
    }
}

.room-card-mobile {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
}

@media (max-width: 768px) {
    .d-pc-table {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .d-mobile-cards {
        display: none !important;
    }
}

/* Legend Dot styling */
.legend-dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    margin-top: -2px;
}

/* Mobile UI Refinements */
@media (max-width: 768px) {
    .page-wrapper {
        padding: 16px 12px 120px;
    }

    /* Header title scaling */
    .page-wrapper h4 {
        font-size: 0.9rem !important;
        line-height: 1.4;
    }

    /* Calendar card padding */
    .cal-card {
        padding: 12px !important;
    }

    /* Calendar Header & External Button */
    .cal-card .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }

    .cal-card .btn-outline-primary {
        display: block;
        width: 100%;
        padding: 8px;
    }

    /* FullCalendar UI on Mobile */
    .fc-header-toolbar {
        flex-direction: column !important;
        gap: 12px !important;
        margin-bottom: 1.5em !important;
    }

    .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
        width: 100%;
    }

    .fc-toolbar-chunk:nth-child(2) {
        order: -1;
        /* Move title to top */
    }

    .fc-toolbar-title {
        font-size: 1.2rem !important;
        text-align: center;
        margin-bottom: 5px;
    }

    .fc-button-group {
        width: 100%;
        display: flex !important;
    }

    .fc-button-group .btn,
    .fc-button-group .fc-button {
        flex: 1;
        padding: 6px 10px !important;
    }

    /* Legend items spacing */
    .cal-card .d-flex.flex-wrap.gap-3 {
        gap: 10px !important;
        justify-content: space-between;
    }
}