/* ==========================================================================
   1. CSS 변수 설정 (Color System) - 통합 관리
   ========================================================================== */
   :root {
    /* [라이트 모드 기본값] */
    --bg-color: #ffffff;
    --text-color: #333333;
    
    /* 네비게이션 (DarkBlue 테마) */
    --nav-bg: #00008B;
    --nav-text: #d3d3d3;
    --nav-border: #000066;
    --nav-hover: #FFD700; /* 선명한 Gold */
    
    /* 링크 & 버튼 */
    --link-color: #007bff;
    --link-hover: #0056b3;
    --btn-bg: #333;
    --btn-text: #fff;
    
    /* 테두리 & 입력창 */
    --border-color: #bbb;
    --input-bg: #ffffff;
    --input-text: #333333;
    --th-bg: #f0f0f0;
    
    /* 기타 UI 요소 */
    --stripe-bg: #f2f2f2;
    --dropdown-bg: #f9f9f9;
    --dropdown-text: #333;
    --dropdown-hover-bg: #f1f1f1;
    --panel-overlay: rgba(255, 255, 255, 0.9);
    --secondary-text: #666;
    
    /* Task & Project 텍스트 */
    --task-title: #6c757d;
    --project-name: #999;

    /* 포인트 컬러 */
    --product-blue: #007bff;
    --danger-color: #d73a49;
    
    /* 호버 배경색 */
    --hover-bg: #e9ecef;
}

/* [다크 모드] - Soft Charcoal (눈이 편한 짙은 회색) */
body.dark-mode {
    /* 배경: 완전 검정(#121212) 대신 부드러운 차콜(#2f343f) */
    --bg-color: #2f343f;
    --text-color: #e0e0e0;
    
    /* 네비게이션: 배경보다 살짝 밝은 톤 */
    --nav-bg: #3f4652;
    --nav-text: #e0e0e0;
    --nav-border: #555555;
    --nav-hover: #FFD700; /* 다크모드에서도 잘 보이는 Gold */
    
    /* 링크 & 버튼: 가독성 높은 밝은 블루/노랑 */
    --link-color: #7aa5d9;
    --link-hover: #ffe082;
    --btn-bg: #4e5766;
    --btn-text: #ffffff;
    
    /* 테두리 & 입력창 */
    --border-color: rgba(255, 255, 255, 0.15);
    --input-bg: #262a33;  /* 입력창은 배경보다 약간 어둡게 */
    --input-text: #e0e0e0;
    --th-bg: #3f4652;
    
    /* 기타 UI 요소 */
    --stripe-bg: #363b47;
    --dropdown-bg: #3f4652;
    --dropdown-text: #e0e0e0;
    --dropdown-hover-bg: #4e5766;
    
    /* 오버레이: 배경색에 맞춰 투명도 조절 */
    --panel-overlay: rgba(47, 52, 63, 0.95);
    
    --secondary-text: #a0a0a0;
    --task-title: #e0e0e0;
    --project-name: #a0a0a0;
    
    /* 포인트 컬러 (톤다운) */
    --product-blue: #7aa5d9;
    --danger-color: #e57373;
    
    /* 호버 배경색 (다크) */
    --hover-bg: #444c56;
}

/* ==========================================================================
   2. 기본 설정 (Reset & Typography)
   ========================================================================== */
body {
    font-family: 'Noto Sans KR', 'Gowun Dodum', Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    font-size: 17px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* 배경 이미지 오버레이 */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--panel-overlay);
    z-index: -1;
    pointer-events: none;
}

/* 링크 스타일 */
a { text-decoration: none; color: var(--text-color); transition: color 0.2s; }
a:hover { color: var(--link-color); }

/* 다크모드 일반 링크 제어 */
body.dark-mode a { color: var(--text-color); } 
body.dark-mode a:hover { color: var(--link-color); }

h2, h3, h4 { margin-top: 0; font-weight: bold; color: var(--text-color); }

/* [수정됨] 기본 컨테이너 너비 97%로 확대 */
.container {
    width: 97%;
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px 0;
}

/* ==========================================================================
   3. 네비게이션 바 (Navigation)
   ========================================================================== */
.navbar {
    height: 43px;
    padding: 0 15px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    
    background-color: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    color: var(--nav-text);
    
    position: sticky;
    top: 0;
    z-index: 1000;
    white-space: nowrap;
}

/* Navbar 링크 및 아이콘 */
.navbar a, 
.navbar .dropdown-toggle {
    color: var(--nav-text) !important;
    text-decoration: none;
    margin-right: 15px; /* 메뉴 간격 15px */
    display: flex;
    align-items: center;
}

.navbar i {
    color: var(--nav-text) !important;
    font-size: 1.3rem; /* 아이콘 크기 */
    padding: 8px 12px; /* 모든 아이콘에 일정한 패딩 적용 */
    border-radius: 12px;
    transition: all 0.2s;
    background: transparent;
}

/* Hover 시 배경 효과 */
.navbar a:hover i,
.navbar .dropdown-toggle:hover i {
    background: rgba(255, 215, 0, 0.15);
    color: #D52122 !important; 
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

#theme-toggle:hover i {
    color: #d52122 !important; 
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

/* 현재 활성화된 페이지 아이콘 스타일 */
.navbar a.active i {
    background: linear-gradient(135deg, rgba(255, 182, 193, 0.3), rgba(255, 192, 203, 0.4));
    box-shadow: 0 2px 8px rgba(255, 182, 193, 0.3);
    color: var(--nav-hover) !important;
}

/* 검색창 (네비게이션 내부) */
.nav-search-form { 
    display: flex; 
    align-items: center; 
    width: 100%; 
    max-width: 400px; 
}

.nav-search-form input {
    flex-grow: 1; 
    height: 34px !important;
    line-height: 34px;
    padding: 0 10px;
    border-radius: 4px 0 0 4px; 
    border: none; 
    background-color: var(--input-bg); 
    color: var(--input-text);
    box-sizing: border-box;
    margin: 0;
}
body.dark-mode .nav-search-form input {
    border: 1px solid var(--border-color);
    border-right: none;
}

.nav-search-form button {
    height: 34px !important;
    width: 40px;
    border-radius: 0 4px 4px 0; 
    border: none;
    background-color: var(--link-color); 
    color: white; 
    cursor: pointer;
    margin: 0;
    display: flex; align-items: center; justify-content: center; padding: 0;
}
body.dark-mode .nav-search-form button { 
    color: #222; font-weight: bold; 
    border: 1px solid var(--border-color); border-left: none;
}

/* 우측 영역 */
.nav-right { gap: 15px; flex-shrink: 0; }
#currentDate { font-size: 14px; color: var(--nav-text); margin-left: 20px; margin-right: 15px; }

/* 다크모드 토글 버튼 */
#theme-toggle {
    background-color: transparent !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    margin: 0;
    display: flex; align-items: center; justify-content: center;
}
#theme-toggle i { margin-right: 0; color: var(--nav-text); }

/* 드롭다운 메뉴 */
.dropdown { position: relative; display: flex; align-items: center; }
.dropdown-menu {
    display: none; position: absolute; top: 100%; right: 0;
    min-width: 160px; z-index: 2000; border-radius: 4px;
    background-color: var(--dropdown-bg);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3); 
    border: 1px solid var(--border-color);
}
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a { 
    display: block; padding: 10px 15px; font-weight: normal; 
    color: var(--dropdown-text) !important;
    margin-right: 0;
}
.dropdown-menu a:hover { 
    background-color: var(--dropdown-hover-bg); 
    color: var(--nav-hover) !important; 
}

/* ==========================================================================
   4. 탭 & 레이아웃 (Tabs & Panels)
   ========================================================================== */
.tabs {
    display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 20px; flex-wrap: wrap;
}
.tab-button {
    padding: 10px 20px; cursor: pointer; background-color: var(--th-bg);
    border: 1px solid var(--border-color); border-bottom: none; margin-right: 4px;
    border-radius: 5px 5px 0 0; font-weight: bold; color: var(--text-color); transition: all 0.2s;
}
.tab-button:hover { background-color: var(--dropdown-hover-bg); }
.tab-button.active {
    background-color: var(--bg-color); border-bottom: 2px solid var(--bg-color);
    color: var(--link-color); margin-bottom: -2px;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

.table-container { display: flex; justify-content: space-between; gap: 20px; margin-top: 10px; }

/* 컬럼(패널) 스타일 */
.column {
    flex: 1; border: 1px solid var(--border-color); 
    position: relative; background-size: cover; background-position: center; 
    background-color: var(--bg-color); min-height: 400px; border-radius: 8px; overflow: hidden;
}
.column::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--panel-overlay); z-index: 0;
}
.column .header {
    position: relative; z-index: 1; background-color: var(--th-bg); padding: 12px; 
    text-align: center; font-weight: bold; border-bottom: 1px solid var(--border-color);
    font-size: 1.1rem; color: var(--text-color);
}
.column .content { position: relative; z-index: 1; padding: 15px; color: var(--text-color); }

/* ==========================================================================
   5. 리스트 & 유틸리티
   ========================================================================== */
.project-list { list-style-type: disc; padding-left: 20px; margin-top: 2px; }
.project-list li { list-style-type: disc; color: var(--text-color); }
.custom-link { font-size: 17px; cursor: pointer; display: block; }
.custom-link:hover { text-decoration: underline; color: var(--link-color); }

.task-list { margin-top: 2px; padding-left: 10px; line-height: 1.6; list-style: none; }
.task-list li::before {
    content: "•"; margin-right: 8px; display: inline-block; font-weight: bold;
    font-size: 1.2em; color: var(--secondary-text); line-height: 1;
}
.task-title-link { text-decoration: none; color: var(--task-title); font-weight: 600; cursor: pointer; margin-right: 5px; transition: color 0.2s; }
.task-title-link:hover { text-decoration: underline; color: var(--link-color); }

.project-name-container { margin-left: 8px; color: var(--project-name); font-size: 0.85em; font-weight: normal; }
.project-name-link { text-decoration: none; color: inherit; }
.project-name-link:hover { text-decoration: underline; color: var(--link-color); }

.materials-ellipsis { display: inline-block; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

/* ==========================================================================
   6. 테이블 스타일 (Tables)
   ========================================================================== */
table {
    width: 100%; border-collapse: collapse !important; table-layout: fixed; 
    margin-bottom: 20px; border: none; 
}

th, td {
    padding: 10px 8px; text-align: left; vertical-align: middle;
    font-size: 0.95rem; color: var(--text-color); 
    border-bottom: 1px solid #d0d0d0; 
    border-top: none; border-left: none; border-right: none;
}

th { 
    background-color: var(--th-bg); font-weight: bold; 
    border-bottom: 1px solid #b0b0b0;
}

body.dark-mode th, body.dark-mode td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
}
body.dark-mode th {
    border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;
}

tbody tr:nth-child(even) { background-color: var(--stripe-bg); }

body:not(.dark-mode) table tr:hover:not(th) { background-color: #E6E6FA !important; transition: background-color 0.2s; }
body.dark-mode tr:hover:not(th) { background-color: rgba(255, 255, 255, 0.05) !important; }

.materials-pin-memo-row { background-color: #ffeb3b !important; color: #333 !important; }
body.dark-mode .materials-pin-memo-row { 
    background-color: #1e2a38 !important; color: #e0e0e0 !important;             
    border-left: 3px solid var(--link-color) !important; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
}

body.dark-mode .memo-content-container[style*="background-color: #E1F5FE"],
body.dark-mode .memo-content-container[style*="background-color: #e1f5fe"] {
    background-color: #1e2a38 !important; border: 1px solid #444c56; color: var(--text-color) !important;
}

body.dark-mode .fa-trash, body.dark-mode .fa-file-pdf, body.dark-mode span[style*="color: #FF4500"], body.dark-mode span[style*="color: red"], body.dark-mode .due-date.past {
    color: var(--danger-color) !important;
}
/* [수정됨] Todo, Materials, Thoughts 테이블 호버 효과 통일 */
#todosTable tbody tr, 
#materials-table tbody tr, 
#thoughts-table tbody tr {
    transition: background-color 0.2s ease;
}

#todosTable tbody tr:hover, 
#materials-table tbody tr:hover, 
#thoughts-table tbody tr:hover {
    background-color: var(--hover-bg) !important;
}

/* 텍스트 링크 스타일 (밑줄 제거, 색상 변경) */
#todosTable a, 
#materials-table a, 
#thoughts-table a { 
    color: inherit !important; 
    text-decoration: none !important; 
}

#todosTable a:hover, 
#materials-table a:hover, 
#thoughts-table a:hover { 
    text-decoration: none !important; 
    color: var(--link-color) !important; 
}

/* ==========================================================================
   7. 폼 & 입력 요소 (Forms & Inputs)
   ========================================================================== */
input[type="text"], input[type="date"], select, textarea {
    width: 100%; padding: 8px; border: 1px solid var(--border-color);
    border-radius: 4px; background-color: var(--input-bg); color: var(--input-text); box-sizing: border-box;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--link-color); }

body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; opacity: 0.6; }

.toggle-switch { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-switch-track { width: 36px; height: 20px; background-color: #ccc; border-radius: 10px; position: relative; transition: 0.3s; }
body.dark-mode .toggle-switch-track { background-color: #555; }
.toggle-switch-thumb { width: 16px; height: 16px; background-color: #fff; border-radius: 50%; position: absolute; top: 2px; left: 2px; transition: 0.3s; }
.toggle-switch.active .toggle-switch-track { background-color: #4CAF50; }
.toggle-switch.active .toggle-switch-thumb { left: 18px; }

.edit-panel {
    position: fixed; top: 0; right: -45%; width: 40%; height: 100%;
    background-color: var(--bg-color); color: var(--text-color);
    box-shadow: -4px 0 10px rgba(0,0,0,0.2); transition: right 0.3s ease-in-out; z-index: 3000; display: flex; flex-direction: column;
    border-left: 1px solid var(--border-color);
}
body.dark-mode .edit-panel { box-shadow: -4px 0 10px rgba(0,0,0,0.5); }

.loading-spinner { width: 24px; height: 24px; border: 3px solid var(--border-color); border-top: 3px solid var(--link-color); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; display: block; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==========================================================================
   8. 통합 버튼 시스템 (Unified Button System)
   ========================================================================== */
/* 버튼 컨테이너 */
.btn-group-right {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border-color);
}

/* 기본 버튼 */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px; font-size: 14px; font-weight: 600;
    border-radius: 4px; border: 1px solid transparent;
    cursor: pointer; text-decoration: none; transition: all 0.2s ease-in-out;
    line-height: 1.5; box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.1); opacity: 0.95; }
.btn:active { transform: translateY(0); box-shadow: none; }

/* 버튼 색상 */
.btn-primary, .btn-save, .btn-search {
    background-color: var(--product-blue); color: white; border-color: var(--product-blue);
}
.btn-primary:hover, .btn-save:hover, .btn-search:hover { background-color: var(--link-hover); color: white; }

.btn-danger, .btn-cancel, .btn-delete, .btn-reset {
    background-color: var(--danger-color); color: white; border-color: var(--danger-color);
}
.btn-danger:hover, .btn-cancel:hover, .btn-delete:hover, .btn-reset:hover { background-color: #b02a37; color: white; }

.btn-secondary, .btn-list {
    background-color: var(--stripe-bg); color: var(--text-color); border-color: var(--border-color);
}
.btn-secondary:hover, .btn-list:hover { background-color: var(--dropdown-hover-bg); }

/* 구버전 버튼 호환용 (유지) */
body.dark-mode .btn-back { background-color: #314a6e !important; }
body.dark-mode .btn-edit { background-color: #238636 !important; }
body.dark-mode .btn-reply { background-color: #8b6d18 !important; }
body.dark-mode .btn-print { background-color: #4a3475 !important; }

/* ==========================================================================
   9. 공통 레이아웃 컴포넌트 (Modern UI)
   ========================================================================== */
/* [수정됨] 메인 컨테이너 97%로 확대 */
.modern-container {
    width: 98%; /* 화면 너비의 97% 사용 */
    
    /* [수정됨] 기존 1200px 제한을 1800px로 대폭 늘림 (혹은 none으로 설정 시 제한 없음) */
    max-width: 1800px; 
    
    margin: 0 auto;
    padding: 30px 10px; /* 좌우 패딩을 조금 줄여서 공간 확보 */
    font-family: 'Noto Sans KR', sans-serif;
    color: var(--text-color);
}

.header-section { margin-bottom: 32px; }
.title {
    font-size: 28px; font-weight: 700; color: var(--text-color);
    margin: 0; display: flex; align-items: center; gap: 12px;
}
.title svg, .title i { color: var(--link-color); }

.form-card {
    background: var(--input-bg); border: 1px solid var(--border-color);
    border-radius: 12px; padding: 28px; margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05); transition: box-shadow 0.2s;
}
.form-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 15px; }
.form-group { margin-bottom: 20px; }
.form-label { display: block; margin-bottom: 8px; font-weight: 500; color: var(--text-color); }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 12px 16px; background-color: var(--bg-color);
    border: 1px solid var(--border-color); border-radius: 8px;
    font-size: 1rem; color: var(--text-color); transition: all 0.2s; box-sizing: border-box;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--link-color); box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.circle-btn {
    width: 32px; height: 32px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background-color: var(--link-color); color: white; cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.circle-btn:hover { transform: scale(1.1); background-color: var(--link-hover); }

.hidden { display: none !important; }

/* ==========================================================================
   10. 모달 (Modal)
   ========================================================================== */
.modal {
    display: none; position: fixed; z-index: 2000; padding-top: 50px;
    left: 0; top: 0; width: 100%; height: 100%; overflow: auto;
    background-color: rgba(0,0,0,0.9);
}
.modal-content {
    margin: auto; display: block; width: 80%; max-width: 800px;
    max-height: 80vh; object-fit: contain;
}
.close {
    position: absolute; top: 15px; right: 35px; color: #f1f1f1;
    font-size: 40px; font-weight: bold; transition: 0.3s; cursor: pointer;
}
.close:hover, .close:focus { color: #bbb; text-decoration: none; cursor: pointer; }

/* ==========================================================================
   11. 모바일 반응형 (Common)
   ========================================================================== */
@media (max-width: 768px) {
    .container { width: 100%; padding: 0; }
    .modern-container { width: 95%; padding: 20px 10px; }
    .form-row { grid-template-columns: 1fr; }
    .modal-content { width: 100%; }
    
    .header-date { display: none; }
    nav { padding: 0 10px; }
    .nav-search-form { max-width: 150px; }
    .tabs { flex-wrap: nowrap; overflow-x: auto; }
    .table-container { flex-direction: column; gap: 20px; }
    .column { width: 100%; }
    table th:nth-child(2), table td:nth-child(2) { display: none; }
    .edit-panel { width: 100%; right: -100%; }
    .navbar a,
    .navbar .dropdown-toggle,
    .navbar i {
        margin-right: 3px; /* 모바일에서 간격 축소 */
    }
    
    /* 검색창이 너무 크면 아이콘이 밀리므로 모바일에서 검색창 너비 조정 */
    .nav-search-form {
        max-width: 120px !important;
    }
}