/**
 * 오디오 태그 편집기 전용 스타일
 * 공통 스타일(common.css)에 없는 요소만 여기에 둡니다.
 */

/* ── 미지원 브라우저 안내 ───────────────────────────────── */
.unsupported-banner {
    display: none;
    background: #fdecea;
    border-left: 4px solid #e07a7a;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 20px;
    color: #8a3a3a;
}

.unsupported-banner strong {
    display: block;
    margin-bottom: 6px;
    font-size: 1rem;
}

.unsupported-banner span {
    font-size: 0.88rem;
    line-height: 1.6;
}

/* ── 상단 도구 막대 ─────────────────────────────────────── */
.toolbar-panel {
    padding: 18px 20px;
    margin-bottom: 16px;
}

.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.toolbar-row + .toolbar-row {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f5;
}

.toolbar-spacer {
    flex: 1;
}

.setup-hint {
    font-size: 0.82rem;
    color: #98a0b3;
}

.loaded-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    margin-right: 4px;
}

/* ── 폴더를 열기 전에는 폴더 열기만 보인다 ─────────────── */
body:not(.folder-loaded) .toolbar-actions,
body:not(.folder-loaded) .workspace,
body:not(.folder-loaded) .warning-box {
    display: none !important;
}

body:not(.folder-loaded) .toolbar-panel {
    max-width: 640px;
    margin: 0 auto 16px;
    padding: 40px 32px;
}

body:not(.folder-loaded) .setup-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
}

body:not(.folder-loaded) #openFolderBtn {
    padding: 14px 36px;
    font-size: 1rem;
}

/* ── 폴더를 연 뒤에는 폴더 열기 줄을 감춘다 ([리셋]으로 처음 화면에 돌아간다) ── */
body.folder-loaded .setup-row {
    display: none;
}

/* 폴더를 연 뒤에는 설정 줄이 사라지므로 위쪽 경계선도 없앤다 */
body.folder-loaded .toolbar-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.root-name {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-text {
    font-size: 0.8rem;
    color: #8a93a5;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ── 경고 목록 ──────────────────────────────────────────── */
.warning-box {
    display: none;
    background: #fff8e6;
    border-left: 4px solid #f0c674;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 16px;
}

.warning-title {
    font-weight: 600;
    color: #8a6d1f;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.warning-list {
    margin: 0;
    padding-left: 18px;
    max-height: 160px;
    overflow-y: auto;
    color: #7a6428;
    font-size: 0.82rem;
    line-height: 1.7;
}

/* ── 작업 영역 ──────────────────────────────────────────── */
.workspace {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 16px;
    align-items: start;
    margin-bottom: 40px;
}

@media (max-width: 1000px) {
    .workspace {
        grid-template-columns: 1fr;
    }
}

.main-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

/* ── 폴더 목록 ──────────────────────────────────────────── */
.folder-panel {
    padding: 18px;
    position: sticky;
    top: 20px;
}

@media (max-height: 620px) {
    .folder-panel {
        position: static;
    }

    .folder-list {
        max-height: 400px;
    }
}

/* 폴더 목록 좁히기 */
.folder-filter-row {
    position: relative;
    margin-bottom: 10px;
}

.folder-filter {
    width: 100%;
    padding: 8px 30px 8px 12px;
    border: 2px solid #e8e8ef;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.82rem;
    color: #3f4759;
    transition: border-color 0.2s;
}

.folder-filter:focus {
    outline: none;
    border-color: #a5b4f0;
}

.folder-filter-clear {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: #eceef5;
    color: #8a93a5;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}

.folder-filter-clear:hover {
    background: #dfe2ec;
    color: #5a6273;
}

.folder-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* 화면 높이에 맞춰 늘어난다. 목록이 길어도 패널이 화면 밖으로 나가지 않는다. */
    max-height: calc(100vh - 200px);
    min-height: 180px;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: 0 -6px;
    padding: 0 6px;
}

/* 목록이 길 때 스크롤 막대를 눈에 덜 띄게 */
.folder-list::-webkit-scrollbar {
    width: 8px;
}

.folder-list::-webkit-scrollbar-thumb {
    background: #d9dcea;
    border-radius: 4px;
}

.folder-list::-webkit-scrollbar-thumb:hover {
    background: #c5cae9;
}

.folder-list::-webkit-scrollbar-track {
    background: transparent;
}

.folder-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "name count"
        "meta count";
    gap: 2px 8px;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f8f9fc;
    cursor: pointer;
    transition: all 0.15s;
}

.folder-item:hover {
    background: #eef1fb;
}

.folder-item.active {
    background: linear-gradient(135deg, #e8eaf6 0%, #f3e5f5 100%);
    border-color: #c5cae9;
}

.folder-item-name {
    grid-area: name;
    font-size: 0.88rem;
    font-weight: 600;
    color: #4a5568;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item-meta {
    grid-area: meta;
    font-size: 0.72rem;
    color: #98a0b3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item-count {
    grid-area: count;
    align-self: center;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: #8a93a5;
}

.dirty-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f0a0b8;
    display: inline-block;
}

.empty-hint {
    padding: 24px 12px;
    text-align: center;
    color: #a8b0c0;
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ── 앨범 패널 ──────────────────────────────────────────── */
.album-panel {
    padding: 20px;
}

.album-path {
    font-size: 0.75rem;
    color: #a8b0c0;
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
}

.album-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 700px) {
    .album-layout {
        grid-template-columns: 1fr;
    }
}

.cover-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cover-box {
    position: relative;
    width: 220px;
    height: 220px;
    border: 2px dashed #d9dcea;
    border-radius: 12px;
    background: #f8f9fc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.2s;
}

.cover-box.dragover {
    border-color: #a5b4f0;
    background: #eef1fb;
}

.cover-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #a8b0c0;
    font-size: 0.78rem;
    text-align: center;
    padding: 0 12px;
}

.cover-placeholder-icon {
    font-size: 1.8rem;
}

.cover-info {
    font-size: 0.72rem;
    color: #98a0b3;
    text-align: center;
    min-height: 16px;
}

.cover-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.cover-actions .btn {
    justify-content: center;
    text-align: center;
}

/* 앨범 항목은 라벨과 입력창을 한 줄에 두어 5줄로 정렬한다 */
.album-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.album-fields .field-row {
    display: grid;
    grid-template-columns: 96px 1fr;
    align-items: center;
    gap: 12px;
}

/* 칩이 여러 줄로 접히면 라벨은 첫 줄에 맞춘다 */
.album-fields .field-row:has(.genre-chips) {
    align-items: start;
}

.album-fields .field-row:has(.genre-chips) .field-label {
    padding-top: 6px;
}

.album-fields .field-label {
    margin: 0;
    white-space: nowrap;
}

@media (max-width: 560px) {
    .album-fields .field-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}

/* 장르 선택 칩 */
.genre-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.genre-chip {
    padding: 5px 11px;
    border: 1px solid #e2e5f0;
    border-radius: 14px;
    background: #f8f9fc;
    color: #6b7280;
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}

.genre-chip:hover {
    background: #eef1fb;
    border-color: #c5cae9;
    color: #4a5568;
}

/* 목록에 없는 장르를 적는 칸 — 다른 칩과 같은 모양이되 점선으로 구분한다 */
.genre-custom {
    border-style: dashed;
    text-align: center;
    flex-shrink: 0;
    /* 적은 글자 수에 맞춰 폭이 따라간다.
       상한을 낮게 두면 거기서 멈춰 마지막 글자가 잘리므로 넉넉히 잡는다. */
    field-sizing: content;
    min-width: 66px;
    max-width: 100%;
}

.genre-custom::placeholder {
    color: inherit;
    opacity: 0.7;
}

.genre-custom:focus {
    outline: none;
    border-style: solid;
    border-color: #a5b4f0;
    background: white;
    color: #3f4759;
}

.genre-custom.active {
    border-style: solid;
}

.genre-chip.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: white;
    font-weight: 600;
}

.genre-note {
    font-size: 0.75rem;
    color: #a8862f;
    padding: 0 4px;
}

.album-hint {
    margin-top: 14px;
    font-size: 0.78rem;
    color: #98a0b3;
}

/* ── 입력 필드 ──────────────────────────────────────────── */
.field-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.field-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
}

.field-label-block {
    display: block;
    margin: 14px 0 6px;
}

.field-input {
    width: 100%;
    padding: 9px 12px;
    border: 2px solid #e8e8ef;
    border-radius: 8px;
    font-size: 0.88rem;
    color: #3f4759;
    font-family: inherit;
    transition: border-color 0.2s;
}

.field-input:focus {
    outline: none;
    border-color: #a5b4f0;
}

.field-input.mixed {
    background: #fbf9f2;
    border-color: #efe3c8;
}

/* ── 트랙 표 ────────────────────────────────────────────── */
.track-panel {
    padding: 20px;
}

/* 곡이 많아도 표 안에서 따로 스크롤하지 않는다.
   페이지 스크롤로 전체를 훑고, 머리글만 화면 위에 붙는다. */
.track-table-wrap {
    overflow: visible;
    border: 1px solid #eeeef4;
    border-radius: 10px;
}

/* 화면이 좁을 때만 가로 스크롤을 허용한다 (열이 뭉개지지 않도록) */
@media (max-width: 700px) {
    .track-table-wrap {
        overflow-x: auto;
    }

    .track-table {
        min-width: 560px;
    }
}

.track-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    /* 파일명이 길어도 열 너비가 밀리지 않도록 고정 배분한다 */
    table-layout: fixed;
}

.track-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f5f6fb;
    box-shadow: inset 0 -1px 0 #e8e8ef;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid #e8e8ef;
    white-space: nowrap;
}

.track-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #f2f2f7;
    vertical-align: middle;
}

.track-row {
    cursor: pointer;
    transition: background 0.15s;
}

.track-row:hover {
    background: #fafbff;
}

.track-row.selected {
    background: #eef1fb;
}

.track-row.dirty .col-name {
    font-weight: 600;
    color: #7c6ba8;
}

.col-name {
    width: 38%;
}

/* 파일명 칸: [형식] [입력창] [교정 단추] */
.name-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    color: #5a6273;
    font-size: 0.8rem;
}

.name-input {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
}

.name-input.renamed {
    background: #eef6f1;
    border-color: #b6ddc7;
    color: #35704f;
}

.name-input.invalid {
    background: #fdecea;
    border-color: #e8a9a2;
    color: #a8453a;
}

/* 깨진 파일명을 교정된 이름으로 바꾸는 단추 */
.name-fix {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 6px;
    background: #fbe8ee;
    color: #a85b76;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}

.name-fix:hover {
    background: #f6d4de;
}

.col-track { width: 76px; }
.col-title { width: 30%; }
.col-artist { width: 22%; }


.track-format {
    display: inline-block;
    flex-shrink: 0;
    min-width: 44px;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    vertical-align: middle;
    cursor: help;
}

.track-format.id3 {
    background: #e6f0fb;
    color: #5b7fa8;
}

.track-format.flac {
    background: #e8f6ee;
    color: #4f8a68;
}

.cell-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    font-size: 0.85rem;
    font-family: inherit;
    color: #3f4759;
    transition: all 0.15s;
}

.cell-input:hover {
    background: #f6f7fc;
}

.cell-input:focus {
    outline: none;
    background: white;
    border-color: #a5b4f0;
}

/* ── 곡 상세 ────────────────────────────────────────────── */
.detail-panel {
    padding: 20px;
}

.detail-panel.empty {
    opacity: 0.6;
}

/* 재생기 */
.detail-player {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: #f8f9fc;
    border-radius: 10px;
}

.detail-player audio {
    flex: 1;
    min-width: 240px;
    height: 34px;
}

.detail-panel.empty .detail-player {
    display: none;
}

.detail-error {
    padding: 12px 14px;
    background: #fdecea;
    border-left: 4px solid #e07a7a;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #8a3a3a;
    line-height: 1.6;
}

.detail-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px 16px;
}

.lyrics-textarea {
    width: 100%;
    height: 220px;
    padding: 14px;
    border: 2px solid #e8e8ef;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.7;
    color: #3f4759;
    resize: vertical;
}

.lyrics-textarea:focus {
    outline: none;
    border-color: #a5b4f0;
}

.lyrics-textarea:disabled {
    background: #f8f9fc;
    color: #a8b0c0;
}

/* ── 모달 ───────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(40, 42, 60, 0.45);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 620px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid #f0f0f5;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: #4a5568;
}

.modal-close {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: #f4f5f9;
    color: #8a93a5;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s;
}

.modal-close:hover {
    background: #e8eaf1;
    color: #5a6273;
}

.modal-search {
    display: flex;
    gap: 8px;
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f5;
}

.modal-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #fafbff;
    border-bottom: 1px solid #f0f0f5;
}

.modal-tools-label {
    font-size: 0.78rem;
    color: #7a8296;
}

.modal-tools-buttons {
    display: inline-flex;
    gap: 6px;
    margin-left: auto;
}

.modal-body {
    padding: 14px 20px 20px;
    overflow-y: auto;
}

/* 검색 결과의 일치 정도 표시 */
.match-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 0.66rem;
    font-weight: 600;
    vertical-align: middle;
}

.match-sure {
    background: #e0f0e6;
    color: #4f8a68;
}

.match-loose {
    background: #fdf3dc;
    color: #a8862f;
}

.modal-loading,
.modal-empty {
    padding: 30px 10px;
    text-align: center;
    color: #a8b0c0;
    font-size: 0.88rem;
}

.album-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}

.album-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid #eeeef4;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.album-result:hover {
    border-color: #c5cae9;
    background: #fafbff;
}

.album-result img {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.album-result-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.album-result-info strong {
    font-size: 0.85rem;
    color: #4a5568;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-result-info em {
    font-style: normal;
    font-size: 0.76rem;
    color: #7a8296;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.album-result-info small {
    font-size: 0.7rem;
    color: #a8b0c0;
}

.lyrics-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lyrics-result {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid #eeeef4;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.lyrics-result:hover {
    border-color: #c5cae9;
    background: #fafbff;
}

.lyrics-result-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.lyrics-result-head strong {
    font-size: 0.88rem;
    color: #4a5568;
}

.lyrics-result-head em {
    font-style: normal;
    font-size: 0.76rem;
    color: #7a8296;
}

.lyrics-result-preview {
    font-size: 0.76rem;
    color: #98a0b3;
    line-height: 1.6;
    max-height: 3.2em;
    overflow: hidden;
}

/* ── 진행 오버레이 ──────────────────────────────────────── */
.processing-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(3px);
    z-index: 10001;
    align-items: center;
    justify-content: center;
}

.processing-overlay.show {
    display: flex;
}

.processing-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 40px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-width: 420px;
    text-align: center;
}

.processing-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid #eef1fb;
    border-top-color: #a5b4f0;
    border-radius: 50%;
    animation: tagger-spin 0.9s linear infinite;
}

@keyframes tagger-spin {
    to { transform: rotate(360deg); }
}

.processing-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: #4a5568;
}

.processing-sub {
    font-size: 0.8rem;
    color: #98a0b3;
    word-break: break-all;
    min-height: 16px;
}
