/* ==========================================================================
   세종시립도서관 스마트 서가 네비게이터 스타일시트
   ========================================================================== */

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary-color: #475569;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Pretendard', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* 1. 상단 헤더 */
.app-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    font-size: 28px;
    background: var(--primary-light);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.app-header .subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.header-badges {
    display: flex;
    gap: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    background: #f1f5f9;
    color: var(--secondary-color);
    border: 1px solid var(--border-color);
}

.badge-floor {
    background: #eff6ff;
    color: var(--primary-color);
    border-color: #bfdbfe;
}

/* 2. 메인 컨테이너 (그리드 레이아웃) */
.main-container {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
    min-height: calc(100vh - 82px);
}

/* 3. 좌측 사이드바 패널 */
.sidebar-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 14px;
    color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* (1) 도서 검색 폼 */
.search-box {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.search-box input {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
    padding: 10px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success-color);
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-success:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f1f5f9;
}

.btn-outline-danger {
    background: transparent;
    border: 1px solid #fca5a5;
    color: var(--danger-color);
}

.btn-outline-danger:hover {
    background: #fef2f2;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

/* 빠른 검색어 태그 */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
}

.tag-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tag-btn {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 3px 8px;
    font-size: 0.75rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s;
}

.tag-btn:hover {
    background: var(--primary-light);
    color: var(--primary-color);
    border-color: #93c5fd;
}

/* 검색 결과 리스트 */
.search-status-bar {
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.book-list-container {
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.book-list-container::-webkit-scrollbar,
.cart-list-container::-webkit-scrollbar {
    width: 6px;
}

.book-list-container::-webkit-scrollbar-thumb,
.cart-list-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.book-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    gap: 12px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.book-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.book-card-img {
    width: 64px;
    height: 90px;
    border-radius: 4px;
    object-fit: cover;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.book-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.book-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.book-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.shelf-tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    color: #ffffff;
}

.status-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: #dcfce7;
    color: #166534;
}

.status-tag.unavailable {
    background: #fee2e2;
    color: #991b1b;
}

.book-card-actions {
    display: flex;
    gap: 6px;
}

/* (2) 대출 바구니 */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.count-badge {
    background: var(--primary-color);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-left: 4px;
}

.cart-list-container {
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 0.82rem;
}

.cart-item-title {
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.cart-item-loc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.cart-item-remove {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
}

.cart-item-remove:hover {
    color: var(--danger-color);
}

.empty-text, .empty-state {
    text-align: center;
    padding: 24px 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* 최적 동선 요약 카드 */
.route-summary-box {
    margin-top: 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-md);
    padding: 14px;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.summary-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e40af;
}

.savings-badge {
    background: #10b981;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 9999px;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: #ffffff;
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    text-align: center;
    border: 1px solid #dbeafe;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-num {
    font-size: 1rem;
    font-weight: 800;
    color: #1e3a8a;
}

.stat-lbl {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.route-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
}

.step-num {
    background: var(--primary-color);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 800;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.step-num.transfer {
    background: #8b5cf6;
}

.step-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.step-shelf {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* 4. 우측 지도 뷰어 패널 */
.map-view-panel {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
}

.map-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.floor-tabs {
    display: flex;
    gap: 8px;
}

.floor-tab {
    padding: 10px 16px;
    border: 1.5px solid var(--border-color);
    background: #f8fafc;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.floor-tab .floor-num {
    font-size: 1rem;
    font-weight: 800;
}

.floor-tab .floor-sub {
    font-size: 0.72rem;
    font-weight: 400;
}

.floor-tab.active {
    background: #ffffff;
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.map-controls {
    display: flex;
    gap: 8px;
}

/* KDC 범례 바 */
.kdc-legend-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 12px;
    font-size: 0.75rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* SVG 지도 영역 */
.map-canvas-wrapper {
    flex: 1;
    background: #1e293b;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    min-height: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #334155;
}

.library-svg {
    width: 100%;
    height: 100%;
    max-height: 600px;
}

/* SVG 요소 스타일 */
.shelf-rect {
    cursor: pointer;
    transition: opacity 0.2s, filter 0.2s;
}

.shelf-rect:hover {
    filter: brightness(1.25) drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
}

.shelf-rect.highlighted {
    animation: pulseGlow 1.5s infinite alternate;
    stroke: #ffffff;
    stroke-width: 2.5px;
}

@keyframes pulseGlow {
    0% { filter: brightness(1.2) drop-shadow(0 0 4px #fbbf24); }
    100% { filter: brightness(1.6) drop-shadow(0 0 12px #f59e0b); }
}

.shelf-label {
    font-size: 10px;
    font-weight: 700;
    fill: #ffffff;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
}

.facility-rect {
    stroke-width: 1;
    stroke: rgba(255, 255, 255, 0.2);
}

.facility-label {
    font-size: 10px;
    font-weight: 700;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
}

/* 경로선 및 마커 */
.route-path-line {
    fill: none;
    stroke: #fbbf24;
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 6, 6;
    animation: dashAnim 1s linear infinite;
}

@keyframes dashAnim {
    to { stroke-dashoffset: -12; }
}

.pin-marker {
    cursor: pointer;
    animation: bounceMarker 1s infinite alternate ease-in-out;
}

@keyframes bounceMarker {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

.step-marker-badge {
    fill: #ef4444;
    stroke: #ffffff;
    stroke-width: 2;
}

.step-marker-text {
    fill: #ffffff;
    font-size: 11px;
    font-weight: 800;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

/* 툴팁 */
.shelf-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    pointer-events: none;
    z-index: 10;
    box-shadow: var(--shadow-lg);
    border: 1px solid #475569;
    max-width: 240px;
}

/* 지도 하단 가이드 */
.map-footer-guide {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.guide-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.pin-dot { background: #ef4444; }
.path-dot { background: #fbbf24; }
.start-dot { background: #8b5cf6; }

/* 모바일 반응형 대응 */
@media (max-width: 1024px) {
    .main-container {
        grid-template-columns: 1fr;
    }
    .map-canvas-wrapper {
        min-height: 400px;
    }
}
