@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&display=swap');
:root {
    --primary: #06C755;
    --primary-dark: #05A546;
    --primary-light: #E6F9ED;
    --bg-main: #F4F7F6;
    --bg-card: #FFFFFF;
    --text-main: #111111;
    --text-muted: #666666;
    --border-color: #E5E5E5;
    --danger: #FF3B30;
    --warning: #FF9500;
    --warning-light: #FFF4E5;
    --nav-height: 60px;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'IBM Plex Sans Thai', sans-serif; }
body { background-color: var(--bg-main); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-height: 100vh; color: var(--text-main); overflow: hidden; }

/* In LIFF, the phone frame should be 100vw, 100vh without borders */
.phone-frame { width: 100vw; height: 100vh; background: var(--bg-main); position: relative; overflow: hidden; display: flex; flex-direction: column; }

.screen { display: none; flex-direction: column; height: 100%; position: absolute; top:0; left:0; width: 100%; background: var(--bg-main); z-index: 1; }
.screen.active { display: flex; z-index: 2; }

/* Header/Chrome */
.liff-header { height: 50px; background: white; display: flex; align-items: center; justify-content: center; position: relative; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.liff-header h1 { font-size: 16px; font-weight: 600; }
.liff-close { position: absolute; left: 16px; cursor: pointer; font-size: 20px; }

.scrollable { flex: 1; overflow-y: auto; position: relative; }
.scrollable::-webkit-scrollbar { display: none; }

/* Bottom Nav / Footer */
.liff-nav { height: 60px; background: white; border-top: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-around; flex-shrink: 0; padding-bottom: 8px;}
.liff-nav-item { display: flex; flex-direction: column; align-items: center; color: var(--text-muted); font-size: 12px; cursor: pointer; gap: 4px; flex: 1; justify-content: center; }
.liff-nav-item.active { color: var(--primary); }
.liff-nav-item svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.5; fill: none; }

.footer-action { padding: 16px; background: white; border-top: 1px solid var(--border-color); flex-shrink: 0; }
.btn { width: 100%; padding: 14px; border-radius: 8px; font-size: 16px; font-weight: 600; text-align: center; cursor: pointer; border: none; display:block;}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: #E5E5E5; color: var(--text-main); }

/* Utilities */
.p-4 { padding: 16px; }
.flex-col { display: flex; flex-direction: column; }
.flex-row { display: flex; align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.text-center { text-align: center; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 20px; font-weight: 700; }
.text-sm { font-size: 14px; }
.text-primary { color: var(--primary); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.card { background: white; border-radius: 12px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); margin-bottom: 16px; }

/* Form */
.input-group { margin-bottom: 16px; }
.input-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.req { color: var(--danger); }
.input-text { width: 100%; padding: 12px; border: 1px solid var(--border-color); border-radius: 8px; font-size: 16px; background: white; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 16px; border: 1px solid var(--border-color); border-radius: 20px; font-size: 14px; cursor: pointer; background: white; user-select: none; }
.chip.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.chip-day { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border-color); font-size: 14px; cursor: pointer; background: white; user-select: none; }
.chip-day.active { background: var(--primary); border-color: var(--primary); color: white; font-weight: 600; }

/* Custom Toggle */
.ios-toggle { width: 40px; height: 24px; background: var(--primary); border-radius: 24px; position: relative; cursor: pointer; transition: background 0.3s; flex-shrink: 0; }
.ios-toggle::after { content: ''; position: absolute; width: 20px; height: 20px; background: white; border-radius: 50%; top: 2px; right: 2px; transition: right 0.3s, left 0.3s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.ios-toggle.off { background: #E5E7EB; border: 1px solid var(--border-color); }
.ios-toggle.off::after { right: auto; left: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.paused-label { font-size: 12px; color: var(--text-muted); background: var(--bg-main); padding: 2px 8px; border-radius: 4px; margin-left: 8px; font-weight: normal; vertical-align: middle; display: none; }
.card.paused { opacity: 0.5; }
.card.paused .paused-label { display: inline-block; }

/* Drawer */
.drawer-overlay { display: none; position: absolute; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.5); z-index:50; flex-direction:column; justify-content:flex-end; }
.drawer-overlay.active { display: flex; }
.drawer-content { background:white; border-radius: 24px 24px 0 0; padding:24px; display:flex; flex-direction:column; height: 70%; }

/* Day Selector */
.day-selector { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: white; border-bottom: 1px solid var(--border-color); }
.day-pill { background: var(--primary-light); color: var(--primary-dark); padding: 4px 12px; border-radius: 12px; font-size: 14px; font-weight: 600; text-align:center; }

/* Toast */
.toast { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); color: white; padding: 12px 24px; border-radius: 24px; font-size: 14px; opacity: 0; transition: opacity 0.3s; z-index: 100; pointer-events:none; }
.toast.show { opacity: 1; }

#liff-error { display: none; padding: 20px; text-align: center; height: 100vh; flex-direction: column; align-items: center; justify-content: center; font-size: 18px; width: 100%; background: white; }
#liff-loading { display: flex; height: 100vh; width: 100%; flex-direction: column; align-items: center; justify-content: center; background: white; }
.spinner { width: 44px; height: 44px; border: 4px solid var(--primary-light); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
