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

:root {
    --primary: #2563EB;
    --primary-light: #3B82F6;
    --primary-lighter: #DBEAFE;
    --primary-dark: #1D4ED8;
    --accent: #059669;
    --accent-light: #D1FAE5;
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --border-light: #F1F5F9;
    --success: #059669;
    --success-bg: #D1FAE5;
    --danger: #DC2626;
    --danger-bg: #FEE2E2;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 10px -2px rgba(0, 0, 0, 0.04);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --transition: 0.2s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.mobile-br {
    display: none;
}

/* ===== Container ===== */
.container {
    max-width: 580px;
    margin: 0 auto;
    padding: 40px 16px;
}

/* ===== Header ===== */
.header {
    text-align: center;
    margin-bottom: 28px;
}

.header h1 {
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
    line-height: 1.3;
}

.header h1 .highlight {
    color: var(--primary);
    position: relative;
}

.header h1 .highlight::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 2px;
    width: 100%;
    height: 6px;
    background: var(--primary-lighter);
    border-radius: 3px;
    z-index: -1;
}

.header-desc {
    font-size: 0.97rem;
    color: var(--text-secondary);
    font-weight: 400;
    line-height: 1.7;
    max-width: 540px;
    margin: 0 auto 16px;
}

.header-desc strong {
    color: var(--text-primary);
    font-weight: 700;
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    border-radius: 3px;
    padding: 0 3px;
}

.header-badges {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ===== Ad Container ===== */
.ad-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.ad-infeed {
    min-height: 120px;
    max-height: 150px;
    padding: 8px 0;
    overflow: hidden;
}

.ad-multiplex {
    margin-top: 24px;
    margin-bottom: 16px;
    min-height: 200px;
}

/* ===== Search Panel ===== */
.search-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.search-tab {
    flex: 1;
    padding: 12px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    outline: none;
}

.search-tab:hover {
    border-color: var(--primary-light);
    color: var(--primary-light);
}

.search-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.search-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.select-group {
    width: 100%;
}

.select-group-btn {
    width: 100%;
}

.select-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.select-group select {
    width: 100%;
    padding: 12px 36px 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 0.93rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    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 d='M6 8L1 3h10z' fill='%2394A3B8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
}

.select-group select:hover {
    border-color: var(--primary-light);
}

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

.select-group select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--border-light);
}

/* ===== Search Button ===== */
.btn-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-xs);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 48px;
    width: 100%;
    justify-content: center;
}

.btn-search:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.btn-search:active:not(:disabled) {
    transform: translateY(0);
}

.btn-search:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Result Toolbar ===== */
.result-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.stats-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-lighter);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: 50px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--primary);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #FFF7ED, #FFEDD5);
    border: 2px solid #FB923C;
    border-radius: 50px;
    animation: filterPulse 2s ease-in-out 3;
}

@keyframes filterPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(251, 146, 60, 0);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(251, 146, 60, 0.25);
    }
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #EA580C;
    white-space: nowrap;
}

.filter-group select {
    padding: 8px 32px 8px 14px;
    background: #FFFFFF;
    border: 1px solid #FDBA74;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    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 d='M6 8L1 3h10z' fill='%23EA580C'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 180px;
}

.filter-group select:hover {
    border-color: #F97316;
    background: #FFFBEB;
}

.filter-group select:focus {
    outline: none;
    border-color: #EA580C;
    box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

/* ===== Loading ===== */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading p {
    color: var(--text-secondary);
    font-size: 0.93rem;
}

/* ===== Error Box ===== */
.error-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: var(--danger-bg);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--radius-xs);
    margin-bottom: 20px;
}

.error-icon {
    font-size: 1.2rem;
}

.error-box p {
    color: var(--danger);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 70px 20px;
}

.empty-icon {
    font-size: 52px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.93rem;
}

/* ===== Result Section ===== */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* ===== Pharmacy Table ===== */
.pharmacy-table {
    width: 100%;
    border-collapse: collapse;
}

.pharmacy-table thead {
    background: var(--primary-lighter);
}

.pharmacy-table th {
    padding: 10px 10px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--primary);
    letter-spacing: 0.3px;
    white-space: nowrap;
    border-bottom: 2px solid rgba(37, 99, 235, 0.15);
}

.pharmacy-table td {
    padding: 10px 10px;
    font-size: 0.85rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.pharmacy-table tbody tr {
    transition: var(--transition);
}

.pharmacy-table tbody tr:hover {
    background: #F0F7FF;
}

.pharmacy-table tbody tr:last-child td {
    border-bottom: none;
}

.th-num {
    display: none;
}

.td-num {
    display: none;
}

.th-name {
    width: 28%;
}

.th-addr {
    width: 46%;
}

.th-tel {
    width: 26%;
    text-align: center;
}

.td-name {
    font-weight: 600;
    color: var(--primary-dark);
}

.td-addr a {
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.td-addr a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.td-addr .map-icon {
    font-size: 0.8em;
    opacity: 0.4;
    transition: var(--transition);
}

.td-addr a:hover .map-icon {
    opacity: 1;
}

.td-tel a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    display: block;
    text-align: center;
}

.td-tel a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.time-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--success-bg);
    border: 1px solid rgba(5, 150, 105, 0.2);
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--success);
    white-space: nowrap;
}

.time-badge-closed {
    background: var(--border-light);
    border-color: var(--border);
    color: var(--text-muted);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    padding: 20px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover:not(.active):not(:disabled) {
    background: var(--primary-lighter);
    border-color: var(--primary-light);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ===== SEO Content ===== */
.seo-content {
    margin-top: 36px;
    padding: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.seo-content h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-align: center;
}

.seo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.seo-card {
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.seo-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.seo-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 24px 20px 20px;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.footer a {
    color: var(--primary);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== Name Wrap & Badge ===== */
.name-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
}

.name-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    word-break: keep-all;
}

.night-badge {
    font-size: 0.9rem;
}

.btn-detail {
    padding: 5px 10px;
    background: #FFFFFF;
    border: 1px solid var(--primary-light);
    color: var(--primary);
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

@keyframes modalScale {
    from {
        transform: scale(0.95) translateY(10px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    background: #F8FAFC;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-info-row {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.info-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
    padding-left: 2px;
}

.info-value a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.info-value a:hover {
    text-decoration: underline;
}

.modal-details {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px dashed var(--border);
}

.modal-details h4 {
    font-size: 0.95rem;
    margin-bottom: 14px;
    color: var(--text-primary);
    font-weight: 700;
}

.time-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.time-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg);
    margin-bottom: 8px;
    border-radius: var(--radius-xs);
    font-size: 0.85rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.day-label {
    font-weight: 600;
}

.time-val {
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: 20px 14px;
    }

    .header h1 {
        font-size: 1.35rem;
        word-break: keep-all;
    }

    .header-desc {
        font-size: 0.85rem;
        margin-bottom: 12px;
        word-break: keep-all;
    }

    .mobile-br {
        display: block;
    }

    .pc-br {
        display: none;
    }

    .header-badges {
        gap: 4px;
        flex-wrap: nowrap;
        width: 100%;
    }

    .badge {
        font-size: 0.7rem;
        padding: 4px 8px;
        white-space: nowrap;
        letter-spacing: -0.5px;
    }

    .search-panel {
        padding: 18px;
    }

    .search-row {
        flex-direction: column;
        gap: 12px;
    }

    .select-group {
        min-width: 100%;
    }

    .select-group-btn {
        min-width: 100%;
    }

    .btn-search {
        width: 100%;
        justify-content: center;
        padding: 14px;
    }

    .result-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group select {
        flex: 1;
        min-width: 0;
    }

    .table-wrapper {
        border-radius: var(--radius-sm);
    }

    .pharmacy-table th,
    .pharmacy-table td {
        padding: 10px 10px;
        font-size: 0.82rem;
    }

    .th-addr,
    .td-addr {
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .empty-state {
        padding: 40px 20px;
    }

    .seo-grid {
        grid-template-columns: 1fr;
    }

    .badge {
        font-size: 0.72rem;
        padding: 4px 10px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.25rem;
    }

    .header-desc {
        font-size: 0.8rem;
    }

    .header-badges {
        gap: 3px;
    }

    .badge {
        font-size: 0.65rem;
        padding: 4px 5px;
    }

    .pharmacy-table th,
    .pharmacy-table td {
        padding: 8px 8px;
        font-size: 0.78rem;
    }
}