/* ===== VARIABLES ===== */
:root {
    --sidebar-w: 220px;
    --header-h: 56px;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --sidebar-bg: #1e2028;
    --sidebar-text: rgba(255,255,255,0.55);
    --sidebar-text-hover: rgba(255,255,255,0.88);
    --sidebar-active-bg: rgba(255,255,255,0.1);
    --sidebar-active-text: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --text: #111827;
    --text-dim: #6b7280;
    --text-light: #9ca3af;
    --accent: #404759;
    --accent-hover: #333a4d;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Inter', 'Apple SD Gothic Neo', -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }

/* ===== SHELL ===== */
.admin-shell { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.admin-sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-logo {
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.03em;
}

.sidebar-close {
    color: var(--sidebar-text);
    font-size: 1.1rem;
    display: none;
    padding: 4px 6px;
    line-height: 1;
}

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1.25rem;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    width: 100%;
    text-align: left;
    border-radius: 0;
}

.nav-item:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-text-hover);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 0.5rem 0;
    flex-shrink: 0;
}

.logout-btn { color: var(--sidebar-text); }

/* ===== OVERLAY (mobile) ===== */
.admin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
}

/* ===== BODY ===== */
.admin-body {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== HEADER ===== */
.admin-header {
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.menu-btn {
    width: 32px;
    height: 32px;
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 4px;
    flex-shrink: 0;
}

.menu-btn span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

.header-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dim);
}

/* ===== CONTENT ===== */
.admin-content {
    padding: 1.5rem;
    flex: 1;
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text);
}

.page-subtitle {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.2rem;
}

/* ===== CARD ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
    font-size: 0.875rem;
}

.card-body { padding: 1.25rem; }

/* ===== STAT CARDS ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
}

.stat-sub {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 0.35rem;
}

/* ===== STATUS BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th {
    text-align: left;
    padding: 0.6rem 1rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    background: var(--border-light);
    white-space: nowrap;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }
tr.clickable { cursor: pointer; }

th.th-sort { cursor: pointer; user-select: none; }
th.th-sort:hover { background: #e5e7eb; }
.sort-arrows { display: inline-block; margin-left: 3px; vertical-align: middle; line-height: 0; fill: #9ca3af; }
th.sort-on .sort-arrows { fill: var(--accent); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    line-height: 1.4;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-default { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-default:hover { background: #f9fafb; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== FORM ===== */
.form-group { margin-bottom: 1rem; }

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
    outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[style*="width: auto"] { width: auto; }

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.35rem;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 130px; }

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: var(--text-dim);
    padding: 0.75rem 0;
}

/* ===== STATES ===== */
.loading-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-dim);
    padding: 2rem;
    justify-content: center;
}

.error-msg {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
    font-size: 0.875rem;
}

/* ===== LOGIN PAGE ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-md);
}

.login-title {
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.3rem;
}

.login-subtitle {
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 1.75rem;
}

.form-input {
    display: block;
    width: 100%;
    height: 2.625rem;
    padding: 0 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    line-height: normal;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    box-shadow: none;
    transition: border-color 0.15s;
}

.form-input::placeholder {
    color: var(--text-light);
    font-size: 0.875rem;
    opacity: 1;
}

.form-input:focus {
    border-color: var(--accent);
}

.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    -webkit-text-fill-color: var(--text);
    transition: background-color 5000s ease-in-out 0s;
}

.form-input::-ms-reveal,
.form-input::-ms-clear { display: none; }

/* ===== DETAIL VIEW ===== */
.detail-section { margin-bottom: 1.5rem; }

.detail-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.detail-item label {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-bottom: 0.15rem;
}

.detail-item .value {
    font-size: 0.9rem;
    color: var(--text);
}

.action-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

/* ===== CALENDAR ===== */
.calendar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.calendar-month-label {
    font-size: 1rem;
    font-weight: 600;
    min-width: 100px;
    text-align: center;
}

.cal-container {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--border-light);
    border-bottom: 1px solid var(--border);
}

.cal-day-header {
    text-align: center;
    padding: 0.45rem;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-dim);
}

/* 주간 행: 날짜 셀 7개(grid) + 절대위치 바들 */
.cal-week {
    position: relative;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}
.cal-week:last-child { border-bottom: none; }

.cal-day {
    min-height: 80px;
    padding: 0.25rem 0.3rem;
    border-right: 1px solid var(--border);
    background: var(--surface);
}
.cal-day:last-child { border-right: none; }
.cal-day.other-month { background: #fafafa; }
.cal-day.today { background: #f0f4ff; }

.cal-date {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}
.cal-day.other-month .cal-date { color: var(--text-light); }

/* 예약 바: 절대 포지셔닝, left/width/top은 인라인 style로 설정 */
.cal-bar {
    position: absolute;
    height: 18px;
    line-height: 18px;
    margin-top: 2px;
    font-size: 0.62rem;
    color: #fff;
    z-index: 1;
    cursor: pointer;
}
.cal-bar:hover { z-index: 50; opacity: 0.9; }
.cal-bar-blocked { cursor: default; }
.cal-bar-blocked:hover { opacity: 1; }

.bar-label {
    display: block;
    height: 18px;
    padding: 0 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-start { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.bar-end   { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }

.cal-bar-witjip    { background: #3b82f6; }
.cal-bar-araetjip  { background: #22c55e; }
.cal-bar-yeopjipA  { background: #f97316; }
.cal-bar-yeopjipB  { background: #a855f7; }
.cal-bar-blocked   { background: #d1d5db; color: #374151; }

.cal-tip-hidden { display: none !important; }

/* Floating 툴팁: position:fixed — cal-container overflow:hidden에 잘리지 않음 */
.cal-float-tooltip {
    position: fixed;
    min-width: 200px;
    background: #1e293b;
    color: #f1f5f9;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.75rem;
    line-height: 1.75;
    white-space: nowrap;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    pointer-events: none;
}

.tip-key {
    display: inline-block;
    width: 3.5em;
    color: #94a3b8;
    font-size: 0.7rem;
}

/* ===== BLAZOR ERROR UI ===== */
#blazor-error-ui {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 4px;
    bottom: 1rem;
    right: 1rem;
    padding: 0.75rem 1rem;
    position: fixed;
    z-index: 1000;
    font-size: 0.8rem;
    display: none;
}
#blazor-error-ui .reload { color: var(--accent); font-weight: 600; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { cursor: pointer; margin-left: 0.75rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-shell.sidebar-open .admin-sidebar { transform: translateX(0); }
    .admin-shell.sidebar-open .admin-overlay { display: block; }
    .admin-shell.sidebar-open .sidebar-close { display: block; }
    .admin-body { margin-left: 0; }
    .menu-btn { display: flex; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .filter-bar .form-group { min-width: 0; width: 100%; }
    .cal-day { min-height: 60px; }
    .bar-label { font-size: 0; }
    .cal-float-tooltip { display: none !important; }
}
