/* ==============================================
   길드랭크 페이지 전용 스타일
   ============================================== */

/* ==============================================
   1. 기본 레이아웃
   ============================================== */
.collapsible-content {
    width: 500px;
}

/* 메인 테이블 좌우 배치 */
.main-tables-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.left-panel {
    flex: 0 0 350px; /* 고정 너비 350px */
    min-width: 350px;
}

.right-panel {
    flex: 1; /* 나머지 공간 차지 */
    min-width: 700px; /* 최소 너비 보장 */
    overflow-x: auto;
}

.panel-header {
    margin-bottom: 10px;
}

.panel-header h3 {
    margin-bottom: 5px;
    color: #495057;
    font-size: 1.1em;
}

.panel-header p {
    margin-bottom: 0;
    font-size: 0.8em;
}

/* 반응형 디자인 - 작은 화면에서는 세로 배치 */
@media (max-width: 1200px) {
    .main-tables-container {
        flex-direction: column;
    }
    
    .left-panel {
        flex: none;
        width: 100%;
        min-width: auto;
    }
    
    .right-panel {
        flex: none;
        width: 100%;
        min-width: auto;
    }
}

/* ==============================================
   2. 접기/펼치기 기능
   ============================================== */
.collapsible-header {
    cursor: pointer;
    padding: 10px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 15px;
    transition: background-color 0.3s ease;
}

.collapsible-header:hover {
    background-color: #e9ecef;
}

.collapsible-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
}

.collapsible-header i {
    margin-right: 10px;
    transition: transform 0.3s ease;
}

.collapsible-header.collapsed i {
    transform: rotate(-90deg);
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0;
    margin-bottom: 0;
}

/* ==============================================
   3. 공통 테이블 스타일
   ============================================== */
.guild-table, .guild-battle-grid {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.guild-table table, .guild-battle-grid table {
    margin-bottom: 0;
    table-layout: fixed;
    width: 100%;
}

.guild-table th, .guild-battle-grid th {
    background-color: #343a40;
    color: white;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    border: none;
    padding: 8px 4px;
    font-size: 0.9em;
}

.guild-table td, .guild-battle-grid td {
    text-align: center;
    vertical-align: middle;
    padding: 6px 4px;
    border: 1px solid #dee2e6;
    font-size: 0.9em;
}

/* ==============================================
   4. 멤버 테이블 (간단)
   ============================================== */
.guild-table .number-col { width: 35px; }
.guild-table .nickname-col { min-width: 150px; }
.guild-table .nickname-col-wide { min-width: 180px; }
.guild-table .stats-col { 
    width: 40px; 
    text-align: center;
    font-weight: bold;
}
.guild-table .stats-col-narrow { 
    width: 25px; 
    text-align: center;
    font-weight: bold;
    font-size: 0.85em;
}

/* 멤버 통계 컬럼 색상 */
.member-wins { color: #28a745; }
.member-losses { color: #dc3545; }
.member-total { color: #6c757d; }

/* ==============================================
   5. 전투 그리드 (핵심)
   ============================================== */
.guild-battle-grid {
    overflow-x: auto;
}

.guild-battle-grid table {
    min-width: 1200px;
    font-size: 14px;
    border-collapse: separate;
    border-spacing: 0;
}

/* 헤더 색상 */
.day-header { background-color: #007bff !important; }
.stats-header { background-color: #6f42c1 !important; }
.sub-header th { background-color: #6c757d; padding: 4px 2px; font-size: 0.8em; }

/* 통계 컬럼 색상 */
.sub-col.stats-win { background-color: #28a745 !important; }
.sub-col.stats-lose { background-color: #dc3545 !important; }
.sub-col.stats-total { background-color: #007bff !important; }

/* ==============================================
   6. 컬럼 너비 통합 설정 (핵심!)
   ============================================== */
/* 판수 컬럼 */
.round-col, 
#battleGrid col:nth-child(1), 
#battleGrid th:nth-child(1), 
#battleGrid td:nth-child(1) {
    width: 45px !important;
    background-color: #343a40 !important;
    color: white;
    font-size: 0.85em;
}

/* 닉네임 컬럼 (2,4,6,8,10,12,14) */
.nickname-cell,
#battleGrid col:nth-child(2), #battleGrid col:nth-child(4), #battleGrid col:nth-child(6),
#battleGrid col:nth-child(8), #battleGrid col:nth-child(10), #battleGrid col:nth-child(12), #battleGrid col:nth-child(14),
#battleGrid th:nth-child(2n):not(:first-child):not(:nth-child(16)):not(:nth-child(17)):not(:nth-child(18)),
#battleGrid td:nth-child(2n):not(:first-child):not(:nth-child(16)):not(:nth-child(17)):not(:nth-child(18)) {
    width: 90px !important;
}

/* 승패 + 통계 컬럼 (3,5,7,9,11,13,15,16,17,18) */
.result-cell, .stats-cell,
#battleGrid col:nth-child(3), #battleGrid col:nth-child(5), #battleGrid col:nth-child(7),
#battleGrid col:nth-child(9), #battleGrid col:nth-child(11), #battleGrid col:nth-child(13),
#battleGrid col:nth-child(15), #battleGrid col:nth-child(16), #battleGrid col:nth-child(17), #battleGrid col:nth-child(18),
#battleGrid th:nth-child(2n+1):not(:first-child), #battleGrid th:nth-child(16), #battleGrid th:nth-child(17), #battleGrid th:nth-child(18),
#battleGrid td:nth-child(2n+1):not(:first-child), #battleGrid td:nth-child(16), #battleGrid td:nth-child(17), #battleGrid td:nth-child(18) {
    width: 30px !important;
}

/* ==============================================
   7. 편집 가능한 셀
   ============================================== */
.editable-cell, .editable-battle-cell {
    cursor: text;
    padding: 4px 3px;
    background-color: #f8f9fa;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    outline: none;
    font-size: 0.9em;
}

.editable-cell:hover, .editable-battle-cell:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.editable-cell:focus, .editable-battle-cell:focus {
    background-color: white;
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.editable-battle-cell.error {
    background-color: #f8d7da !important;
    color: #721c24 !important;
    border-color: #f5c6cb !important;
}

/* 승패 결과 배경색 */
.result-win {
    background-color: #28a745 !important;
    color: white !important;
    font-weight: bold;
}

.result-lose {
    background-color: #dc3545 !important;
    color: white !important;
    font-weight: bold;
}

/* ==============================================
   8. 자동완성 드롭다운
   ============================================== */
.autocomplete-dropdown {
    position: absolute;
    background: white;
    border: 1px solid #ced4da;
    border-radius: 4px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.autocomplete-item:hover, .autocomplete-item.highlighted {
    background-color: #007bff;
    color: white;
}

/* ==============================================
   9. 버튼 스타일
   ============================================== */
.action-buttons {
    text-align: center;
    margin: 1rem 0;
}

.btn-add-row { 
    background-color: #28a745; 
    margin-right: 8px; 
    padding: 6px 12px;
    font-size: 0.9em;
}
.btn-remove-row { 
    background-color: #dc3545; 
    margin-right: 8px;
    padding: 6px 12px;
    font-size: 0.9em;
}
.btn-calculate { 
    background-color: #007bff; 
    margin-right: 8px;
    padding: 6px 12px;
    font-size: 0.9em;
}

/* ==============================================
   10. 설정 그리드
   ============================================== */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item:last-child {
    grid-column: span 2;
    flex-direction: row;
    justify-content: center;
    gap: 15px;
}

/* ==============================================
   11. 팁 상자
   ============================================== */

.tips {
    position: relative;
    width: 100%;
    background-color: #aeeecb;
    color: #1a7242;
    padding: 10px;
    text-align: left;
    border-radius: 8px;
    margin-bottom: 30px;
}

.tips p {
    margin: 0;
}

/* ==============================================
   12. 에러 메시지
   ============================================== */
.validation-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 15px;
    display: none;
}

.validation-error.show { display: block; }
.validation-error::before { content: "※ "; font-weight: bold; }

/* ==============================================
   13. 다크모드 (간소화)
   ============================================== */
.dark-mode .guild-table, .dark-mode .guild-battle-grid { background: #495057; color: white; }
.dark-mode .guild-table th, .dark-mode .guild-battle-grid th { background-color: #212529; }
.dark-mode .guild-table td, .dark-mode .guild-battle-grid td { border-color: #6c757d; }

.dark-mode .day-header { background-color: #0056b3 !important; }
.dark-mode .stats-header { background-color: #5a2d91 !important; }
.dark-mode .sub-header th { background-color: #545b62 !important; }

.dark-mode .editable-cell, .dark-mode .editable-battle-cell {
    background-color: #6c757d;
    color: white;
}

.dark-mode .editable-cell:focus, .dark-mode .editable-battle-cell:focus {
    background-color: #495057;
}

.dark-mode .editable-battle-cell.error {
    background-color: #721c24 !important;
    color: #f8d7da !important;
}

.dark-mode .result-win {
    background-color: #1e7e34 !important;
    color: white !important;
}

.dark-mode .result-lose {
    background-color: #bd2130 !important;
    color: white !important;
}

.dark-mode .autocomplete-dropdown {
    background: #495057;
    border-color: #6c757d;
}

.dark-mode .autocomplete-item { color: white; }
.dark-mode .validation-error { background-color: #721c24; color: #f8d7da; }