/* =========================================
   1. Reset & Layout Base (수정됨)
   ========================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

body { overflow: hidden; }

.flex { display: flex; }
.jcsb { justify-content: space-between; }

#detail-container {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    opacity: 0;
    z-index: 0;
    transition: 0.5s;
}

#detail-container.active {
    opacity: 1;
    z-index: 100;
    height: calc(100vh - 80px);
}

/* [수정 1] 세로-윗 정렬로 변경 */
#detail-container #capture_area {
    width: 80%;
    height: 60%;
    background-color: #555;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    /* 내부 레이아웃 수정 */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* center -> flex-start (위쪽 정렬) */
    padding: 2rem 2rem; /* 상단 패딩을 늘려서(1.5->3) 너무 붙지 않게 함 */
    color: #fff;
}


/* =========================================
   2. Buttons (Close, Download, Edit)
   ========================================= */
/* (기존 코드 유지) */
#detail-container #close_btn,
#detail-container #download_btn {
    position: absolute;
    right: 30px;
    background: transparent;
    color: #fff;
    border: 3px solid #fff;
    border-radius: 50%;
    font-weight: bold;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
}
#detail-container #close_btn { top: 30px; }
#detail-container #download_btn { top: 90px; }

#detail-container #edit_btn {
    position: absolute;
    bottom: 30px; 
    right: 30px;
    background: transparent;
    color: #fff;
    border: 3px solid #fff;
    border-radius: 4px;
    font-weight: bold;
    width: 140px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
}
#detail-container button:hover { background: rgba(255,255,255,0.1); }


/* =========================================
   3. View Mode Content
   ========================================= */
/* (기존 코드 유지) */


#detail-container #category-container,
#detail-container #technologies-container,
#detail-container #status-container,
#detail-container #develop-schedule {
    margin: 5px 0;
    display: flex;
}
.category-chip, .tech-chip {
    display: inline-block;
    color: #fff;
    padding: 3px 8px;
    border-radius: 15px;
    font-size: 12px;
    margin-right: 5px;
    margin-bottom: 2px;
}
.category-chip { background-color: #007BFF; }
.tech-chip { background-color: #28A745; }

#detail-description {
    margin: 10px 0; /* 간격 살짝 조정 */
    line-height: 1.4;
    font-size: 0.95rem;
    max-height: 100px;
    overflow-y: auto;
}
#status-label, #schedule-label { font-weight: bold; margin-right: 10px; }
#detail-title { font-size: 1.8rem; margin-bottom: 10px; }


/* =========================================
   4. Fan Animation
   ========================================= */
/* (기존 코드 유지 - 생략 가능하지만 안전하게 둠) */
#fan-container {
    width: 100%; height: calc(100vh - 80px); overflow: hidden;
    display: flex; justify-content: center; align-items: center;
    position: absolute; top: 200px;
}
#fan-wrapper { position: relative; width: 800px; height: 200px; }
.card {
    width: 160px; height: 250px; position: absolute; left: 50%; margin-left: -70px;
    border-radius: 10px; display: flex; flex-direction: column; justify-content: flex-end;
    padding: 15px; color: #fff; box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer; transform-origin: center 600px;
    transform: rotate(var(--rotate-deg)); transition: 0.2s ease;
}
.card span { font-size: 16px; font-weight: bold; position: absolute; top: 20px; }
.card em { font-style: normal; font-size: 22px; font-weight: bold; }
.card:hover { transform: rotate(var(--rotate-deg)) scale(1.1); z-index: 10 !important; box-shadow: 0 8px 25px rgba(0,0,0,0.3); }


/* =========================================
   5. Edit Mode Logic (수정됨)
   ========================================= */
/* [수정 2] 기본적으로 Edit Field 및 하위 요소들 강력하게 숨김 */
.edit-field, 
.edit-field.extra-settings {
    display: none !important;
}
#detail-container.editing #detail-content {
    width: 70%;
}
#detail-container.editing #status-label, 
#detail-container.editing #schedule-label {
    display: none;
}
/* Editing 클래스가 붙으면 View 숨기고 Edit 보임 */
#detail-container.editing .view-field { display: none !important; }

/* [수정 2] 편집 모드일 때만 보이도록 설정 */
#detail-container.editing .edit-field { display: block !important; }

/* 날짜 입력칸 flex */
#detail-container.editing #develop-schedule .edit-field { display: flex !important; }

/* 아이콘/색상 설정창 flex */
#detail-container.editing .edit-field.extra-settings { display: flex !important; }


/* =========================================
   6. Edit Mode Styling
   ========================================= */
.edit-field {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    padding: 2px 0;
    margin-bottom: 4px;
    transition: all 0.3s ease;
}
.edit-field:focus {
    outline: none;
    border-bottom: 1px solid #fff;
    background: rgba(0, 0, 0, 0.1);
}
#edit-title { font-size: 1.8rem; font-weight: bold; margin-bottom: 10px; }
#edit-category, #edit-tech { color: #ddd; }
textarea#edit-desc {
    height: 40px; min-height: 50px; line-height: 1.3; resize: none;
    background: rgba(0,0,0,0.1); border-radius: 5px; padding: 5px; margin-bottom: 5px;
}
#develop-schedule .edit-field { border-bottom: none; display: flex; align-items: center; gap: 10px; }
#develop-schedule input[type="date"] {
    background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px; padding: 4px; font-family: inherit; cursor: pointer;
}
#develop-schedule input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }


/* =========================================
   7. Bottom Controls (수정됨)
   ========================================= */
.edit-field.extra-settings {
    position: absolute;
    bottom: 30px;
    left: 30px;
    
    /* [수정 3] 너비 확장 및 정렬 이슈 해결 */
    width: auto;
    min-width: 250px; /* 최소 너비 확보해서 삐져나옴 방지 */
    margin: 0;
    padding: 0;
    border: none;
    
    align-items: center;
    gap: 15px;
    z-index: 200;
}

.extra-settings label {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.3);
    padding: 5px 12px; /* 패딩 살짝 늘림 */
    border-radius: 20px;
    white-space: nowrap; /* 줄바꿈 방지 */
}

#edit-color {
    width: 25px; height: 25px; border: 1px solid #fff;
    border-radius: 50%; padding: 0; background: none; cursor: pointer;
}
#edit-icon {
    width: 30px; text-align: center; background: transparent;
    border: none; color: #fff; font-size: 1.2rem; cursor: pointer;
}


/* =========================================
   8. Icon Preset Box
   ========================================= */
.preset-box {
    display: none; /* JS 제어 */
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 180px; /* 너비 살짝 늘림 */
    background: #333;
    border: 1px solid #555;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    padding: 8px;
    z-index: 999;
    flex-wrap: wrap;
    gap: 5px;
}
.preset-box.show { display: flex; }
.preset-box span {
    font-size: 1.2rem; padding: 5px; cursor: pointer;
    border-radius: 4px; transition: background 0.2s;
}
.preset-box span:hover { background-color: #555; transform: scale(1.2); }

/* =========================================
   [Clean HTML Fix] Removed Inline Styles
   ========================================= */

/* 1. 아이콘 픽커 래퍼 (position: relative 복구) */
.icon-picker-wrapper {
    position: relative;
}

/* 2. 아이콘 인풋 커서 및 정렬 (이미 있지만 확실하게) */
#edit-icon {
    cursor: pointer;
    text-align: center;
}

/* 3. 카드 내부 하단 영역 (font-size: 24px 복구) */
/* HTML에서 <div class="card-footer flex jcsb"> 로 클래스 추가함 */
.card-footer {
    font-size: 24px;
    width: 100%; /* flex jcsb가 잘 작동하도록 */
}

/* 4. 초기 카드 로테이션 변수 초기화 */
/* HTML style="--rotate-deg: 0deg" 제거 대체 */
#init_card {
    --rotate-deg: 0deg;
}

/* 5. 인풋 필드 너비 100% 보장 (이미 .edit-field에 있지만 혹시 몰라 추가) */
#edit-category, 
#edit-tech, 
#edit-link {
    width: 100%;
}