/*
 * 활자공간 예약 v2 공통 스타일
 * 구조: Design tokens → Base → Layout → Components → Responsive
 * 원칙: 다크 테마를 기본값으로 유지하고, 이전 라이트 테마 덮어쓰기 코드는 남기지 않는다.
 */

:root {
    color-scheme: dark;
    --bg: hsl(10 20% 4% / 1);
    --surface: hsl(21 17% 8% / 1);
    --surface-raised: hsl(24deg 20.75% 10.39%);
    --surface-sunken: hsl(18deg 24.14% 5.69%);
    --ink: hsl(36 24% 96% / 1);
    --muted: hsl(30deg 10.38% 64.12%);
    --line: hsl(43deg 14% 18.5%);
    --accent: #ff7a1a;
    --accent-dim: #101114;
    --danger: #e14b4b;
    --danger-dim: #241416;
    --warning: #ffc247;
    --warning-dim: #211d10;
    --ok: #1fc46b;
    --ok-dim: #0f2318;
    --ticket-orange: #ff7a1a;
    --ticket-dark: #101114;
    --ticket-muted-dark: rgba(16,17,20,.72);
    --ticket-muted-light: rgba(242,244,247,.72);
    --radius: 2px;
    --radius-card: 2px;
    --gap: 1.125em;
    --max-width: 1180px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;

    word-break: keep-all;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-size: 1rem;
}

body.body-modal-open,
body.mobile-menu-open {
    overflow: hidden;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--ink);
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    border-color: var(--accent);
}

button.primary,
.button.primary,
.settings-nav a.active,
.slot-btn.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #06110c;
}

button.danger,
.button.danger {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.button.small {
    padding: 6px 10px;
    font-size: 14px;
    /* margin-top: 6px; */
    width: max-content;
}

input,
select,
textarea {
    width: 100%;
    /* margin-top: 6px; */
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-sunken);
    color: var(--ink);
    height: 3em;
    padding: 0.5em 1em;
    font-weight: 400;
}

textarea {
    height: auto;
}

input[type="checkbox"] {
    height: 1.4em;
    padding: 0;
    margin: 0.8em;
}

label input,
label select,
label textarea {
    margin-top: 7px;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
.button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

label {
    display: block;
    /*margin-bottom: 8px;*/
    font-weight: 700;
}

table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--surface-raised);
    font-size: 13px;
}

/* Layout */
.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 28px;
    background: var(--bg);
    transition: transform .24s ease;
}

.brand {
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.brand .logo {
    width: 1.7em;
    height: 1.7em;
    margin: -0.5em 0.5em -0.5em 0;
    vertical-align: 0.025em;
}

.header-menu {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 18px;
}

.site-header nav {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: 10px;
}

.site-header nav a,
.account-link,
.logout button {
    padding: 7px 10px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font: inherit;
    text-decoration: none;
}

.site-header nav a.nav-link {
    display: inline-flex;
    align-items: flex-start;
    gap: 2px;
}

.nav-role-badge {
    display: inline-block;
    color: var(--accent);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: .04em;
    transform: translateY(-.35em);
}

.site-header nav a:hover,
.account-link:hover,
.logout button:hover {
    background: var(--accent-dim);
    color: var(--ink);
}

.header-account {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.logout {
    margin: 0;
}

.menu-toggle {
    display: none;
}

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 32px 20px 80px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--gap);
    margin-bottom: 18px;
}

.page-head h1 {
    margin: 0;
    font-size: 34px;
    font-weight: 600;
}

.grid {
    display: grid;
    gap: var(--gap);
}

.grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-actions,
.inline-form,
.inline-actions,
.action-grid,
.compact-form,
.modal-actions,
.search,
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inline-form,
.action-grid,
.compact-form,
.filter-bar {
    align-items: flex-end;
    margin-top: 18px;
}

.search {
    margin-bottom: 14px;
}

.search input {
    margin: 0;
    flex: 1;
}

.action-grid label,
.filter-bar label {
    min-width: 220px;
    flex: 1;
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Shared panels */
.hero,
.panel,
.auth-card,
.notice,
.table-wrap,
.day-col,
.settings-card,
.slot-message,
.reservation-time-first {
    margin-bottom: 22px;
    /* border: 1px solid var(--line); */
    border-radius: var(--radius-card);
    background: var(--surface);
}

.settings-card,
.slot-message {
    margin-bottom: 0;
}

.hero,
.panel,
.auth-card,
.notice {
    padding: 22px;
}

.hero {
    background: var(--accent);
    color: var(--ticket-dark);

    min-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content:space-between;
}

.hero h1,
.panel > h1,
.auth-card h1 {
    margin-top: 0;
    font-size: 1.75em;
    letter-spacing: -.015em;
    line-height: 1.2;
}

.hero h1 {
    font-size: 3em;
    font-weight: 500;
}

.panel > h1,
.panel > form > h1,
.auth-card > h1 {
    color: var(--accent);
    font-weight: 500;
}

.panel > h2,
.panel > form > h2 {
    margin-top: 1.5em;
    line-height: 1.25;
    color: var(--accent);
    border-top: 1.5px solid var(--accent);
    padding-top: 0.33em;
    font-weight: 500;
}

.panel > h2:first-of-type,
.panel > form > h2:first-of-type {
    margin-top: 0;
}

.panel h3 {
    margin: 0.5em 0;
}

.panel > *:first-child {
    margin-top: 0;
}

.panel > *:last-child,
.auth-card > *:last-child {
    margin-bottom: 0;
}

.panel > form > label,
.auth-card > form > label {
    margin-top: 1em;
}

.panel .foot,
.auth-card .foot {
    margin-top: 1.75em;
}

.foot button {
    margin-right: 0.33em;
}

.auth-card {
    max-width: 560px;
    margin-inline: auto;
    margin-top: 8vh;
}

.table-wrap {
    overflow: auto;
}

.table-wrap.compact table {
    min-width: 640px;
}

/* Text helpers and messages */
.muted,
.no-contents, 
.field-help {
    color: var(--muted);
}

.no-contents {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    padding: 0.5em 1em;

    border-radius: var(--radius);
}

.field-help {
    margin: 6px 0 0;
    font-size: 13px;
    font-weight: 400;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: var(--radius);
    background: var(--surface-raised);
    font-size: 12px;
    font-weight: 600;
}

.flash {
    margin-bottom: 14px;
    padding: 12px 15px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--ink);
}

.flash.success {
    border-color: #276d43;
    background: var(--ok-dim);
}

.flash.warning {
    border-color: #75601f;
    background: var(--warning-dim);
}

.flash.danger {
    border-color: #7b2a2a;
    background: var(--danger-dim);
}

.clean {
    padding-left: 0;
    list-style: none;

    background: var(--surface-raised);
    border: 1px solid var(--line);
    padding: 0.33em 1em;

    border-radius: var(--radius);
}

.clean li {
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
}

.clean li:last-of-type {
    border-bottom: none;
}

.clean li > strong:after {
    content: '|';
    font-weight: 400;
    color: var(--line);
    margin: 0 .2em 0 .5em;
}

.small-list {
    font-size: 14px;
}

.markdown strong {
    text-decoration: underline solid 2.5px var(--accent);
}

.markdown p:first-child,
.markdown ul:first-child,
.markdown ol:first-child {
    margin-top: 0;
}

.markdown p:last-child,
.markdown ul:last-child,
.markdown ol:last-child {
    margin-bottom: 0;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: max-content;

}

.checkline input {
    width: auto;
    margin: 0;
}

.detail {
    display: grid;
    grid-template-columns: 124px 1fr;
    gap: 10px 18px;
}

.detail dt {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.875em;
}

.detail dd {
    margin: 0;
}

/* Tickets */
.ticket-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    align-items: start;
}

.dashboard-ticket-panels .ticket-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.ticket {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    /* aspect-ratio: 1 / 1.414; */
    padding: 22px;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius);
    background: var(--ticket-orange);
    color: var(--ticket-dark);
    text-align: left;
    text-decoration: none;
}

.ticket-button {
    appearance: none;
    font: inherit;
    cursor: pointer;
}

.ticket-button:hover,
.ticket-link:hover {
    outline: 2px solid rgba(255, 255, 255, .35);
    outline-offset: 2px;
}

.ticket-meta,
.ticket-label {
    /* color: var(--ticket-muted-dark); */
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.ticket-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticket-main,
.ticket-bottom,
.ticket-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.ticket-main {
    align-items: flex-start;
    margin-top: 10px;
}

.ticket-bottom,
.ticket-footer {
    align-items: flex-end;
}

.ticket-title {
    display: block;
    font-size: clamp(28px, 3.0vw, 40px);
    line-height: 1.15;
    word-break: keep-all;
    font-weight:  500;
    letter-spacing: -.03em;
}

.ticket-status {
    display: inline-flex;
    align-self: flex-start;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--ticket-dark);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.ticket-divider {
    height: 1px;
    margin: 16px 0;
    background: var(--ticket-dark);
}

.ticket-divider-top {
    margin-top: 20px;
    margin-bottom: 18px;
}

.ticket-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin: 0;
}

.ticket-info strong,
.ticket-bottom strong,
.ticket-footer span {
    display: block;
    font-size: 18px;
    line-height: 1.16;
    letter-spacing: 0;
    font-weight:  500;
}

.ticket-info small,
.ticket-bottom span,
.ticket-footer span:last-child {
    color: var(--ticket-muted-dark);
    font-size: 12px;
}

.ticket-bottom span,
.ticket-footer span:last-child {
    font-size: 14px;
    text-align: right;
}

.ticket-spacer {
    flex: 1;
    min-height: 12px;
}

.status-approved.ticket,
.ticket-modal-hero.status-approved {
    background: var(--ticket-orange);
}

.ticket-modal-hero .badge {
    color: var(--ink);
}

.status-pending.ticket,
.ticket-modal-hero.status-pending {
    background: var(--warning);
}

.status-rejected.ticket,
.status-cancelled.ticket,
.ticket-modal-hero.status-rejected,
.ticket-modal-hero.status-cancelled {
    background: hsl(215 10% 50% / 1);
}

.status-rejected.ticket .ticket-meta,
.status-rejected.ticket .ticket-label,
.status-rejected.ticket .ticket-info small,
.status-rejected.ticket .ticket-bottom span,
.status-cancelled.ticket .ticket-meta,
.status-cancelled.ticket .ticket-label,
.status-cancelled.ticket .ticket-info small,
.status-cancelled.ticket .ticket-bottom span {
    color: var(--ticket-dark);
}

.status-rejected.ticket .ticket-divider,
.status-cancelled.ticket .ticket-divider {
    background: var(--ticket-dark);
}

/* Reservation form and schedule */
.reservation-time-first {
    margin: 18px 0 22px;
    padding: 18px;
    background: var(--surface-raised);
    border: 1px solid var(--line);
}

.reservation-time-first .slot-picker {
    margin-bottom: 0;
}

.slot-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
    gap: 8px;
    margin: 12px 0 20px;
}

.slot-btn {
    padding: 10px;
    background: var(--surface-raised);
}

.slot-btn.disabled {
    color: var(--muted);
    cursor: not-allowed;
    opacity: 0.6;

    text-decoration: line-through 1.5px var(--muted);
}

.slot-message {
    padding: 12px;
    margin-top: 1em;
    background: var(--surface);
}

.week-grid {
    margin-top: 1.25em;
}

.day-col {
    padding: 8px 16px;
    margin-bottom: 18px;
}

.day-col h3 {
    margin-top: 0;
    color: var(--accent);
    font-weight: 600;
}

.schedule-item {
    display: block;
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(
    --ink);
    text-decoration: none;
}

.weekday-box {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
}

.weekday-box .checkline {
    margin-top: 8px;
}

/* Settings */
.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.settings-nav a {
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-raised);
    text-decoration: none;
}

.settings-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--gap);
}

.settings-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 22px 20px;
    text-decoration: none;
}

.settings-card strong {
    font-size: 20px;
    color: var(--accent);
}

/* Modal */
.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .82);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(900px, calc(100vw - 48px));
    max-height: calc(100vh - 48px);
    margin: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: var(--surface);
}

.ticket-modal-dialog {
    padding: 0;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius);
    background: var(--surface-raised);
    color: var(--ink);
    font-size: 24px;
    line-height: 1;
}

.modal-close img {
    width: 0.75em;
    height: 0.75em;
}

.ticket-modal-hero {
    padding: 20px 28px 22px;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    color: var(--ticket-dark);
}

.ticket-modal-hero h2 {
    margin: 6px 0 10px;
    font-size: 42px;
    line-height: .96;
    letter-spacing: -.05em;
    font-weight: 500;
}

.modal-panel {
    margin: 0;
    border: 0;
    border-radius: 0 0 var(--radius-card) var(--radius-card);
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 20px;
}

/* Warnings */
.warning-state {
    background: #1c1f25;
}

.warning-state.유효 {
    background: #102719;
    color: #6ee59a;
}

.warning-state.소멸,
.warning-state.삭제됨 {
    background: #2a1718;
    color: #ff8a8a;
}

.warning-table .badge {
    white-space: nowrap;
}

.error-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

/* Responsive */
@media (max-width: 760px) {
    body {
        font-size: 0.875rem;
    }

    .site-header {
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--bg);
    }

    .site-header.header-hidden:not(.menu-open) {
        transform: translateY(-110%);
    }

    .brand {
        position: relative;
        z-index: 80;
        max-width: calc(100vw - 86px);
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 1.125em;
    }

    .menu-toggle {
        position: relative;
        z-index: 80;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        width: 44px;
        height: 44px;
        padding: 0;
        border: none;
        background: transparent;
    }

    .menu-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--ink);
        transition: transform .18s ease, opacity .18s ease;
    }

    .site-header.menu-open .menu-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .site-header.menu-open .menu-toggle span:nth-child(2) {
        opacity: 0;
    }

    .site-header.menu-open .menu-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .header-menu {
        position: fixed;
        inset: 0;
        z-index: 60;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 18px;
        padding: 86px 22px 32px;
        background: var(--bg);
        opacity: 0;
        pointer-events: none;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
    }

    .site-header.menu-open .header-menu {
        opacity: 1;
        pointer-events: auto;
        visibility: visible;
        transform: translateY(0);
    }

    .site-header nav,
    .header-account {
        width: 100%;
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .site-header nav a,
    .account-link,
    .logout button {
        width: 100%;
        padding: 16px 0;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        color: var(--ink);
        font-size: 20px;
        text-align: left;
    }

    .site-header nav a.nav-link {
        justify-content: flex-start;
        gap: 4px;
    }

    .nav-role-badge {
        font-size: 12px;
        transform: translateY(-.45em);
    }

    .logout button {
        justify-content: flex-start;
        border-top: 0;
        border-right: 0;
        border-left: 0;
        background: transparent;
    }

    .container {
        padding: 20px 14px 64px;
    }

    .grid.two,
    .detail,
    .week-grid {
        grid-template-columns: 1fr;
    }

    .page-head {
        flex-direction: column;
    }

    .hero,
    .panel,
    .auth-card,
    .notice {
        padding: 22px 18px;
    }

    .ticket {
        padding: 18px;
    }

    .ticket-title {
        font-size: 36px;
    }

    .ticket-info {
        grid-template-columns: 1fr;
    }

    .modal {
        padding: 16px;
    }

    .modal-dialog {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 32px);
    }
}
