/* CosMyLive - Custom Styles */
:root {
    --line-green: #06C755;
    --line-green-dark: #04A844;
    --line-green-light: #E8F9EE;
    --bg-primary: #F0F2F5;
    --card-bg: #FFFFFF;
    --text-primary: #1C1C1E;
    --text-secondary: #6C757D;
    --border-color: #E5E7EB;
    --status-pending: #FF9500;
    --status-confirmed: #06C755;
    --status-cancelled: #FF3B30;
    --nav-height: 64px;
    --header-height: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'LINE Seed Sans TH', 'Prompt', 'Noto Sans Thai', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Loading ─────────────────────────────────────── */
#loading-screen {
    position: fixed; inset: 0;
    background: linear-gradient(135deg, #06C755 0%, #04A844 100%);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 9999; gap: 16px;
}
.loading-logo {
    width: 80px; height: 80px;
    background: #fff; border-radius: 24px;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; color: #06C755;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── App Shell ───────────────────────────────────── */
#app { display: none; flex-direction: column; min-height: 100vh; }
#app.visible { display: flex; }

/* ─── Top Header ──────────────────────────────────── */
.app-header {
    position: sticky; top: 0; z-index: 100;
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center;
    padding: 0 16px; gap: 12px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.app-header .logo { font-size: 20px; color: #06C755; }
.app-header h1 {
    font-size: 16px; font-weight: 700;
    color: var(--text-primary); flex: 1;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--line-green);
}
.user-avatar-placeholder {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--line-green);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 16px; font-weight: 700;
}

/* ─── Main Content ────────────────────────────────── */
.main-content {
    flex: 1;
    padding-bottom: calc(var(--nav-height) + 16px);
    overflow-y: auto;
}

/* ─── Bottom Navigation ───────────────────────────── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: #fff;
    border-top: 1px solid var(--border-color);
    display: flex; z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px; cursor: pointer;
    transition: all 0.2s ease;
    border: none; background: none; padding: 8px 4px;
    color: var(--text-secondary); font-size: 10px;
    -webkit-tap-highlight-color: transparent;
}
.nav-item .nav-icon { font-size: 22px; transition: transform 0.2s; }
.nav-item.active { color: var(--line-green); }
.nav-item.active .nav-icon { transform: scale(1.15); }
.nav-item.active span:last-child { font-weight: 700; }

/* ─── Views ───────────────────────────────────────── */
.view { display: none; padding: 16px; }
.view.active { display: block; }

/* ─── Cards ───────────────────────────────────────── */
.card {
    background: #fff; border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}
.card-header {
    padding: 16px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
}
.card-body { padding: 16px; }

/* ─── Section Title ───────────────────────────────── */
.section-title {
    font-size: 15px; font-weight: 700;
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}

/* ─── Room Cards ──────────────────────────────────── */
.room-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.room-card {
    background: #fff; border-radius: 16px;
    padding: 16px; cursor: pointer;
    transition: all 0.2s; position: relative; overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    border: 2px solid transparent;
}
.room-card:active { transform: scale(0.97); }
.room-card.selected { border-color: var(--line-green); }
.room-color-bar {
    height: 4px; border-radius: 2px; margin-bottom: 12px;
}
.room-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.room-capacity { font-size: 11px; color: var(--text-secondary); }
.room-badge {
    position: absolute; top: 10px; right: 10px;
    font-size: 9px; padding: 3px 8px; border-radius: 20px;
    font-weight: 700;
}
.badge-active { background: #E8F9EE; color: #06C755; }
.badge-maintenance { background: #FFF3E0; color: #FF9500; }
.badge-inactive { background: #FFE5E5; color: #FF3B30; }

/* ─── Status Badges ───────────────────────────────── */
.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 700;
    padding: 4px 10px; border-radius: 20px;
}
.status-pending { background: #FFF3CD; color: #FF9500; }
.status-confirmed { background: #E8F9EE; color: #06C755; }
.status-cancelled { background: #FFE5E5; color: #FF3B30; }

/* ─── Schedule Table ──────────────────────────────── */
.schedule-wrapper {
    overflow-x: auto;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    background: #fff;
}
.schedule-table {
    width: 100%; border-collapse: collapse;
    min-width: 480px;
    font-size: 12px;
}
.schedule-table th {
    background: #F8FAFC; padding: 10px 8px;
    text-align: center; font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap; position: sticky; top: 0; z-index: 10;
}
.schedule-table th.time-col { min-width: 64px; }
.schedule-table td {
    padding: 4px; border: 1px solid #F0F2F5;
    vertical-align: top; min-width: 100px;
}
.schedule-table td.time-cell {
    padding: 6px 8px; text-align: center;
    color: var(--text-secondary); font-size: 11px;
    background: #F8FAFC; font-weight: 600; white-space: nowrap;
    min-width: 64px;
}
.slot-free {
    height: 44px; border-radius: 6px;
    background: #F8FAF8;
    transition: background 0.15s;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: #ccc;
}
.slot-free:hover { background: var(--line-green-light); color: var(--line-green); }
.slot-booked {
    border-radius: 6px; padding: 4px 6px;
    font-size: 10px; line-height: 1.4;
    cursor: pointer; min-height: 44px;
    transition: opacity 0.15s;
}
.slot-booked:hover { opacity: 0.85; }
.slot-booked .slot-title {
    font-weight: 700; font-size: 11px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slot-booked .slot-user { opacity: 0.8; }
.slot-booked .slot-time { opacity: 0.7; font-size: 9px; }

/* ─── Date Navigator ──────────────────────────────── */
.date-nav {
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; border-radius: 12px;
    padding: 10px 16px; margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.date-nav button {
    background: var(--bg-primary); border: none;
    width: 36px; height: 36px; border-radius: 50%;
    cursor: pointer; font-size: 18px;
    transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.date-nav button:hover { background: var(--line-green-light); }
.date-nav .date-display {
    font-size: 15px; font-weight: 700; text-align: center; flex: 1;
}
.date-nav .date-sub { font-size: 12px; color: var(--text-secondary); font-weight: 400; }

/* ─── Booking Form ────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 13px;
    font-weight: 700; margin-bottom: 6px;
    color: var(--text-primary);
}
.form-label .required { color: #FF3B30; margin-left: 2px; }
.form-control {
    width: 100%; padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px; font-size: 14px;
    background: #fff; transition: border-color 0.2s;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}
.form-control:focus {
    outline: none; border-color: var(--line-green);
    box-shadow: 0 0 0 3px rgba(6,199,85,0.12);
}
.form-control.error { border-color: #FF3B30; }
.form-error { font-size: 11px; color: #FF3B30; margin-top: 4px; }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236C757D' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.time-row { display: flex; gap: 10px; }
.time-row .form-group { flex: 1; }

/* ─── Buttons ─────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; padding: 12px 24px; border: none;
    border-radius: 12px; font-size: 15px;
    font-weight: 700; cursor: pointer;
    transition: all 0.2s; font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
    background: var(--line-green); color: #fff;
    box-shadow: 0 4px 12px rgba(6,199,85,0.3);
}
.btn-primary:hover { background: var(--line-green-dark); }
.btn-outline {
    background: transparent; color: var(--line-green);
    border: 1.5px solid var(--line-green);
}
.btn-danger {
    background: #FF3B30; color: #fff;
    box-shadow: 0 4px 12px rgba(255,59,48,0.25);
}
.btn-secondary {
    background: #F0F2F5; color: var(--text-primary);
}
.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ─── Booking List ────────────────────────────────── */
.booking-item {
    background: #fff; border-radius: 14px;
    padding: 14px 16px; margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    cursor: pointer; transition: transform 0.15s;
    border-left: 4px solid var(--border-color);
}
.booking-item:active { transform: scale(0.99); }
.booking-item.pending { border-left-color: var(--status-pending); }
.booking-item.confirmed { border-left-color: var(--status-confirmed); }
.booking-item.cancelled { border-left-color: var(--status-cancelled); opacity: 0.7; }
.booking-title-text { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.booking-meta { font-size: 12px; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 8px; }
.booking-meta span { display: flex; align-items: center; gap: 4px; }

/* ─── Modal ───────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200; align-items: flex-end;
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-sheet {
    background: #fff; width: 100%;
    border-radius: 24px 24px 0 0;
    max-height: 92vh; overflow-y: auto;
    animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle {
    width: 40px; height: 4px;
    background: #E0E0E0; border-radius: 2px;
    margin: 12px auto 0;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
}
.modal-header h3 { font-size: 17px; font-weight: 700; flex: 1; }
.modal-close {
    width: 32px; height: 32px; border: none;
    background: var(--bg-primary); border-radius: 50%;
    cursor: pointer; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 20px; }

/* ─── Detail Row ──────────────────────────────────── */
.detail-row {
    display: flex; gap: 10px; padding: 10px 0;
    border-bottom: 1px solid var(--border-color); align-items: flex-start;
}
.detail-row:last-child { border-bottom: none; }
.detail-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.detail-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; }
.detail-value { font-size: 14px; font-weight: 600; }

/* ─── Today Stats ─────────────────────────────────── */
.stats-row {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
    margin-bottom: 16px;
}
.stat-card {
    background: #fff; border-radius: 14px; padding: 14px 10px;
    text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-number { font-size: 26px; font-weight: 800; color: var(--line-green); }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ─── Empty State ─────────────────────────────────── */
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 40px; color: #C8D0D8; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Toast ───────────────────────────────────────── */
#toast {
    position: fixed; bottom: 80px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1C1C1E; color: #fff;
    padding: 12px 24px; border-radius: 40px;
    font-size: 14px; font-weight: 600;
    z-index: 9999; opacity: 0;
    transition: all 0.3s; white-space: nowrap;
    pointer-events: none; max-width: 90vw;
}
#toast.success { background: var(--line-green); }
#toast.error { background: #FF3B30; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── Login Screen ────────────────────────────────── */
#login-screen {
    display: none; min-height: 100vh;
    background: linear-gradient(160deg, #06C755 0%, #04A844 60%, #038837 100%);
    flex-direction: column; align-items: center; justify-content: center;
    padding: 32px; text-align: center; gap: 24px;
}
#login-screen.visible { display: flex; }
.login-logo {
    width: 96px; height: 96px; background: #fff;
    border-radius: 28px; display: flex; align-items: center; justify-content: center;
    font-size: 44px; color: #06C755;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    margin-bottom: 8px;
}
.login-title { font-size: 28px; font-weight: 800; color: #fff; }
.login-subtitle { font-size: 15px; color: rgba(255,255,255,0.85); }
.btn-line-login {
    background: #fff; color: #06C755;
    padding: 16px 40px; border-radius: 40px;
    font-size: 16px; font-weight: 800;
    border: none; cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    display: flex; align-items: center; gap: 10px;
    transition: transform 0.2s;
}
.btn-line-login:active { transform: scale(0.97); }

/* ─── Availability Preview ────────────────────────── */
.avail-slots {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.avail-slot {
    padding: 6px 10px; border-radius: 8px; font-size: 11px;
    font-weight: 600; border: 1.5px solid;
}
.avail-slot.free { background: #E8F9EE; color: #06C755; border-color: #06C755; }
.avail-slot.busy { background: #FFE5E5; color: #FF3B30; border-color: #FF3B30; }

/* ─── Filter Tabs ─────────────────────────────────── */
.filter-tabs {
    display: flex; gap: 8px; overflow-x: auto;
    padding-bottom: 4px; margin-bottom: 12px;
    scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
    white-space: nowrap; padding: 7px 16px;
    border-radius: 20px; border: 1.5px solid var(--border-color);
    background: #fff; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    color: var(--text-secondary);
}
.filter-tab.active {
    background: var(--line-green); color: #fff; border-color: var(--line-green);
}

/* ─── Notice Box ─────────────────────────────────────── */
.notice-box {
    background: #F0F7FF; border: 1px solid #C8E0FF;
    border-radius: 10px; padding: 12px 14px;
    margin-bottom: 16px; font-size: 13px; color: #4A6FA5;
    display: flex; align-items: flex-start; gap: 8px;
}
.notice-box i { margin-top: 2px; flex-shrink: 0; }

/* ─── Print Styles ────────────────────────────────────── */
@media print {
    .bottom-nav, .app-header, .btn, .date-nav button,
    #toast, .modal-overlay { display: none !important; }
    .main-content { padding: 0 !important; }
    .view { display: block !important; padding: 0 !important; }
    .schedule-wrapper { overflow: visible !important; box-shadow: none !important; }
    .schedule-table { font-size: 10px !important; }
    body { background: white !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
    @page { margin: 1cm; }
}
