/* ========================================
   노원구 축구장 예약 시스템 스타일
   모바일 반응형 UI/UX
   ======================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #0891b2;
    --info-light: #cffafe;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -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);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========== Container ========== */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container-wide {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px 32px;
    padding-top: 140px;
}

/* ========== Navbar ========== */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.nav-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    min-height: 44px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-brand h1 {
    font-size: 1.1rem;
    color: var(--primary);
    white-space: nowrap;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-user {
    display: none;
}

/* Nav Tabs - 하단 고정 느낌 */
.nav-tabs {
    display: flex;
    border-top: 1px solid var(--border);
}

.nav-tab {
    flex: 1;
    padding: 8px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
}

.nav-tab:hover { color: var(--primary); background: var(--primary-light); }
.nav-tab.active {
    color: var(--primary);
    background: var(--primary-light);
}
.nav-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0; left: 20%; right: 20%;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
}

/* Session Bar */
.session-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg);
    font-size: 0.7rem;
    color: var(--text-light);
    overflow-x: auto;
    white-space: nowrap;
}

.session-bar .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-green { background: var(--success-light); color: var(--success); }
.badge-blue { background: var(--primary-light); color: var(--primary); }

/* ========== Login Box ========== */
.login-box {
    width: 100%;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px 24px;
}

.logo {
    text-align: center;
    margin-bottom: 28px;
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-light);
    font-size: 0.82rem;
}

.login-section {
    margin-bottom: 20px;
}

.login-section h2 {
    font-size: 0.92rem;
    margin-bottom: 14px;
    color: var(--text);
}

.help-text {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-bottom: 10px;
    line-height: 1.5;
}

/* ========== Divider ========== */
.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    padding: 0 12px;
    color: var(--text-light);
    font-size: 0.78rem;
}

/* ========== Form ========== */
.form-group {
    margin-bottom: 14px;
    flex: 1;
    min-width: 0;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px; /* iOS 줌 방지 */
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--card-bg);
    color: var(--text);
    -webkit-appearance: none;
    appearance: none;
}

.form-group 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='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group input:focus,
.form-group select:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: flex;
    gap: 12px;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    gap: 6px;
    white-space: nowrap;
    touch-action: manipulation;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: var(--secondary); color: white; }
.btn-info { background: var(--info); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
    padding: 9px 14px;
}
.btn-outline:hover { background: var(--bg); }

.btn-full { width: 100%; }

.btn-sm {
    padding: 4px 8px;
    font-size: 0.7rem;
    border-radius: 6px;
}

.btn-group {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

/* ========== Card ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.card-header h2 {
    font-size: 0.95rem;
    color: var(--text);
    white-space: nowrap;
}

.card-header .btn-group-header {
    display: flex;
    gap: 6px;
}

.card-body {
    padding: 18px;
}

/* ========== Fee Grid ========== */
.fee-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.fee-item {
    text-align: center;
    padding: 14px 8px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.fee-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.fee-value {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}

/* ========== Log Area ========== */
.log-area {
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 0.75rem;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 14px;
    -webkit-overflow-scrolling: touch;
    word-break: break-word;
}

.log-entry {
    padding: 3px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    line-height: 1.5;
}

.log-entry:last-child { border-bottom: none; }
.log-info { color: #38bdf8; }
.log-success { color: #4ade80; }
.log-error { color: #f87171; }
.log-warn { color: #fbbf24; }
.log-time { color: #94a3b8; margin-right: 6px; font-size: 0.7rem; }

/* ========== Alert ========== */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }

/* ========== Info Box ========== */
.info-box {
    margin-top: 20px;
    padding: 14px;
    background: #eff6ff;
    border-radius: var(--radius-sm);
    border: 1px solid #bfdbfe;
}

.info-box h3 {
    font-size: 0.85rem;
    margin-bottom: 6px;
    color: var(--primary);
}

.info-box ul {
    list-style: none;
    font-size: 0.78rem;
    color: var(--text-light);
}

.info-box li { padding: 2px 0; }
.info-box li::before { content: '•'; color: var(--primary); margin-right: 6px; }

/* ========== Modal ========== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--card-bg);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--card-bg);
}

.modal-header h2 { font-size: 1rem; }

.modal-close {
    background: var(--bg);
    border: none;
    width: 32px; height: 32px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    text-align: right;
    position: sticky;
    bottom: 0;
    background: var(--card-bg);
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.result-item:last-child { border-bottom: none; }
.result-label { color: var(--text-light); font-size: 0.85rem; }
.result-value { font-weight: 600; font-size: 0.9rem; }

/* ========== Spinner ========== */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 6px;
}

/* ========== Time Display ========== */
.time-display {
    text-align: center;
    padding: 10px 0;
}

.time-main {
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
}

.time-sub {
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--text-light);
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========== Schedule Table → Mobile Cards ========== */
.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.schedule-table th {
    background: var(--bg);
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 0.78rem;
}

.schedule-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.schedule-table tr:hover { background: #f8fafc; }

.schedule-table .remaining {
    font-family: 'SF Mono', monospace;
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
}

.schedule-table .result-cell {
    font-size: 0.72rem;
    max-width: 150px;
    word-break: break-all;
}

.schedule-table .result-cell small { color: var(--text-light); }

/* Mobile Schedule Cards */
.schedule-cards { display: none; }

.schedule-card {
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}

.schedule-card.status-done { border-color: var(--success); background: #f0fdf4; }
.schedule-card.status-failed { border-color: var(--danger); background: #fef2f2; }
.schedule-card.status-waiting { border-color: var(--warning); }

.sch-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.sch-card-status {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
}

.sch-card-status.st-waiting { background: var(--warning-light); color: #92400e; }
.sch-card-status.st-running { background: var(--info-light); color: #155e75; }
.sch-card-status.st-done { background: var(--success-light); color: #166534; }
.sch-card-status.st-failed { background: var(--danger-light); color: #991b1b; }

.sch-card-delete {
    background: none;
    border: 1.5px solid var(--danger);
    color: var(--danger);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}

.sch-card-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    font-size: 0.8rem;
}

.sch-card-info dt {
    color: var(--text-light);
    font-size: 0.72rem;
}

.sch-card-info dd {
    font-weight: 600;
    margin-bottom: 4px;
}

.sch-card-remaining {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-family: 'SF Mono', monospace;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
}

.sch-card-result {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.72rem;
    word-break: break-all;
    color: var(--text-light);
}

/* Status Colors for table */
.status-waiting td:first-child { color: var(--warning); }
.status-running td:first-child { color: var(--info); }
.status-done td:first-child { color: var(--success); }
.status-failed td:first-child { color: var(--danger); }
.status-done { background: #f0fdf4 !important; }
.status-failed { background: #fef2f2 !important; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* ========== RESPONSIVE ========== */

/* 태블릿 이하 */
@media (max-width: 768px) {
    .container {
        padding: 16px 12px;
    }

    .container-wide {
        padding-top: 130px;
    }

    .login-box {
        padding: 28px 20px;
        border-radius: var(--radius-sm);
    }

    .logo h1 { font-size: 1.3rem; }

    .card-header { padding: 12px 16px; }
    .card-body { padding: 16px; }

    .fee-grid { gap: 8px; }
    .fee-item { padding: 10px 6px; }
    .fee-value { font-size: 0.95rem; }

    .time-main { font-size: 1.4rem; }

    /* 테이블 → 카드 전환 */
    .schedule-table { display: none; }
    .schedule-cards { display: block; }
}

/* 모바일 */
@media (max-width: 480px) {
    .container-wide {
        padding-left: 10px;
        padding-right: 10px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn {
        padding: 13px 20px;
        font-size: 0.92rem;
    }

    .nav-brand h1 { font-size: 0.95rem; }

    .card { border-radius: var(--radius-sm); }
    .card-header h2 { font-size: 0.88rem; }

    .log-area {
        max-height: 200px;
        font-size: 0.7rem;
        padding: 10px;
    }

    .modal-content {
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
    }

    .fee-grid { grid-template-columns: repeat(3, 1fr); }

    .time-main { font-size: 1.2rem; letter-spacing: 0; }

    .info-box { padding: 12px; }
    .info-box ul { font-size: 0.75rem; }
}

/* 데스크톱 */
@media (min-width: 769px) {
    .container-wide {
        padding-top: 140px;
    }

    .nav-user { display: inline; }

    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius);
        max-width: 500px;
    }

    .schedule-cards { display: none; }
    .schedule-table { display: table; }
}

/* Safe areas (노치 대응) */
@supports (padding-top: env(safe-area-inset-top)) {
    .navbar { padding-top: env(safe-area-inset-top); }
    .container-wide { padding-bottom: env(safe-area-inset-bottom); }
}
