@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #10B981;
    --dark: #1E293B;
    --light: #F8FAFC;
    --danger: #EF4444;
    --warning: #F59E0B;
    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-600: #475569;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.18);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Sarabun', sans-serif;
}

body {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    color: var(--dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

/* Typography */
h1, h2, h3, h4, h5, h6 { color: var(--dark); margin-bottom: 1rem; font-weight: 600; }
a { text-decoration: none; color: var(--primary); transition: color 0.3s; }
a:hover { color: var(--primary-hover); }

/* Layout */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Navbar */
.navbar {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-brand img {
    height: 40px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-links a {
    color: var(--gray-600);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-links a:hover, .nav-links a.active {
    background: var(--primary);
    color: white;
}

/* Forms */
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--gray-600); }
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}
select.form-control { cursor: pointer; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    gap: 0.5rem;
    font-size: 1rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--gray-200); color: var(--dark); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--secondary); color: white; }
.btn-fade {
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}
.btn-fade:hover {
    background: var(--dark);
    color: white;
    border-color: var(--dark);
}
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.875rem; }

/* Tables */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; box-shadow: var(--shadow-sm); }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--gray-200); }
.table-responsive th, .table-responsive td { white-space: nowrap; }
th { background: var(--gray-100); font-weight: 600; color: var(--gray-600); }
tr:hover { background: var(--gray-100); }

/* Badges */
.badge { padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.875rem; font-weight: 500; display: inline-block;}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-primary { background: #E0E7FF; color: #3730A3; }

/* Dashboard Cards */
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { padding: 1.5rem; border-radius: 12px; display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow-sm);}
.stat-card.primary { background: linear-gradient(135deg, #6366f1 0%, #4F46E5 100%); color: white; }
.stat-card.success { background: linear-gradient(135deg, #34d399 0%, #10B981 100%); color: white; }
.stat-card.warning { background: linear-gradient(135deg, #fbbf24 0%, #F59E0B 100%); color: white; }
.stat-card.danger { background: linear-gradient(135deg, #f87171 0%, #EF4444 100%); color: white; }
.stat-card .value { font-size: 2.5rem; font-weight: 700; margin-bottom: 0.2rem; }
.stat-card .label { font-size: 1.1rem; opacity: 0.9; }
.stat-card i { font-size: 3rem; opacity: 0.5; }

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }

.filter-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: end;
}
.filter-btn-wrapper {
    grid-column: span 2;
    margin-top: 1rem;
}

/* Login Page specific */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(79,70,229,0.1) 0%, rgba(16,185,129,0.1) 100%);
}
.login-card {
    max-width: 400px;
    width: 100%;
    padding: 2.5rem;
}
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-header img {
    max-width: 120px;
    max-height: 120px;
    margin-bottom: 1rem;
    object-fit: contain;
    border-radius: 12px;
}

/* Alert */
.alert { padding: 1rem; border-radius: 8px; margin-bottom: 1rem; transition: opacity 0.3s; }
.alert-danger { background: #FEE2E2; color: #991B1B; border: 1px solid #F87171; }
.alert-success { background: #D1FAE5; color: #065F46; border: 1px solid #34D399; }

/* Utilities */
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--secondary); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

/* Room Cards (for user view) */
.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.room-card {
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s;
}
.room-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}
.room-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f1f5f9;
}
.room-body {
    padding: 1.5rem;
}

/* Timeline */
.timeline {
    margin-top: 1rem;
    padding-left: 1rem;
}
.timeline-item {
    border-left: 3px solid var(--primary);
    padding: 0 0 1rem 1.25rem;
    position: relative;
}
.timeline-item::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
}
.timeline-date {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
    display: inline-block;
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 12px;
}
.timeline-content {
    background: var(--gray-100);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-top: 0.25rem;
}
.timeline-content h4 {
    margin-bottom: 0.25rem;
    font-size: 1rem;
}

.stat-card.orange { background: linear-gradient(135deg, #f97316 0%, #ea580c 100%); color: white; }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    .nav-brand {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
    .nav-links {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    /* Make h2 headers smaller on mobile */
    h2 {
        font-size: 1.25rem;
    }
    
    /* Container default for mobile (prevents 2rem squish) */
    .container {
        padding: 1rem;
    }
    
    /* Edge-to-edge layout for mobile (Index Page Only) */
    .page-index .container {
        padding: 1rem 0;
    }
    .page-index .alert {
        margin-left: 1rem;
        margin-right: 1rem;
    }
    
    /* Utilities for edge-to-edge panels inside padded containers */
    .bleed-mobile {
        margin-left: -1rem !important;
        margin-right: -1rem !important;
        padding-left: 1rem !important;
        padding-right: 0.5rem !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }
    
    /* Index page header layout wrapper */
    .d-flex.justify-between.align-center.mb-2,
    .d-flex.justify-between.align-center.mb-4 {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
        padding: 0 1rem;
    }
    
    .stack-on-mobile {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
        padding: 0 0.5rem;
    }
    
    .filter-form {
        grid-template-columns: 1fr;
    }
    .filter-form > div {
        min-width: 0; /* Prevents grid children from blowing out */
        width: 100%;
        overflow: hidden;
    }
    .filter-form .form-control {
        width: 100%;
        box-sizing: border-box;
    }
    .filter-btn-wrapper {
        grid-column: span 1 !important;
        margin-top: 0.5rem;
    }
    
    /* Responsive timeline date formatting */
    .timeline-date .date-end {
        display: block;
        margin-top: 0.2rem;
    }
    
    /* FullCalendar reductions for mobile */
    .fc .fc-toolbar-title {
        font-size: 1.1rem !important;
    }
    .fc .fc-button, 
    .fc .fc-button-primary {
        padding: 0.2rem 0.4rem !important;
        font-size: 0.75rem !important;
        line-height: 1.2 !important;
        height: auto !important;
    }
    .fc-col-header-cell-cushion {
        padding: 2px !important;
        font-size: 0.85rem !important;
    }
    
    /* FullCalendar List View adjustments */
    .fc-list-table td {
        padding: 6px 8px !important;
    }
    .fc-list-day-cushion a,
    .fc-list-event-time,
    .fc-list-event-title,
    .fc-list-empty-cushion {
        font-size: 0.85rem !important;
    }
    
    /* Upcoming timeline list */
    .timeline {
        padding-left: 0.5rem;
    }
    .timeline-item {
        padding: 0 0 1rem 1rem;
    }
    .timeline-date {
        font-size: 0.75rem;
    }
    .timeline-content h4 {
        font-size: 0.9rem;
    }
    .timeline-content .gap-3 {
        font-size: 0.8rem !important;
        gap: 0.5rem !important;
    }
    #list-view-section h3 {
        font-size: 1.1rem;
    }
    #list-view-section p {
        font-size: 0.8rem !important;
    }

    .page-index .glass-panel {
        padding: 1rem 0.5rem !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    .login-card {
        border-radius: 16px !important;
        border: 1px solid var(--glass-border) !important;
        padding: 1.5rem !important;
    }
}
