/* TFS Admin Dashboard Custom Styles */

/* Configuration, structured data, plain text and source files. */
.text-file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-control, 6px);
    color: var(--color-accent-primary);
    background: var(--color-accent-muted);
}
.text-file-icon-text { color: var(--color-text-secondary); background: var(--color-bg-tertiary); }
.text-file-icon-data { color: var(--color-success); background: var(--color-bg-tertiary); }

.clash-cat-mark {
    display: inline-block;
    flex: none;
    width: 28px;
    height: 28px;
    background: currentColor;
    -webkit-mask: url('/clash.svg') center / contain no-repeat;
    mask: url('/clash.svg') center / contain no-repeat;
}
.clash-file-icon { color: var(--color-accent-primary); }
.clash-details { padding: 14px; border: 1px solid var(--color-border-primary); border-radius: var(--radius-control, 6px); background: var(--color-bg-tertiary); }
.clash-details-header, .clash-details-header h3 { display: flex; align-items: center; gap: 8px; }
.clash-details-header { justify-content: space-between; gap: 12px; }
.clash-details-header h3 { color: var(--color-text-primary); font-size: 14px; font-weight: 600; }
.clash-details-header .clash-cat-mark { width: 22px; height: 22px; color: var(--color-accent-primary); }
.clash-details button { flex-shrink: 0; }
.clash-details button:disabled { opacity: 0.5; cursor: wait; }
.clash-details-hint { margin-top: 6px; font-size: 12px; color: var(--color-text-tertiary); overflow-wrap: anywhere; white-space: pre-line; }
.clash-details-error { margin-top: 8px; font-size: 12px; color: var(--color-danger); overflow-wrap: anywhere; }
.clash-nodes-scroll { max-height: 320px; margin-top: 12px; overflow-y: auto; }
.clash-nodes-table { width: 100%; border-collapse: collapse; table-layout: fixed; text-align: left; }
.clash-nodes-table th { position: sticky; top: 0; padding: 8px 0; font-size: 11px; font-weight: 500; color: var(--color-text-tertiary); background: var(--color-bg-tertiary); }
.clash-nodes-table th:last-child { width: 100px; text-align: right; }
.clash-nodes-table td { padding: 9px 0; border-top: 1px solid var(--color-border-primary); }
.clash-nodes-table td:first-child { padding-right: 12px; }
.clash-node-name { color: var(--color-text-primary); font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.clash-node-address { margin-top: 3px; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--color-text-tertiary); overflow-wrap: anywhere; }
.clash-node-latency { text-align: right; color: var(--color-text-secondary); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.clash-latency-fast { color: var(--color-success); }
.clash-latency-slow { color: var(--color-accent-primary); }
.clash-latency-failed { color: var(--color-danger); }
.clash-subscription { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--color-border-primary); }
.clash-subscription label { color: var(--color-text-secondary); font-size: 12px; }
.clash-subscription-controls { display: flex; gap: 8px; margin-top: 6px; }
.clash-subscription-controls input { width: 0; min-width: 0; flex: 1; padding: 6px 8px; border-radius: 4px; font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.text-editor-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.5);
}
.text-editor-overlay.hidden { display: none; }
.text-editor-dialog {
    display: flex;
    flex-direction: column;
    width: min(1120px, 100%);
    height: min(820px, calc(100dvh - 48px));
    overflow: hidden;
    border: 1px solid var(--color-border-primary);
}
.text-editor-header, .text-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
}
.text-editor-heading { min-width: 0; }
#textEditorFileName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.text-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    border-top: 1px solid var(--color-border-primary);
    border-bottom: 1px solid var(--color-border-primary);
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    font-size: 12px;
}
.text-editor-format { padding: 2px 8px; border-radius: 4px; background: var(--color-accent-muted); color: var(--color-accent-primary); }
.text-editor-charset { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.text-editor-charset select { padding: 2px 5px; border-radius: 4px; font-size: 12px; }
#textEditorReload { margin-left: auto; white-space: nowrap; }
.text-editor-error { padding: 10px 24px; color: var(--color-danger); background: var(--color-bg-tertiary); font-size: 13px; overflow-wrap: anywhere; }
.text-editor-surface { display: flex; flex: 1; min-height: 0; background: var(--color-bg-secondary); }
.text-editor-content, .text-editor-line-numbers {
    margin: 0;
    padding: 16px;
    border: 0;
    border-radius: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    line-height: 24px;
    font-variant-ligatures: none;
    tab-size: 4;
    white-space: pre;
}
.text-editor-line-numbers {
    flex: none;
    min-width: 54px;
    overflow: hidden;
    text-align: right;
    user-select: none;
    color: var(--color-text-muted);
    background: var(--color-bg-tertiary);
    border-right: 1px solid var(--color-border-primary);
}
.text-editor-content {
    flex: 1;
    width: 0;
    min-width: 0;
    resize: none;
    outline: none;
    color: var(--color-text-primary);
    caret-color: var(--color-accent-primary);
    background: transparent;
}
.text-editor-content:focus-visible { box-shadow: inset 0 0 0 1px var(--color-accent-primary); }
.text-editor-content:disabled { opacity: 0.6; }
.text-editor-statusbar { display: flex; justify-content: space-between; gap: 12px; padding: 6px 24px; font-size: 12px; color: var(--color-text-tertiary); border-top: 1px solid var(--color-border-primary); }
.text-editor-footer { border-top: 1px solid var(--color-border-primary); }
.text-editor-actions { display: flex; flex-shrink: 0; gap: 10px; }
.text-editor-dialog button:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 640px) {
    .text-editor-overlay { padding: 8px; }
    .text-editor-dialog { height: calc(100dvh - 16px); }
    .text-editor-header, .text-editor-footer { padding: 12px; }
    .text-editor-toolbar, .text-editor-statusbar { padding-left: 12px; padding-right: 12px; }
    .text-editor-footer { align-items: stretch; flex-direction: column; gap: 12px; }
    .text-editor-actions { justify-content: flex-end; }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Grid item card hover effects */
.file-card {
    transition: all 0.2s ease-in-out;
}

.file-card:hover {
    border-color: var(--color-border-secondary);
}


/* Image thumbnail overlay */
.thumbnail-overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
}

/* Loading skeleton animation */
@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #f1f5f9 25%,
        #e2e8f0 50%,
        #f1f5f9 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

/* Smooth transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Floating selection action bar：选中态从底部滑入 */
@keyframes floatingBarEnter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

#selectedToolbar:not(.hidden) {
    animation: floatingBarEnter 0.25s ease-out;
}

/* Badge animations */
.badge {
    transition: all 0.15s ease;
}

.badge:hover {
    transform: scale(1.05);
}

/* Button ripple effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
}

/* Sidebar mobile transition */
@media (max-width: 1024px) {
    #sidebar {
        transform: translateX(-100%);
    }
    
    #sidebar.active {
        transform: translateX(0);
    }
}

/* Local folder panel: right sidebar dual-pane */
#openLocalFolderBtn {
    transition: background-color 0.2s ease, color 0.2s ease;
}

#openLocalFolderBtn.active {
    background-color: var(--color-accent-primary) !important;
    border-color: var(--color-accent-primary);
    color: white;
}

/* View-mode button groups: zero-width when hidden, fade with opacity */
#listModeActions {
    width: 0;
    overflow: hidden;
    transition: opacity 0.25s ease;
}

#listModeActions:not(.view-hidden) {
    width: auto;
    overflow: visible;
}

#listModeActions.view-hidden {
    opacity: 0;
    pointer-events: none;
}

/* NSFW toggle button */
#nsfwToggleBtn {
    transition: opacity 0.25s ease, background-color 0.2s ease, color 0.2s ease;
}

#nsfwToggleBtn.active {
    background-color: var(--color-danger) !important;
    border-color: var(--color-danger);
    color: white;
}

/* NSFW blur effect: only on grid media and list thumbnails */
.waterfall-card.nsfw-blur > div:first-child,
.list-row.nsfw-blur .list-thumbnail img {
    filter: blur(25px);
    transition: filter 0.3s ease;
}

/* Video card container */
.video-card-container {
    cursor: pointer;
}

.video-card-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-card-container .video-play-icon {
    transition: opacity 0.2s ease;
}

.video-card-container:hover .video-play-icon {
    opacity: 0.8;
}

#localFolderPanel {
    width: 50vw;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#localFolderPanel.active {
    opacity: 1;
    pointer-events: auto;
}

#localFolderPanel.no-transition {
    transition: none !important;
}

#mainView {
    transition: margin-right 0.3s ease;
}

#mainView.local-panel-active {
    margin-right: 50vw;
}

#mainView.no-transition {
    transition: none !important;
}

/* Local file list table rows */
.local-file-row {
    transition: background-color 0.15s ease;
}

#localFolderBack:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.local-file-row:hover {
    background-color: var(--color-bg-tertiary) !important;
}

.local-file-row[data-kind="dir"] {
    cursor: pointer;
}

.local-file-row[data-kind="file"] {
    cursor: grab;
}

.local-file-row.dragging {
    opacity: 0.5;
}

.local-file-row .local-file-icon {
    flex-shrink: 0;
}

.local-file-row[data-kind="dir"] .local-file-icon {
    color: var(--color-accent-primary);
}

.local-file-row[data-kind="file"] .local-file-icon {
    color: var(--color-text-tertiary);
}

/* File type icons */
.file-type-icon {
    transition: all 0.2s ease;
}

.file-card:hover .file-type-icon {
    transform: scale(1.1);
}

/* Progress bar animation */
@keyframes progress-bar {
    from {
        width: 0%;
    }
    to {
        width: 100%;
    }
}

.progress-animate {
    animation: progress-bar 0.3s ease-out;
}

/* Table row hover */
.table-row-hover {
    transition: background-color 0.15s ease;
}

.table-row-hover:hover {
    background-color: #f8fafc;
}

/* Checkbox custom style */
input[type="checkbox"]:checked {
    background-color: #3B82F6;
    border-color: #3B82F6;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem;
    background: #1e293b;
    color: white;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

.tooltip:hover::after {
    opacity: 1;
    bottom: calc(100% + 5px);
}

/* Image zoom on hover */
.zoom-image {
    transition: transform 0.3s ease;
}

.zoom-image:hover {
    transform: scale(1.05);
}

/* Loading spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    animation: spin 1s linear infinite;
}

/* Drag and drop zone */
.drag-active {
    border-color: #3B82F6;
    background-color: rgba(59, 130, 246, 0.1);
}

/* Responsive utilities */
@media (max-width: 640px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 641px) and (max-width: 768px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1025px) and (max-width: 1280px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (min-width: 1281px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

/* Tag badges in list view */
.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 500;
    background-color: var(--color-accent-muted, rgba(14, 165, 233, 0.1));
    color: var(--color-accent-primary, #0ea5e9);
    cursor: default;
    transition: all 0.15s ease;
    position: relative;
    max-width: 120px;
}

.tag-badge-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-badge .tag-delete-btn {
    display: none;
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background-color: var(--color-danger, #ef4444);
    color: white;
    cursor: pointer;
    padding: 0;
    line-height: 0;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.1s ease;
}

.tag-badge:hover .tag-delete-btn {
    display: inline-flex;
}

.tag-badge .tag-delete-btn:hover {
    transform: scale(1.15);
}

/* Add tag button */
.tag-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px dashed var(--color-border-secondary, #cbd5e1);
    background: transparent;
    color: var(--color-text-tertiary, #94a3b8);
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.tag-add-btn:hover {
    border-color: var(--color-accent-primary, #0ea5e9);
    color: var(--color-accent-primary, #0ea5e9);
    background-color: var(--color-accent-muted, rgba(14, 165, 233, 0.08));
}

/* Inline tag input */
.tag-input-inline {
    display: inline-flex;
    align-items: center;
}

.tag-input-field {
    width: 80px;
    padding: 2px 6px;
    border: 1px solid var(--color-accent-primary, #0ea5e9);
    border-radius: 9999px;
    font-size: 12px;
    line-height: 1.4;
    outline: none;
    background-color: var(--color-bg-secondary, #fff);
    color: var(--color-text-primary, #1e293b);
    transition: width 0.15s ease;
}

.tag-input-field:focus {
    width: 100px;
}

/* Reserve column width so the inline tag input doesn't trigger a layout shift */
.tag-col {
    min-width: 150px;
}

/* Hide tag column when local folder panel is active */
#mainView.local-panel-active .tag-col,
#mainView.local-panel-active .created-col {
    display: none;
}

/* Bookmark button states */
#localFolderBookmark:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

#localFolderBookmark.active {
    color: var(--color-accent-primary);
}

#localFolderBookmark.active svg {
    fill: var(--color-accent-primary);
    stroke: var(--color-accent-primary);
}

#localFolderPreviewToggle.active {
    color: var(--color-accent-primary);
}

#localFolderPreviewToggle.active svg {
    stroke: var(--color-accent-primary);
}

/* Waterfall card tag badges */
.waterfall-tag-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 9999px;
    font-size: 10px;
    line-height: 1.5;
    font-weight: 500;
    background-color: var(--color-accent-muted, rgba(14, 165, 233, 0.1));
    color: var(--color-accent-primary, #0ea5e9);
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Print styles */
@media print {
    aside, header, .no-print {
        display: none !important;
    }
    
    main {
        margin: 0 !important;
    }
}

/* Waterfall layout styles */
.waterfall-card {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Ensure waterfall items maintain order */
#waterfallContainer > * {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Waterfall card fade-in animation */
.fade-in-card {
    animation: fadeInCard 0.4s ease forwards;
    opacity: 0;
}

@keyframes fadeInCard {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
