/**
 * 파일 경로: public/css/style.css
 * 작성/수정 일시: 2026-11-25 11:20 KST
 * 설명: 전역 공통 스타일 (와이드 화면 확장, word-break-keep 유틸, 모바일 카드 뷰, 커스텀 모달/토스트, 인쇄 제어)
 *       Tailwind CSS 초기화로 인해 작아진 section-header h3 글자 크기 및 굵기 명시적 복원 유지
 */

:root {
    --primary-color: #2c3e50;
    --accent-color: #e74c3c;
    --bg-color: #f4f7f6;
    --sidebar-width: 250px;
    --card-shadow: 0 2px 10px rgba(0,0,0,0.05);
    --income-color: #27ae60;
    --expense-color: #e74c3c;
    --border-color: #ddd;
}

* { box-sizing: border-box; }

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: #333;
    line-height: 1.6;
}

.word-break-keep {
    word-break: keep-all;
}

.text-ellipsis-safe {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Layout Structure --- */
.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

/* PC 와이드 해상도를 시원하게 활용하도록 max-width 1600px로 확장 */
.main-container {
    display: flex;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    gap: 20px;
    padding: 20px;
}

/* --- Navigation --- */
nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
}

nav a {
    text-decoration: none;
    color: #555;
    font-weight: 500;
    transition: color 0.2s;
}

nav a:hover {
    color: var(--accent-color);
}

/* --- User Menu --- */
.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
}

.user-menu a {
    text-decoration: none;
    color: #666;
    font-weight: 500;
}

.user-menu a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* --- Sidebar & Main Content Area --- */
aside {
    width: var(--sidebar-width);
    flex-shrink: 0;
}

main {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    padding: 25px;
    min-width: 0;
    overflow-x: hidden;
}

/* --- Ads Slots (Revenue Model 보존) --- */
.ads-slot {
    background: #eee;
    text-align: center;
    border: 1px dashed #ccc;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ads-top {
    width: 100%;
    height: 90px;
    margin-bottom: 20px;
}

.ads-sidebar {
    width: 100%;
    min-height: 200px;
}

.ads-mid {
    width: 100%;
    min-height: 120px;
    height: auto;
}

/* --- Common UI Components --- */
.card { background: #fff; border-radius: 12px; border: 1px solid #eee; padding: 20px; }
.badge { background: #f0f2f5; padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; }
.empty-msg { text-align: center; color: #999; padding: 30px 0; }

/* =========================================
 * 전역 유니버설 에디터(Rich Editor) 본문 높이 제한 및 내부 스크롤 적용
 * ========================================= */
.uni-editor-content {
    min-height: 250px;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: hidden;
}

.uni-editor-content::-webkit-scrollbar { width: 8px; }
.uni-editor-content::-webkit-scrollbar-track { background: #f8fafc; border-radius: 4px; }
.uni-editor-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.uni-editor-content::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 30px; }
.stat-card { background: #fff; padding: 20px; border-radius: 12px; border: 1px solid #eee; display: flex; flex-direction: column; }
.stat-card .label { font-size: 0.9rem; color: #777; margin-bottom: 10px; }
.stat-card .value { font-size: 1.5rem; font-weight: 800; }
.stat-card.income .value { color: var(--income-color); }
.stat-card.expense .value { color: var(--expense-color); }

/* Content Table & Lists */
.content-row { display: grid; grid-template-columns: 1.5fr 1fr; gap: 30px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }

.section-header h3 {
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 0;
    letter-spacing: -0.5px;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th { text-align: left; padding: 12px; border-bottom: 2px solid #f4f7f6; color: #888; }
.data-table td { padding: 12px; border-bottom: 1px solid #f4f7f6; }

.simple-list { list-style: none; padding: 0; margin: 0; }
.simple-list li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f4f7f6; }
.simple-list li a { text-decoration: none; color: #333; }
.simple-list li .date { color: #999; font-size: 0.8rem; }

/* --- Buttons (모바일 터치 타겟 min-height: 45px 보장) --- */
.btn {
    min-height: 45px;
    padding: 10px 22px;
    border-radius: 8px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, background-color 0.2s;
}
.btn:hover { opacity: 0.92; }
.btn-primary { background: var(--accent-color); color: #fff; }
.btn-outline { border: 1.5px solid #cbd5e1; color: #475569; background: transparent; }
.btn-lg { padding: 14px 32px; font-size: 1.1rem; }

/* स्मार्ट 하이라이트 피드백 */
.smart-filled {
    animation: smartPulse 1.5s ease-out;
}
@keyframes smartPulse {
    0% { background-color: #fef9c3; border-color: #facc15; }
    100% { background-color: transparent; }
}

/* --- Toast Notification Styles (Global) --- */
#toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}
.toast-msg {
    background-color: rgba(44, 62, 80, 0.95);
    color: #fff;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    font-size: 0.95rem;
    text-align: center;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
}
.toast-msg.show {
    opacity: 1;
    transform: scale(1);
}

/* --- Global Modal & Alert Overlay (FadeIn + ScaleUp) --- */
.global-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100000;
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.global-overlay.hidden {
    display: none;
}
.global-overlay.show {
    opacity: 1;
    visibility: visible;
}
.custom-modal-box {
    background: #fff;
    padding: 28px;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transform: scale(0.95);
    transition: transform 0.25s ease;
    text-align: center;
}
.global-overlay.show .custom-modal-box { transform: scale(1); }
.custom-modal-msg { font-size: 1.05rem; color: #333; margin-bottom: 24px; word-break: keep-all; }
.custom-modal-actions { display: flex; gap: 10px; justify-content: center; }
.custom-modal-actions .btn { flex: 1; }

/* --- Responsive & Mobile Card View (992px 이하 자동 카드 뷰 전환) --- */
@media (max-width: 992px) {
    .main-container { flex-direction: column; }
    aside { width: 100%; }

    header {
        height: auto;
        flex-wrap: wrap;
        padding: 10px 15px;
        gap: 10px;
    }

    .logo { order: 1; }
    .user-menu { order: 2; margin-left: auto; }

    nav {
        display: block;
        width: 100%;
        order: 3;
        border-top: 1px solid #f5f5f5;
        padding-top: 10px;
        overflow-x: auto;
    }

    nav ul {
        justify-content: flex-start;
        gap: 20px;
        white-space: nowrap;
        padding-bottom: 5px;
    }

    nav a {
        font-size: 0.95rem;
        display: inline-block;
        padding: 5px 0;
    }

    /* 모바일/태블릿 Card View 자동 변환 (992px 기준 통일) */
    .mobile-card-table,
    .mobile-card-table thead,
    .mobile-card-table tbody,
    .mobile-card-table th,
    .mobile-card-table td,
    .mobile-card-table tr {
        display: block;
        width: 100%;
    }
    .mobile-card-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    .mobile-card-table tr {
        margin-bottom: 14px;
        border: 1px solid var(--border-color);
        border-radius: 10px;
        background: #fff;
        padding: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    }
    .mobile-card-table td {
        position: relative;
        padding: 12px 12px 12px 48%;
        text-align: right;
        border-bottom: 1px solid #f4f7f6;
        min-height: 45px;
    }
    .mobile-card-table td:last-child { border-bottom: 0; }
    .mobile-card-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 14px;
        width: 43%;
        padding-right: 10px;
        text-align: left;
        font-weight: 700;
        color: #64748b;
        top: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* 스마트폰 해상도 전용 여백 최소화 */
@media (max-width: 768px) {
    .stats-grid, .content-row { grid-template-columns: 1fr; }
    .logo { font-size: 1.2rem; }

    main { padding: 12px !important; background: transparent !important; box-shadow: none !important; border: none !important; }
    .wrapper { padding: 0 !important; min-height: auto; }
    .main-container { padding: 0 !important; margin: 0 !important; gap: 10px; }
    .card { padding: 15px 12px !important; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); border: 1px solid var(--border-color); }
}

/* =========================================
 * 스마트 가로 스크롤 좌우 화살표 UI
 * ========================================= */
.scroll-nav-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 25px;
}
.scroll-nav-wrapper > .settings-tabs,
.scroll-nav-wrapper > .sch-tabs-container {
    margin-bottom: 0 !important;
}
#pc-nav-menu { margin-bottom: 0 !important; }

.scroll-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.scroll-nav-btn:hover {
    background: #f8fafc;
    color: #3b82f6;
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.scroll-nav-btn.left { left: 0; }
.scroll-nav-btn.right { right: 0; }
.scroll-nav-btn.hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-50%) scale(0.8); }

.notice-viewer-custom.uni-editor-viewer {
    min-height: auto !important;
    background: transparent !important;
    padding: 0 !important;
}

/* =========================================
 * 보고서 인쇄 및 PDF 저장 전용 스타일
 * ========================================= */
@media print {
    header, aside, .ads-slot, .cta-buttons, .export-controls, nav, .hide-on-print,
    a[href^="javascript:history.back"], #mobile-menu-btn, .user-menu, .print\:hidden,
    div[class*="border-dashed"][class*="bg-gray-200"] {
        display: none !important;
    }

    html, body {
        background-color: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
        font-size: 10pt;
        color: #000;
    }

    .wrapper, .main-container, main {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        overflow: visible !important;
    }

    div[class*="md:grid-cols-3"] {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        gap: 15px !important;
        margin-bottom: 20px !important;
    }
    div[class*="md:grid-cols-3"] > div {
        flex: 1 1 0 !important;
        width: 33.33% !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        break-inside: avoid;
        padding: 15px !important;
    }

    .card, .stat-card, .bg-white, .report-card, div[class*="md:grid-cols-3"] > div {
        border: 1px solid #ddd !important;
        border-radius: 6px !important;
        box-shadow: none !important;
        margin-bottom: 20px !important;
        background: transparent !important;
        break-inside: avoid-page;
    }

    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    .hidden.md\:block { display: block !important; }
    .overflow-x-auto { overflow: visible !important; }
    table.data-table { width: 100% !important; border-collapse: collapse !important; margin-bottom: 20px !important; }
    table.data-table th, table.data-table td { padding: 6px !important; }
    canvas { max-width: 220px !important; max-height: 220px !important; margin: 10px auto !important; display: block !important; }

    @page { size: A4 portrait; margin: 1.2cm; }
}