/* 1. 기본 설정 및 높이 변수 (높이 조절 관리자) */
:root {
    --primary: #2563eb;
    --bg: #f8fafc;
    --border-light: #f1f5f9;
    --border-dark: #e2e8f0;
    --text-main: #1e293b;
    --text-sub: #64748b;

    /* [설정] 화면용 높이 */
    --row-height-screen: 28px;
    
    /* [설정] 인쇄용 높이 (모바일/PC 공통 조절점) */
    --row-height-print: 7mm; 
    --header-height-print: 7mm;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body { 
    margin: 0; 
    font-family: 'Pretendard', sans-serif; 
    background: var(--bg); 
    color: var(--text-main);
    overflow-x: hidden; 
}

/* 2. 상단 바 (App Bar) */
.app-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    height: 60px;
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.app-bar h1 {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    pointer-events: none;
    white-space: nowrap;
}

.date-info { font-size: 0.75rem; opacity: 0.9; min-width: 50px; z-index: 1; }

.round-add-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 5;
    margin-left: auto;
    margin-right: 10px;
    transition: background 0.2s;
}

.icon-btn { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; padding: 8px; z-index: 2; }

/* 사이드 메뉴 (Drawer) */
.drawer { position: fixed; inset: 0; z-index: 1000; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.drawer-content { 
    position: absolute; right: 0; top: 0; bottom: 0; width: 250px; 
    background: white; padding: 24px; display: flex; flex-direction: column; gap: 12px;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
}
.drawer-content h3 { margin-top: 0; border-bottom: 1px solid var(--border-dark); padding-bottom: 10px; }
.drawer-content button { padding: 12px; text-align: left; border: none; background: #f1f5f9; border-radius: 8px; font-weight: bold; cursor: pointer; }

/* 3. 시간표 그리드 */
.grid-wrapper {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    background: white;
    border-bottom: 1px solid #ddd;
}

.grid-header { 
    background: #1e293b; color: white; text-align: center; font-size: 0.8rem; 
    position: sticky; top: 60px; z-index: 10; display: flex; align-items: center; justify-content: center;
}

.grid-time-label, .grid-cell { 
    height: var(--row-height-screen); 
    display: flex; align-items: center; justify-content: center; text-align: center;
}

.grid-time-label { 
    background: #f1f5f9; color: black; font-size: 0.7rem; 
    border-bottom: 1px solid var(--border-dark); border-right: 1px solid var(--border-dark); 
}

.grid-cell { font-size: 0.75rem; border-bottom: 1px solid var(--border-light); border-right: 1px solid var(--border-light); overflow: hidden; }

.occupied { font-weight: bold; color: #1e3a8a; -webkit-print-color-adjust: exact; }

/* 4. 모달 및 명언 카드 (일정 추가 모달 스타일 병합) */
.modal { 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.5); 
    z-index: 1100; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

.modal-content { 
    background: white; 
    padding: 20px; 
    border-radius: 16px; 
    width: 90%; 
    max-width: 400px; 
}

.quote-card { text-align: center; padding: 40px 20px !important; }
.quote-icon { font-size: 40px; margin-bottom: 20px; }
.quote-text { font-size: 1.2rem; font-weight: bold; color: var(--text-main); margin-bottom: 10px; line-height: 1.4; }
.quote-author { font-size: 0.9rem; color: var(--text-sub); margin-bottom: 30px; }

/* 일정 추가 모달 전용 폼 스타일 */
.subject-chips { 
    display: flex; 
    gap: 8px; 
    margin-bottom: 12px; 
    flex-wrap: wrap; 
}

.chip { 
    padding: 8px 16px; 
    border-radius: 20px; 
    border: 1px solid var(--border-dark); 
    background: white; 
    font-size: 0.9rem; 
    cursor: pointer; 
    transition: all 0.2s ease; 
}

.chip.active { 
    background: var(--primary); 
    color: white; 
    border-color: var(--primary); 
    font-weight: bold; 
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.form-group { 
    margin-bottom: 16px; 
    display: flex; 
    flex-direction: column; 
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-sub);
}

input, select { 
    padding: 10px; 
    border: 1px solid #ddd; 
    border-radius: 8px; 
    font-size: 1rem; 
}

/* 5. 버튼 공통 시스템 */
.modal-buttons { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    margin-top: 15px; 
}

.primary, .secondary, .danger, .primary-full { 
    padding: 12px; 
    border-radius: 8px; 
    border: none; 
    font-weight: 600; 
    cursor: pointer; 
    width: 100%; 
}

.primary, .primary-full { background: var(--primary); color: white; }
.secondary { 
    background: #e2e8f0; 
    color: #475569; 
    transition: background 0.2s;
}
.secondary:hover { background: #cbd5e1; }
.danger { background: #ef4444; color: white; }

/* 6. 푸터 */
.app-footer { background: #ffffff; border-top: 1px solid var(--border-dark); padding: 20px 0; text-align: center; width: 100%; }
.footer-content p { font-size: 0.85rem; color: var(--text-sub); margin: 0; }
.footer-content strong { color: var(--primary); }

.hidden { display: none !important; }
.print-only { display: none; }

/* 8. 인쇄 최적화 (모바일/PC 공통) */
@media print {
    * { 
        -webkit-print-color-adjust: exact !important; 
        print-color-adjust: exact !important; 
        color-adjust: exact !important; 
        -webkit-text-size-adjust: none !important;
    }

    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    body { background: white; width: 100% !important; margin: 0; padding: 0; }
    .no-print, .drawer, .modal, .round-add-btn, .icon-btn, .fab { display: none !important; }
    
    .print-only { display: block !important; text-align: center; margin-bottom: 10px; }
    .print-title h1 { font-size: 24pt; border-bottom: 2pt solid var(--primary); display: inline-block; padding-bottom: 5px; }
    
    .grid-wrapper {
        display: grid !important;
        grid-template-columns: 15mm repeat(7, 1fr) !important;
        border: 1pt solid #cbd5e1 !important;
        width: 100% !important;
    }
    
    .grid-header {
        height: var(--header-height-print) !important;
        background: #1e293b !important; 
        color: white !important; 
        font-size: 10pt !important;
        display: flex !important; 
        align-items: center !important; 
        justify-content: center !important;
    }

    .grid-time-label, .grid-cell { 
        height: var(--row-height-print) !important; 
        min-height: var(--row-height-print) !important;
        max-height: var(--row-height-print) !important;
        display: flex !important; 
        align-items: center !important; 
        justify-content: center !important;
        border-bottom: 0.5pt solid #e2e8f0 !important;
        border-right: 0.5pt solid #e2e8f0 !important;
        box-sizing: border-box !important;
        page-break-inside: avoid;
    }

    .grid-time-label { background: #f8fafc !important; color: #475569 !important; font-size: 8pt !important; }
    
    .occupied {
        font-size: 8pt !important;
        line-height: 1 !important;
        white-space: nowrap;
    }
    
    .app-footer {
        display: block !important;
        position: relative;
        margin-top: 15mm;
        border-top: 0.5pt solid #cbd5e1 !important;
    }
}