/**
 * Juso Search Modal - Common Address Search Styles
 * Theme-independent address search modal for juso.go.kr API
 *
 * Usage:
 *   <link rel="stylesheet" href="/lib/juso-search.css">
 *
 * @package dr-templates-php
 */

/* ==========================================
   CSS Variables (Theme-Independent)
   ========================================== */
:root {
    --juso-primary: #5671c0;
    --juso-primary-hover: #4560a8;
    --juso-primary-bg: #f0f3fa;
    --juso-border: #e5e7eb;
    --juso-border-light: #f0f0f0;
    --juso-text: #1f2937;
    --juso-text-light: #6b7280;
    --juso-text-muted: #9ca3af;
    --juso-bg: #ffffff;
    --juso-bg-gray: #f9fafb;
    --juso-radius: 0.5rem;
    --juso-radius-lg: 0.75rem;
    --juso-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --juso-transition: 0.2s ease;
}

/* ==========================================
   Modal Overlay
   ========================================== */
.juso-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.juso-modal-overlay.juso-modal-active {
    display: flex;
}

/* ==========================================
   Modal Container
   ========================================== */
.juso-modal-container {
    background: var(--juso-bg);
    border-radius: var(--juso-radius-lg);
    box-shadow: var(--juso-shadow);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: jusoModalFadeIn 0.2s ease;
}

@keyframes jusoModalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   Modal Header
   ========================================== */
.juso-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--juso-border);
    flex-shrink: 0;
}

.juso-modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--juso-text);
    margin: 0;
    line-height: 1.4;
}

.juso-modal-header h3 i {
    color: var(--juso-primary);
    margin-right: 0.5rem;
}

.juso-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--juso-text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--juso-radius);
    transition: background var(--juso-transition), color var(--juso-transition);
    flex-shrink: 0;
}

.juso-modal-close:hover {
    color: var(--juso-text);
    background: var(--juso-bg-gray);
}

/* ==========================================
   Modal Body
   ========================================== */
.juso-modal-body {
    padding: 1rem 1.25rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* ==========================================
   Search Form
   ========================================== */
.juso-search-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.juso-search-input {
    flex: 1;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--juso-border);
    border-radius: var(--juso-radius);
    font-size: 0.875rem;
    color: var(--juso-text);
    background: var(--juso-bg);
    outline: none;
    transition: border-color var(--juso-transition);
    font-family: inherit;
}

.juso-search-input:focus {
    border-color: var(--juso-primary);
}

.juso-search-input::placeholder {
    color: var(--juso-text-muted);
}

.juso-search-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.625rem 1rem;
    background: var(--juso-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--juso-radius);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: background var(--juso-transition);
    font-family: inherit;
}

.juso-search-btn:hover {
    background: var(--juso-primary-hover);
}

.juso-search-btn i {
    font-size: 0.75rem;
}

/* ==========================================
   Search Tip
   ========================================== */
.juso-search-tip {
    font-size: 0.8125rem;
    color: var(--juso-text-light);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.juso-search-tip i {
    color: var(--juso-text-muted);
    margin-right: 0.25rem;
}

/* ==========================================
   Search Results
   ========================================== */
.juso-results {
    max-height: 20rem;
    overflow-y: auto;
}

.juso-results::-webkit-scrollbar {
    width: 6px;
}

.juso-results::-webkit-scrollbar-track {
    background: transparent;
}

.juso-results::-webkit-scrollbar-thumb {
    background: var(--juso-border);
    border-radius: 3px;
}

.juso-results::-webkit-scrollbar-thumb:hover {
    background: var(--juso-text-muted);
}

/* ==========================================
   Result Item
   ========================================== */
.juso-item {
    display: flex;
    flex-direction: column;
    gap: 0.1875rem;
    padding: 0.75rem;
    border: 1px solid var(--juso-border);
    border-radius: var(--juso-radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background var(--juso-transition), border-color var(--juso-transition);
    background: var(--juso-bg);
}

.juso-item:last-child {
    margin-bottom: 0;
}

.juso-item:hover {
    background: var(--juso-primary-bg);
    border-color: var(--juso-primary);
}

.juso-zip {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--juso-primary);
    line-height: 1.4;
}

.juso-road {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--juso-text);
    line-height: 1.4;
}

.juso-jibun {
    font-size: 0.75rem;
    color: var(--juso-text-muted);
    line-height: 1.4;
}

/* ==========================================
   Empty State
   ========================================== */
.juso-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--juso-text-muted);
    font-size: 0.875rem;
    line-height: 1.6;
}

.juso-empty i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--juso-border);
}

/* ==========================================
   Loading State
   ========================================== */
.juso-loading {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--juso-text-muted);
    font-size: 0.875rem;
}

.juso-loading i {
    margin-right: 0.375rem;
}

/* ==========================================
   More Button (Load More / Pagination)
   ========================================== */
.juso-more {
    text-align: center;
    padding: 0.625rem;
    color: var(--juso-primary);
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    border: 1px dashed var(--juso-border);
    border-radius: var(--juso-radius);
    transition: background var(--juso-transition), border-color var(--juso-transition);
    margin-top: 0.5rem;
    background: none;
    width: 100%;
    font-family: inherit;
}

.juso-more:hover {
    background: var(--juso-primary-bg);
    border-color: var(--juso-primary);
}

.juso-more i {
    margin-right: 0.25rem;
}

/* ==========================================
   Responsive: Mobile (360px~767px)
   ========================================== */
@media (max-width: 767px) {
    .juso-modal-container {
        max-width: 100%;
    }

    .juso-modal-header {
        padding: 0.875rem 1rem;
    }

    .juso-modal-body {
        padding: 0.875rem 1rem;
    }

    .juso-search-input {
        font-size: 1rem;
    }

    .juso-item {
        padding: 0.625rem;
    }
}

/* ==========================================
   Responsive: Small Mobile (~480px)
   ========================================== */
@media (max-width: 480px) {
    .juso-modal-container {
        max-height: 90vh;
    }

    .juso-search-form {
        flex-direction: column;
    }

    .juso-search-btn {
        padding: 0.625rem;
        justify-content: center;
    }

    .juso-modal-header h3 {
        font-size: 0.9375rem;
    }
}

/* ==========================================
   Responsive: Fold/Flip (~359px)
   ========================================== */
@media (max-width: 359px) {
    .juso-modal-overlay {
        padding: 0.5rem;
    }

    .juso-modal-header {
        padding: 0.75rem;
    }

    .juso-modal-body {
        padding: 0.75rem;
    }

    .juso-modal-header h3 {
        font-size: 0.875rem;
    }

    .juso-search-input {
        padding: 0.5rem 0.75rem;
    }

    .juso-item {
        padding: 0.5rem;
    }

    .juso-road {
        font-size: 0.8125rem;
    }
}

/* ==========================================
   Responsive: FHD (1920px~2559px)
   ========================================== */
@media (min-width: 1920px) and (max-width: 2559px) {
    .juso-modal-container {
        max-width: 560px;
    }

    .juso-modal-header h3 {
        font-size: 1.0625rem;
    }

    .juso-search-input {
        font-size: 0.9375rem;
        padding: 0.6875rem 1rem;
    }

    .juso-road {
        font-size: 0.9375rem;
    }
}

/* ==========================================
   Responsive: QHD (2560px~3839px)
   ========================================== */
@media (min-width: 2560px) and (max-width: 3839px) {
    .juso-modal-container {
        max-width: 600px;
    }

    .juso-modal-header {
        padding: 1.125rem 1.5rem;
    }

    .juso-modal-header h3 {
        font-size: 1.125rem;
    }

    .juso-modal-body {
        padding: 1.125rem 1.5rem;
    }

    .juso-search-input {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }

    .juso-search-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
    }

    .juso-item {
        padding: 0.875rem;
    }

    .juso-road {
        font-size: 0.9375rem;
    }
}

/* ==========================================
   Responsive: UHD (3840px+)
   ========================================== */
@media (min-width: 3840px) {
    .juso-modal-container {
        max-width: 680px;
    }

    .juso-modal-header {
        padding: 1.25rem 1.75rem;
    }

    .juso-modal-header h3 {
        font-size: 1.25rem;
    }

    .juso-modal-body {
        padding: 1.25rem 1.75rem;
    }

    .juso-search-input {
        font-size: 1.0625rem;
        padding: 0.875rem 1.125rem;
    }

    .juso-search-btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.9375rem;
    }

    .juso-item {
        padding: 1rem;
        margin-bottom: 0.625rem;
    }

    .juso-road {
        font-size: 1rem;
    }

    .juso-zip {
        font-size: 0.8125rem;
    }

    .juso-jibun {
        font-size: 0.8125rem;
    }

    .juso-results {
        max-height: 24rem;
    }
}

/* ==========================================
   다음 우편번호 서비스(키 없는 검색) 모드
   ========================================== */
.juso-modal-overlay.juso-daum-mode .juso-search-form,
.juso-modal-overlay.juso-daum-mode .juso-search-tip,
.juso-modal-overlay.juso-daum-mode .juso-results {
    display: none;
}

.juso-daum-layer {
    display: none;
    width: 100%;
    height: 460px;
    overflow: hidden;
}

.juso-modal-overlay.juso-daum-mode .juso-daum-layer {
    display: block;
}
