/* =============================================================
   files.css — 파일 보관함 (폴더 탐색 + 미리보기)
   포털 톤(글래스 패널, --muted, sky 액센트)을 따르며 새 색을 만들지 않는다.
   ============================================================= */

/* display 를 지정하는 요소는 [hidden] 을 다시 명시해야 숨는다. */
.file-viewer[hidden],
.file-dialog[hidden] {
    display: none;
}

/* ---------- 경로 ---------- */
.file-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0 1.1rem;
    font-size: 0.85rem;
}

.file-crumb {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--muted);
    text-decoration: none;
}

.file-crumb:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.09);
}

.file-crumb.is-current {
    color: var(--text);
    background: rgba(121, 212, 255, 0.14);
    font-weight: 700;
}

.file-crumb-sep {
    color: var(--muted);
}

/* ---------- 입력/액션 ---------- */
.file-picker-field,
.file-folder-field {
    min-width: 0;
}

.file-input-native,
.file-share-input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.file-picker {
    display: flex;
    align-items: center;
    width: 100%;
    height: 2.5rem;
    padding: 0 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    color: var(--text);
    cursor: pointer;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.file-picker:hover,
.file-picker:focus-within {
    border-color: rgba(121, 212, 255, 0.5);
    background: rgba(121, 212, 255, 0.09);
    transform: translateY(-1px);
}

.file-picker-name {
    min-width: 0;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 6rem;
    height: 2.5rem;
    padding: 0 1rem;
    white-space: nowrap;
}

.file-upload-button {
    width: fit-content;
    min-width: 4.8rem;
    padding-inline: 0.85rem;
}

.file-share-toggle {
    white-space: nowrap;
}

.file-share-button {
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.055);
    color: var(--text);
}

.file-share-button:hover {
    border-color: rgba(121, 212, 255, 0.5);
    background: rgba(121, 212, 255, 0.09);
    color: var(--text);
}

.file-share-input:checked + .file-share-button {
    border-color: rgba(255, 255, 255, 0.08);
    background: linear-gradient(135deg, #ff9c52, #ffb980);
    color: #08111d;
}

.file-create-folder-form {
    display: grid;
    grid-template-columns: minmax(12rem, 24rem) auto;
    align-items: end;
    width: fit-content;
    max-width: 100%;
}

.file-create-folder-form input[type="text"] {
    width: 100%;
    max-width: 100%;
    height: 2.5rem;
    border-radius: 999px;
}

/* ---------- 목록 ---------- */
.file-inline-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.file-inline-form input[type="text"] {
    flex: 1;
    min-width: 0;
}

.file-inline-form.file-create-folder-form {
    display: grid;
    grid-template-columns: minmax(12rem, 24rem) auto;
    align-items: end;
    width: fit-content;
    max-width: 100%;
}

/* 파일 보관함은 업로드/목록을 수직으로 쌓아 디렉토리 탐색 공간을 넓게 쓴다. */
.file-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

.file-workspace > .sub-panel:first-child {
    padding: 1rem;
}

.file-workspace > .sub-panel:first-child .stack-form {
    display: grid;
    grid-template-columns: minmax(12rem, 24rem) auto auto;
    align-items: end;
    gap: 0.6rem;
}

.file-workspace > .sub-panel:first-child .file-share-toggle {
    align-self: end;
}

.file-workspace > .sub-panel:first-child .file-inline-form {
    max-width: 34rem;
}

.file-workspace > .sub-panel:first-child .file-create-folder-form {
    max-width: 100%;
}

.file-table {
    table-layout: fixed;
}

.file-table td:first-child,
.file-table th:first-child {
    width: 42%;
}

.file-table th:nth-child(2),
.file-table td:nth-child(2) {
    width: 6rem;
}

.file-table th:nth-child(3),
.file-table td:nth-child(3) {
    width: 5.5rem;
    white-space: nowrap;
}

.file-table th:nth-child(4),
.file-table td:nth-child(4) {
    width: 8rem;
    white-space: nowrap;
}

.file-table th:nth-child(5),
.file-table td:nth-child(5) {
    width: 1%;
    white-space: nowrap;
}

.file-table td,
.file-table th {
    vertical-align: middle;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.file-table tbody tr {
    border-color: rgba(255, 255, 255, 0.07);
}

.file-table tbody tr:hover {
    background: rgba(121, 212, 255, 0.045);
}

@media (max-width: 900px) {
    .file-workspace > .sub-panel:first-child .stack-form {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .file-workspace > .sub-panel:first-child .file-picker-field {
        grid-column: 1 / -1;
    }

    .file-workspace > .sub-panel:first-child .file-share-toggle {
        grid-column: 2;
    }

    .file-create-folder-form {
        grid-template-columns: minmax(0, 1fr) auto;
        width: 100%;
    }

    .file-create-folder-form input[type="text"] {
        width: 100%;
    }


    .file-table .action-cell {
        flex-wrap: wrap;
    }
}

.file-name {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 0;
    background: transparent;
    color: var(--text);
    padding: 0;
    text-align: left;
    text-decoration: none;
    max-width: 100%;
    min-width: 0;
}

.file-name-text {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-preview-trigger:hover,
.file-name.is-folder:hover {
    color: var(--lg-cool, #79d4ff);
    text-decoration: underline;
}

.file-name.is-folder {
    font-weight: 700;
}

.file-icon {
    flex: 0 0 auto;
}

.file-table td:first-child .file-name {
    width: 100%;
}

.file-table .action-cell {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.28rem;
}

.file-table .action-cell .inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    margin: 0;
}

.file-table .action-cell .btn-sm,
.file-table .action-cell .form-select-sm {
    padding-top: 0.22rem;
    padding-bottom: 0.22rem;
    font-size: 0.72rem;
}

.file-table .action-cell .form-select-sm {
    width: 9rem;
    min-width: 9rem;
    border-radius: 999px;
}

/* ---------- 미리보기 뷰어 ---------- */
.file-viewer,
.file-dialog {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background: rgba(3, 8, 16, 0.68);
    backdrop-filter: blur(8px);
}

.file-viewer-panel {
    display: flex;
    flex-direction: column;
    width: min(60rem, 100%);
    max-height: calc(100vh - 3rem);
    overflow: hidden;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(8, 16, 29, 0.96);
    box-shadow: 0 28px 74px rgba(0, 0, 0, 0.52);
}

.file-viewer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.file-viewer-head strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-viewer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.file-viewer-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 1.1rem;
}

.file-viewer-body img,
.file-viewer-body video {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 12rem);
    margin: 0 auto;
    border-radius: 12px;
}

.file-viewer-body audio {
    width: 100%;
}

.file-viewer-body iframe {
    width: 100%;
    height: calc(100vh - 12rem);
    border: 0;
    border-radius: 12px;
    background: #fff;
}

.file-viewer-note {
    margin: 0;
    color: var(--muted);
    text-align: center;
}

.file-plaintext {
    margin: 0;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---------- 마크다운 ---------- */
.file-markdown {
    line-height: 1.65;
}

.file-markdown h1,
.file-markdown h2,
.file-markdown h3,
.file-markdown h4 {
    margin: 1.2rem 0 0.5rem;
    line-height: 1.25;
}

.file-markdown h1 { font-size: 1.6rem; }
.file-markdown h2 { font-size: 1.35rem; }
.file-markdown h3 { font-size: 1.12rem; }

.file-markdown p,
.file-markdown ul {
    margin: 0 0 0.75rem;
}

.file-markdown ul {
    padding-left: 1.2rem;
}

.file-markdown code {
    padding: 0.1rem 0.35rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.09);
    font-family: var(--font-mono, monospace);
    font-size: 0.86em;
}

.file-markdown pre {
    margin: 0 0 0.9rem;
    padding: 0.9rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    overflow-x: auto;
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
}

.file-markdown blockquote {
    margin: 0 0 0.9rem;
    padding: 0.35rem 0.9rem;
    border-left: 3px solid rgba(121, 212, 255, 0.5);
    color: var(--muted);
}

.file-markdown a {
    color: var(--lg-cool, #79d4ff);
}

/* ---------- 이름 변경 다이얼로그 ---------- */
.file-dialog-panel {
    width: min(24rem, 100%);
    padding: 1.1rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(8, 16, 29, 0.96);
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.5);
}

.file-dialog-panel input[type="text"] {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    padding: 0.55rem 0.75rem;
}

@media (max-width: 720px) {
    .file-viewer-body iframe,
    .file-viewer-body img,
    .file-viewer-body video {
        max-height: 60vh;
    }

    .file-viewer-body iframe {
        height: 60vh;
    }
}

.drive-browser-panel {
    display: grid;
    gap: 0.75rem;
}

.drive-target-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.drive-target-row strong {
    color: var(--text);
}

.drive-table th:first-child,
.drive-table td:first-child {
    width: 54%;
}

.drive-table th:nth-child(2),
.drive-table td:nth-child(2) {
    width: 20%;
}

.drive-table th:nth-child(3),
.drive-table td:nth-child(3) {
    width: 8rem;
}

.drive-page-actions {
    display: flex;
    justify-content: center;
}

/* ---------- 제한 모드(비로그인·소셜 미연동) 안내 ---------- */
.file-limited-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 0.9rem;
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(121, 212, 255, 0.28);
    border-left: 3px solid var(--accent-cool);
    border-radius: var(--radius-sm);
    background: rgba(121, 212, 255, 0.07);
}

.file-limited-badge {
    flex: none;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(121, 212, 255, 0.16);
    color: var(--accent-cool);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.file-limited-text {
    flex: 1 1 18rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.55;
}

.file-limited-text strong {
    color: var(--text);
}

.file-limit-error {
    grid-column: 1 / -1;
    margin: 0;
    color: #ff9d9d;
    font-size: 0.82rem;
}
