/* ===== 마사지 샵 관리 시스템 - 공통 스타일 ===== */
:root {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-elevated: #232340;
    --primary: #e94560;
    --primary-hover: #ff6b81;
    --accent: #0f3460;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #2d2d4a;
    --radius: 12px;
    --header-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: var(--safe-bottom);
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
ul { list-style: none; }

/* ===== Header ===== */
.app-header {
    position: sticky; top: 0; z-index: 100;
    height: var(--header-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px;
    backdrop-filter: blur(12px);
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; }
.app-title { font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
@media (min-width: 600px) { .app-title { max-width: none; } }
.user-badge { font-size: 0.8rem; color: var(--text-muted); background: var(--bg-elevated); padding: 4px 10px; border-radius: 20px; }
.btn-icon {
    background: transparent; border: none; color: var(--text);
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; cursor: pointer;
}
.btn-icon:hover, .btn-icon:active { background: var(--bg-elevated); }

/* ===== Side Menu ===== */
.side-menu {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; max-width: 85vw;
    background: var(--bg-card); z-index: 200;
    transform: translateX(-100%); transition: transform 0.25s ease;
    display: flex; flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
}
.side-menu.open { transform: translateX(0); }
.side-menu-header {
    height: var(--header-h); display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px; border-bottom: 1px solid var(--border);
}
.side-menu ul { padding: 12px 0; flex: 1; overflow-y: auto; }
.side-menu li a {
    display: block; padding: 14px 20px; color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.side-menu li a:hover, .side-menu li a.active { background: var(--bg-elevated); color: var(--text); }
.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150;
    opacity: 0; visibility: hidden; transition: 0.25s;
}
.overlay.show { opacity: 1; visibility: visible; }

/* ===== Main ===== */
.main-content { padding: 12px; max-width: 1400px; margin: 0 auto; }

/* ===== Waiting Bar ===== */
.waiting-bar {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 12px 16px; margin-bottom: 16px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    border: 1px solid var(--border);
}
.waiting-label { font-weight: 600; color: var(--text-muted); font-size: 0.85rem; }
.waiting-list { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.therapist-chip {
    background: var(--bg-elevated); padding: 4px 12px; border-radius: 20px;
    font-size: 0.85rem; display: inline-flex; align-items: center; gap: 4px;
}
.therapist-chip .code { color: var(--primary); font-weight: 700; }

/* ===== Rooms Grid ===== */
.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.room-card {
    background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border); overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
}
.room-card:active { transform: scale(0.98); }
.room-card.occupied { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.room-card.warning { border-color: var(--warning); box-shadow: 0 0 12px rgba(245,158,11,0.4); animation: pulse-warn 1.5s infinite; }
@keyframes pulse-warn {
    0%, 100% { box-shadow: 0 0 8px rgba(245,158,11,0.3); }
    50% { box-shadow: 0 0 20px rgba(245,158,11,0.7); }
}
.room-header {
    padding: 12px 16px; display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-elevated); border-bottom: 1px solid var(--border);
}
.room-name { font-weight: 700; font-size: 1.05rem; }
.room-beds { font-size: 0.8rem; color: var(--text-muted); }
.room-status-badge {
    font-size: 0.75rem; font-weight: 600; padding: 3px 10px; border-radius: 12px;
}
.badge-available { background: rgba(16,185,129,0.2); color: var(--success); }
.badge-occupied { background: rgba(233,69,96,0.2); color: var(--primary); }
.badge-warning { background: rgba(245,158,11,0.25); color: var(--warning); }

.room-body { padding: 14px 16px; min-height: 110px; }
.room-empty { color: var(--text-muted); text-align: center; padding: 20px 0; font-size: 0.9rem; }
.session-info { display: flex; flex-direction: column; gap: 6px; }
.session-therapist { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.session-therapist img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.session-time { font-size: 0.9rem; color: var(--text-muted); }
.session-customer { font-size: 0.85rem; color: var(--text-muted); }
.progress-bar {
    height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 8px;
}
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 1s linear; }
.progress-fill.warning { background: var(--warning); }
.time-left {
    font-size: 1.1rem; font-weight: 700; margin-top: 6px;
}
.time-left.warning { color: var(--warning); }
.time-left.danger { color: var(--danger); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 8px; border: none; font-weight: 600;
    cursor: pointer; transition: background 0.15s, transform 0.1s;
    font-size: 0.95rem;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Modal ===== */
.modal {
    position: fixed; inset: 0; z-index: 300;
    display: flex; align-items: flex-end; justify-content: center;
    background: rgba(0,0,0,0.6); padding: 0;
}
@media (min-width: 600px) {
    .modal { align-items: center; padding: 20px; }
}
.modal[hidden] { display: none !important; }
.modal-content {
    background: var(--bg-card); width: 100%; max-width: 440px;
    border-radius: 16px 16px 0 0; max-height: 90vh; overflow-y: auto;
    animation: slideUp 0.25s ease;
}
@media (min-width: 600px) {
    .modal-content { border-radius: 16px; }
}
@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.15rem; }
.modal-content form, #sessionDetail { padding: 16px 20px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="tel"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); }
.duration-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.duration-btn {
    flex: 1; min-width: 70px; text-align: center; cursor: pointer;
}
.duration-btn input { display: none; }
.duration-btn span {
    display: block; padding: 10px 8px; border-radius: 8px;
    background: var(--bg); border: 2px solid var(--border); font-weight: 600; font-size: 0.9rem;
}
.duration-btn input:checked + span { border-color: var(--primary); background: rgba(233,69,96,0.15); color: var(--primary); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px 20px; border-top: 1px solid var(--border); }
.form-actions .btn { flex: 1; }

/* ===== Toast ===== */
.toast {
    position: fixed; bottom: calc(20px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
    background: #333; color: #fff; padding: 12px 24px; border-radius: 30px;
    font-size: 0.9rem; z-index: 400; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: fadeIn 0.2s;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ===== Loading ===== */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ===== Tables (관리 페이지용) ===== */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-header h2 { font-size: 1.25rem; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; background: var(--bg-card); }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { background: var(--bg-elevated); font-weight: 600; color: var(--text-muted); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--bg-elevated); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; }
.badge-success { background: rgba(16,185,129,0.2); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.2); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.2); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.2); color: #3b82f6; }

/* ===== Install PWA Banner ===== */
.pwa-banner {
    position: fixed; bottom: calc(16px + var(--safe-bottom)); left: 16px; right: 16px;
    background: var(--primary); color: #fff; padding: 14px 16px; border-radius: 12px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    z-index: 90; box-shadow: 0 8px 24px rgba(233,69,96,0.4);
    animation: slideUp 0.3s;
}
.pwa-banner button { background: #fff; color: var(--primary); border: none; padding: 8px 16px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.pwa-banner .close-pwa { background: transparent; color: #fff; font-size: 1.2rem; padding: 4px; }

/* ===== Utility ===== */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
