/* ========================================
   BookPicker — Subtle Sketch Style
   ======================================== */

/* --- Reset & Base --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #FAFAF5;
    color: #2c2c2c;
    line-height: 1.6;
    min-height: 100vh;
}

/* --- Nav --- */
.nav {
    background: #fff;
    border-bottom: 1.5px solid #d0d0d0;
    padding: 0.7rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.nav-logo {
    font-family: 'Nanum Pen Script', cursive;
    font-weight: 400;
    font-size: 1.45rem;
    color: #2c2c2c;
    text-decoration: none;
    letter-spacing: -0.3px;
}
.nav-logo:hover { color: #E8726A; }
.nav-link {
    color: #888;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-link:hover { color: #2c2c2c; }

/* --- Container --- */
.container {
    max-width: 860px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* --- Typography --- */
h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
    font-weight: 700;
    color: #2c2c2c;
}
.subtitle {
    color: #888;
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

/* --- Form --- */
.form-section { margin-bottom: 1.75rem; }
.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: #2c2c2c;
}
.hint {
    color: #999;
    font-size: 0.85rem;
}

/* Budget Input */
.input-budget {
    width: 100%;
    max-width: 300px;
    padding: 0.55rem 0.75rem;
    border: 1.5px solid #c0c0c0;
    border-radius: 6px;
    font-size: 0.95rem;
    background: #fff;
    color: #2c2c2c;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-budget:focus {
    outline: none;
    border-color: #999;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.04);
}
.input-budget::placeholder { color: #bbb; }

/* Radio Group — School Level */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.radio-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1.2rem;
    border: 1.5px solid #c0c0c0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.15s;
    user-select: none;
    background: #fff;
}
.radio-item input { display: none; }
.radio-item:hover {
    border-color: #999;
    background: #f7f7f3;
}
.radio-item:has(input:checked) {
    background: #2c2c2c;
    color: #fff;
    border-color: #2c2c2c;
}

/* Tag Group — Checkboxes */
.tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}
.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.8rem;
    border: 1.5px solid #d0d0d0;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s;
    user-select: none;
    background: #fff;
}
.tag-item input { display: none; }
.tag-item:hover { border-color: #999; }
.tag-item:has(input:checked) {
    background: #5BA8A0;
    color: #fff;
    border-color: #5BA8A0;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.55rem 1.3rem;
    border: 1.5px solid #2c2c2c;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    background: #F5D76E;
    color: #2c2c2c;
    text-align: center;
}
.btn:hover {
    box-shadow: 1px 2px 4px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}
.btn:active {
    box-shadow: none;
    transform: translateY(0);
}

.btn-primary {
    background: #E8726A;
    color: #fff;
    border-color: #E8726A;
    font-size: 1.05rem;
    padding: 0.6rem 1.8rem;
}
.btn-primary:hover {
    background: #d9645c;
    border-color: #d9645c;
}

.btn-secondary {
    background: #fff;
    border-color: #c0c0c0;
    color: #555;
}
.btn-secondary:hover {
    background: #f7f7f3;
    border-color: #999;
}

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}

/* --- Error --- */
.error {
    color: #E8726A;
    margin-top: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.5rem 0.8rem;
    border: 1.5px dashed #e8a8a4;
    border-radius: 6px;
    background: rgba(232,114,106,0.05);
}

/* --- Result Page --- */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.result-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

/* Budget Bar */
.budget-bar {
    background: #fff;
    border: 1.5px solid #d0d0d0;
    border-radius: 8px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.5rem;
}
.budget-bar-inner {
    height: 10px;
    background: #f0f0ec;
    border-radius: 5px;
    margin-top: 0.5rem;
    overflow: hidden;
}
.budget-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #5BA8A0, #F5D76E, #E8726A);
    border-radius: 5px;
    transition: width 0.4s ease;
}
.budget-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: #888;
}
.budget-info strong {
    color: #2c2c2c;
}

/* Sort Toggle */
.view-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.sort-toggle {
    display: flex;
    gap: 0;
    border: 1.5px solid #d0d0d0;
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
}
.view-toggle {
    display: flex;
    gap: 0;
    border: 1.5px solid #d0d0d0;
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
}
.sort-btn, .view-btn {
    padding: 0.4rem 0.9rem;
    border: none;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: #888;
    transition: all 0.15s;
}
.sort-btn + .sort-btn, .view-btn + .view-btn { border-left: 1px solid #d0d0d0; }
.sort-btn.active, .view-btn.active {
    background: #2c2c2c;
    color: #F5D76E;
}

/* Book table view */
.book-table-wrap {
    overflow-x: auto;
    border: 1.5px solid #d0d0d0;
    border-radius: 8px;
    background: #fff;
}

/* --- Book Cards --- */
.book-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.8rem;
}

.book-card {
    background: #fff;
    border: 1.5px solid #d0d0d0;
    border-radius: 8px;
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.4rem;
    transition: box-shadow 0.15s, transform 0.15s;
}
.book-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

.book-info { flex: 1; min-width: 0; }
.book-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.15rem;
    color: #2c2c2c;
    line-height: 1.3;
}
.book-meta {
    font-size: 0.85rem;
    color: #888;
}
.book-meta span { margin-right: 0.5rem; }
.book-source {
    font-size: 0.82rem;
    color: #aaa;
    margin-top: 0.15rem;
}
.book-price {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    color: #E8726A;
}
.book-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px dashed #e0e0dc;
}

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 100;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
    background: #fff;
    border-radius: 10px;
    padding: 1.5rem;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
.modal h2 {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
}
.modal-close {
    float: right;
    background: none;
    border: 1.5px solid #d0d0d0;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    cursor: pointer;
    color: #888;
    font-family: inherit;
    transition: all 0.15s;
}
.modal-close:hover {
    background: #2c2c2c;
    color: #fff;
    border-color: #2c2c2c;
}

/* Replace List */
.replace-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.replace-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid #d0d0d0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
}
.replace-item:hover {
    background: #FAFAF5;
    border-color: #999;
}
.replace-item strong {
    font-size: 0.95rem;
}

/* --- Count badge --- */
.count-badge {
    display: inline-block;
    background: #5BA8A0;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.1rem 0.5rem;
    border-radius: 6px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #aaa;
    font-size: 1rem;
}

/* --- Print Styles --- */
@media print {
    .nav, .result-actions, .book-actions, .sort-toggle, .budget-bar-inner, .modal-overlay { display: none !important; }
    body { background: #fff; }
    .container { max-width: 100%; margin: 0; padding: 0; }
    .book-card {
        border: 1px solid #ccc;
        break-inside: avoid;
        box-shadow: none;
    }
    .book-list { display: block; }
    .budget-bar { border: 1px solid #ccc; box-shadow: none; }
    h1 { font-size: 1.2rem; }
}

/* --- Upload Zone --- */
.upload-zone {
    border: 2px dashed #d0d0d0;
    border-radius: 8px;
    padding: 1.2rem 1rem;
    background: #fff;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover {
    border-color: #999;
    background: #FAFAF5;
}
.upload-zone.dragover {
    border-color: #5BA8A0;
    background: #f0f9f8;
}
.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #888;
    font-size: 0.92rem;
}
.upload-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #2c2c2c;
}
.upload-info .btn-sm {
    padding: 0.1rem 0.4rem;
    font-size: 0.85rem;
    line-height: 1;
}
.owned-badge {
    display: inline-block;
    font-size: 0.85rem;
    color: #5BA8A0;
    font-weight: 500;
}
.owned-badge strong {
    color: #2c2c2c;
}

.owned-exclude-badge {
    display: inline-block;
    background: #F5D76E;
    color: #2c2c2c;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 6px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

/* --- Admin --- */
.admin-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}
.admin-select {
    font-family: inherit;
    padding: 0.4rem 0.6rem;
    border: 1.5px solid #c0c0c0;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
    color: #2c2c2c;
    cursor: pointer;
}
.admin-select:focus { outline: none; border-color: #999; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.admin-table th {
    text-align: left;
    padding: 0.5rem 0.5rem;
    border-bottom: 2px solid #2c2c2c;
    font-weight: 600;
    font-size: 0.82rem;
    color: #888;
    white-space: nowrap;
}
.admin-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid #e8e8e4;
    vertical-align: top;
}
.admin-table td strong {
    font-weight: 600;
    color: #2c2c2c;
}
.admin-table .text-right { text-align: right; }

.source-type-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    color: #fff;
}
.source-type-file  { background: #7B9EA8; }
.source-type-board { background: #A08BB5; }
.source-type-html  { background: #8BA87B; }

/* --- Institution Cards --- */
.institution-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.institution-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}
.institution-card-compact {
    background: #fff;
    border: 1.5px solid #d0d0d0;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    transition: all 0.15s;
}
.institution-card-link:hover .institution-card-compact {
    border-color: #999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.institution-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.institution-name {
    font-size: 1rem;
    font-weight: 700;
    color: #2c2c2c;
}
.institution-meta {
    display: flex;
    gap: 0.8rem;
    align-items: center;
    margin-top: 0.15rem;
    font-size: 0.85rem;
    color: #666;
}
.selection-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    background: #F5D76E;
    color: #2c2c2c;
}

/* External link */
.ext-link {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.1rem 0.4rem;
    font-size: 0.82rem;
    border-radius: 4px;
    color: #5BA8A0;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.ext-link:hover {
    color: #2c2c2c;
    background: #f0f9f8;
}

/* --- Institution Detail: Session sections --- */
.session-section {
    margin-bottom: 1.5rem;
}
.session-section-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    margin-bottom: 0.3rem;
    border-bottom: 1.5px solid #d0d0d0;
}
.session-section-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #2c2c2c;
}
.session-count {
    font-size: 0.82rem;
    color: #888;
}

/* Inline book table */
.inline-book-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.inline-book-table th {
    text-align: left;
    padding: 0.35rem 0.4rem;
    border-bottom: 1.5px solid #d0d0d0;
    font-weight: 600;
    font-size: 0.78rem;
    color: #888;
    white-space: nowrap;
}
.inline-book-table td {
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid #e8e8e4;
    vertical-align: top;
}
.inline-book-table td strong {
    font-weight: 600;
    color: #2c2c2c;
}
.empty-inline {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    color: #aaa;
}

/* Level badges */
.level-badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    color: #fff;
}
.level-초등 { background: #5BA8A0; }
.level-중등 { background: #7B9EA8; }
.level-고등 { background: #A08BB5; }

.area-badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    background: #F5D76E;
    color: #2c2c2c;
    margin-right: 0.25rem;
    white-space: nowrap;
}

/* Tier badges */
.tier-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    margin-right: 0.25rem;
    white-space: nowrap;
}
.tier-1 { background: #D4A843; color: #fff; }
.tier-2 { background: #5B8DB8; color: #fff; }
.tier-3 { background: #6BAF7A; color: #fff; }

/* --- Loading Overlay --- */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f0f0ec;
    border-top: 4px solid #E8726A;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loading-text {
    font-size: 1.05rem;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 0.4rem;
}
.loading-subtext {
    font-size: 0.85rem;
    color: #888;
    line-height: 1.4;
}

/* --- ISBN Page --- */
.isbn-col-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.isbn-col-item {
    flex: 1;
    min-width: 200px;
}
.table-scroll {
    overflow-x: auto;
    border: 1.5px solid #d0d0d0;
    border-radius: 6px;
    background: #fff;
}

/* Pandas dataframe styling */
table.dataframe {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
table.dataframe th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 2px solid #2c2c2c;
    font-weight: 600;
    font-size: 0.82rem;
    color: #888;
    white-space: nowrap;
}
table.dataframe td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid #e8e8e4;
    vertical-align: top;
}

/* --- Guide Page --- */
.guide-steps {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2.5rem;
}
.guide-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: #fff;
    border: 1.5px solid #d0d0d0;
    border-radius: 8px;
    padding: 1rem 1.1rem;
    transition: box-shadow 0.15s;
}
.guide-step:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.step-number {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #5BA8A0;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    border-radius: 50%;
}
.step-content { flex: 1; min-width: 0; }
.step-title {
    font-size: 1rem;
    font-weight: 700;
    color: #2c2c2c;
    margin-bottom: 0.3rem;
}
.step-desc {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
    margin-bottom: 0.15rem;
}
.guide-section {
    margin-bottom: 2rem;
}
.guide-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c2c2c;
    margin-bottom: 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1.5px solid #d0d0d0;
}
.guide-feature {
    background: #fff;
    border: 1.5px solid #d0d0d0;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.6rem;
}
.guide-feature strong {
    display: block;
    font-size: 0.95rem;
    color: #2c2c2c;
    margin-bottom: 0.2rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .container { padding: 0 1rem; }
    h1 { font-size: 1.3rem; }
    .book-list { grid-template-columns: 1fr; }
    .result-header { flex-direction: column; }
    .result-actions { width: 100%; }
    .btn-primary { width: 100%; text-align: center; }
    .admin-table { font-size: 0.8rem; }
}
