/* 폰트 정의 (공통) */
@font-face {
    font-family: 'GmarketSansBold';
    src: url('fonts/GmarketSansBold.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ==========================================
   웹 화면 전용 스타일 (인쇄 엔진이 읽지 못하게 격리)
   ========================================== */
@media screen {
    :root {
        --primary-color: #2c3e50;
        --accent-color: #3498db;
        --bg-color: #f4f7f9;
        --card-bg: #ffffff;
        --text-main: #333333;
        --text-muted: #7f8c8d;
        --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        --dist-1: #2563eb;
        --dist-2: #7c3aed;
        --dist-3: #db2777;
        --dist-4: #059669;
        --dist-default: #475569;
    }

    body {
        background-color: var(--bg-color);
        color: var(--text-main);
        font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
        margin: 0;
        padding: 0;
    }

    .container {
        max-width: 1440px;
        margin: 0 auto;
        padding: 40px 20px;
    }

    .page-header {
        text-align: center;
        margin-bottom: 50px;
    }

    .page-header h1 {
        font-family: 'GmarketSansBold', sans-serif;
        font-size: 2.5rem;
        color: var(--primary-color);
        margin-bottom: 10px;
    }

    .page-header p {
        color: var(--text-muted);
        font-size: 1.1rem;
    }

    .search-filter-wrapper {
        background: #fff;
        padding: 30px;
        border-radius: 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
        margin-bottom: 40px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .search-container {
        position: relative;
        width: 100%;
        max-width: 600px;
    }

    #filterBox {
        width: 100%;
        padding: 16px 25px 16px 50px;
        font-size: 16px;
        border: 2px solid #edf2f7;
        border-radius: 15px;
        background: #f8fafc;
        transition: var(--transition);
        outline: none;
    }

    #filterBox:focus {
        border-color: var(--accent-color);
        background: #fff;
        box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
    }

    .search-icon {
        position: absolute;
        left: 20px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-muted);
    }

    .filter-chips {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        justify-content: center;
        max-width: 1000px;
    }

    .district-chips {
        margin-top: 15px;
        padding-top: 15px;
        border-top: 1px dashed #e2e8f0;
    }

    .chip {
        padding: 8px 18px;
        background: #f1f5f9;
        border-radius: 50px;
        font-size: 13px;
        color: var(--primary-color);
        cursor: pointer;
        transition: var(--transition);
        border: 1px solid #e2e8f0;
        font-weight: 500;
    }

    .chip:hover {
        background: #e2e8f0;
        border-color: #cbd5e1;
    }

    .chip.active {
        background: var(--accent-color);
        color: #fff;
        border-color: var(--accent-color);
    }

    .chip-separator {
        width: 1px;
        height: 20px;
        background: #e2e8f0;
        margin: auto 10px;
    }

    .btn-print-mode {
        background: #475569;
        color: white;
        border: none;
        padding: 10px 20px;
        border-radius: 10px;
        font-weight: 600;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        transition: all 0.2s ease;
        font-size: 14px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    .btn-print-mode:hover {
        background: #334155;
        transform: translateY(-1px);
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    }

    .clelic-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 30px;
        padding: 20px 0;
    }

    .print-card {
        background: var(--card-bg);
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
        transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
        border: 1px solid rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        position: relative; /* 추가: 개별 제어 버튼 절대 배치용 */
    }

    .print-card:hover {
        transform: translateY(-10px);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    }

    .card-header {
        padding: 15px 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .header-title {
        color: #fff;
        font-family: 'GmarketSansBold', sans-serif;
        font-size: 1.3rem;
        font-weight: 800;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }

    .header-district {
        color: rgba(255, 255, 255, 0.9);
        font-size: 0.8rem;
        font-weight: 600;
        margin-left: 10px;
        white-space: nowrap;
    }

    .card-body {
        padding: 20px;
        display: flex;
        gap: 20px;
        align-items: center;
    }

    .card-photo {
        flex-shrink: 0;
    }

    .image-container {
        width: 100px;
        height: 130px;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
        background: #f1f5f9;
    }

    .image-container img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.6s ease;
    }

    .print-card:hover .image-container img {
        transform: scale(1.1);
    }

    .card-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .name-section {
        margin-bottom: 12px;
    }

    .name-text {
        font-size: 1.6rem;
        font-weight: 800;
        color: var(--primary-color);
        margin-bottom: 2px;
    }

    .bapt-text {
        font-size: 1.1rem;
        color: var(--text-muted);
        font-weight: 600;
    }

    .meta-section {
        display: flex;
        flex-direction: row;
        gap: 20px;
        margin-top: 5px;
    }

    .meta-section.triple {
        gap: 12px;
    }

    .meta-section.triple .meta-label {
        font-size: 11px;
    }

    .meta-section.triple .meta-value {
        font-size: 13px;
    }

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

    .meta-label {
        font-size: 12px;
        color: #94a3b8;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .meta-value {
        font-size: 15px;
        color: var(--text-main);
        font-weight: 700;
    }

    @media (max-width: 768px) {
        .container {
            padding: 20px 15px;
        }

        .page-header h1 {
            font-size: 1.8rem;
        }

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

    /* 카드 편집/숨김 액션 버튼 */
    .card-actions {
        position: absolute;
        right: 12px;
        bottom: 12px;
        display: flex;
        gap: 6px;
        opacity: 0;
        transition: opacity 0.2s ease, transform 0.2s ease;
        transform: translateY(5px);
        z-index: 10;
    }

    .print-card:hover .card-actions {
        opacity: 1;
        transform: translateY(0);
    }

    .btn-card-action {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        border: none;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 14px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .btn-card-action:hover {
        transform: scale(1.15);
        background: #ffffff;
        box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
    }

    .btn-card-action.btn-edit:hover {
        color: #3b82f6;
    }

    .btn-card-action.btn-hide:hover {
        color: #ef4444;
    }

    /* 모달창 스타일 (Glassmorphism & Modern UI) */
    .modal-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(15, 23, 42, 0.6);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 10000;
        animation: fadeIn 0.3s ease-out;
    }

    .modal-content {
        background: rgba(255, 255, 255, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 24px;
        width: 90%;
        max-width: 600px;
        max-height: 90vh;
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .modal-header {
        padding: 20px 24px;
        border-bottom: 1px solid #f1f5f9;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .modal-header h2 {
        margin: 0;
        font-family: 'GmarketSansBold', sans-serif;
        font-size: 1.5rem;
        color: #1e293b;
    }

    .modal-close {
        font-size: 28px;
        font-weight: 500;
        color: #94a3b8;
        cursor: pointer;
        transition: color 0.2s ease;
        line-height: 1;
    }

    .modal-close:hover {
        color: #334155;
    }

    .form-grid {
        padding: 24px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        overflow-y: auto;
    }

    .form-group {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .form-group.full-width {
        grid-column: span 2;
    }

    .form-group label {
        font-size: 13px;
        font-weight: 600;
        color: #64748b;
    }

    .form-group input {
        padding: 10px 14px;
        border: 1px solid #cbd5e1;
        border-radius: 10px;
        font-size: 14px;
        color: #334155;
        transition: all 0.2s ease;
        background: #f8fafc;
    }

    .form-group input:focus {
        outline: none;
        border-color: #3b82f6;
        background: #fff;
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    }

    .modal-footer {
        padding: 16px 24px;
        border-top: 1px solid #f1f5f9;
        background: #f8fafc;
        display: flex;
        justify-content: flex-end;
        gap: 12px;
    }

    .modal-footer button {
        padding: 10px 20px;
        border-radius: 10px;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .btn-cancel {
        border: 1px solid #cbd5e1;
        background: #fff;
        color: #64748b;
    }

    .btn-cancel:hover {
        background: #f1f5f9;
        color: #334155;
    }

    .btn-save {
        border: none;
        background: #3b82f6;
        color: #fff;
    }

    .btn-save:hover {
        background: #2563eb;
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
    }

    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    @keyframes slideUp {
        from { transform: translateY(20px); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }

    @media (max-width: 640px) {
        .form-grid {
            grid-template-columns: 1fr;
        }
        .form-group.full-width {
            grid-column: span 1;
        }
    }
}

/* ==========================================
   인쇄 전용 스타일 (인쇄 시에만 활성화)
   ========================================== */
@media print {
    @page {
        size: landscape;
        margin: 5mm;
    }

    /* 모든 무거운 시각 효과 제거 (색상은 유지) */
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    .page-header,
    .search-filter-wrapper,
    .chip,
    .chip-separator,
    .district-chips,
    .card-actions,
    .modal-backdrop {
        display: none !important;
    }

    body {
        background: #fff !important;
    }

    .container {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .clelic-grid {
        display: block !important;
        width: 27.6cm !important;
        margin: 0 auto !important;
    }

    .print-card {
        display: block;
        float: left;
        width: 9cm;
        height: 6cm;
        margin: 0 !important;
        border: 0.1mm solid #eee;
        border-radius: 12px;
        overflow: hidden;
        background: #fff !important;
        box-sizing: border-box;
        page-break-inside: avoid;
    }

    .card-header {
        height: 1.4cm;
        padding: 0 15px;
        line-height: 1.4cm;
        -webkit-print-color-adjust: exact;
        display: block;
    }

    .header-title {
        font-family: 'GmarketSansBold', sans-serif !important;
        font-weight: bold;
        font-size: 14pt;
        color: #fff !important;
        float: left;
    }

    .header-district {
        font-size: 10pt;
        color: #fff !important;
        float: right;
    }

    .card-body {
        height: 4.6cm;
        padding: 10px 15px;
        display: block;
    }

    /* 사진 비율 유지 (잘라내기 방식) */
    .card-photo {
        float: left !important;
        width: 3.2cm !important;
        height: 4.2cm !important;
        overflow: hidden !important;
        border-radius: 8px;
        position: relative;
    }

    .image-container img {
        height: 100% !important;
        width: auto !important;
        min-width: 100% !important;
        display: block !important;
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }

    .card-info {
        margin-left: 3.5cm !important;
        padding-top: 5px !important;
        display: block !important;
    }

    .name-text {
        font-size: 20pt !important;
        font-weight: 800;
        color: #2c3e50 !important;
        font-family: 'GmarketSansBold', sans-serif !important;
        margin-bottom: 2px;
        display: block;
    }

    .bapt-text {
        font-size: 13pt !important;
        color: #7f8c8d !important;
        font-weight: 700;
        display: block;
    }

    .meta-section {
        margin-top: 10px !important;
        display: table !important;
        width: 100% !important;
        table-layout: fixed;
    }

    .meta-item {
        display: table-cell !important;
        width: 50% !important;
        vertical-align: top;
    }

    .meta-section.triple .meta-item {
        width: 33.3% !important;
    }

    .meta-section:not(.triple) .meta-item-bishop {
        display: none !important;
    }

    .meta-label {
        font-size: 9pt !important;
        color: #94a3b8 !important;
        font-weight: bold;
        display: block;
    }

    .meta-section.triple .meta-label {
        font-size: 8pt !important;
    }

    .meta-value {
        font-size: 11pt !important;
        color: #334155 !important;
        font-weight: 700;
        display: block;
    }

    .meta-section.triple .meta-value {
        font-size: 9pt !important;
    }
}