/* Dashboard Settings & Profile Dialog */
.dashboard-dialog {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, .5);
    backdrop-filter: blur(5px);
}

.dashboard-dialog.is-open {
    display: flex;
}

.dashboard-dialog-content {
    position: relative;
    width: min(100%, 420px);
    padding: 1.35rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.dashboard-dialog-content.has-settings-sidebar {
    display: flex;
    width: min(780px, calc(100vw - 2rem));
    height: min(600px, calc(100dvh - 2rem));
    flex-direction: column;
    overflow: hidden;
}

.dashboard-dialog-content.has-settings-sidebar #dashboardDialogBody {
    flex: 1;
    min-height: 0;
}

.dashboard-dialog-content h2 {
    margin: 0 0 .8rem;
    font-size: 1.1rem;
}

.dashboard-dialog-close {
    position: absolute;
    top: .75rem;
    right: .75rem;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
}

.dashboard-profile-list {
    display: grid;
    gap: .55rem;
    margin: 0;
}

.dashboard-profile-list div {
    display: grid;
    gap: .15rem;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-soft);
}

.dashboard-profile-list dt {
    color: var(--muted);
    font-size: .74rem;
    font-weight: 800;
}

.dashboard-profile-list dd {
    margin: 0;
    color: var(--text);
    font-size: .84rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.dashboard-dialog-message {
    margin: 0;
    color: var(--muted);
    font-size: .84rem;
    line-height: 1.55;
}

.dashboard-password-form {
    display: grid;
    gap: .7rem;
}

.dashboard-password-form label {
    display: grid;
    gap: .3rem;
    color: var(--muted);
    font-size: .76rem;
    font-weight: 700;
}

.dashboard-password-form input {
    width: 100%;
    min-height: 40px;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    background: var(--bg);
    font: inherit;
    font-size: .84rem;
}

.dashboard-password-form input:focus {
    border-color: var(--accent);
    outline: 2px solid color-mix(in srgb, var(--accent) 20%, transparent);
}

.dashboard-password-submit {
    width: 100%;
}

.dashboard-password-status {
    min-height: 1.1rem;
    margin: 0;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.45;
}

.dashboard-password-status.is-error {
    color: var(--danger);
}

.dashboard-password-status.is-success {
    color: #23734c;
}

:root[data-dashboard-theme="dark"] .dashboard-password-status.is-success {
    color: #8bd3a9;
}

.dashboard-settings-layout {
    display: grid;
    width: 100%;
    height: 100%;
    min-height: 0;
    grid-template-columns: 190px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.dashboard-settings-nav {
    display: grid;
    align-content: start;
    gap: .3rem;
    overflow-y: auto;
    padding: .65rem;
    border-right: 1px solid var(--border);
    background: var(--surface-soft);
}

.dashboard-settings-nav button {
    display: flex;
    min-height: 40px;
    align-items: center;
    padding: .55rem .65rem;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    background: transparent;
    font: inherit;
    font-size: .8rem;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.dashboard-settings-nav button:hover,
.dashboard-settings-nav button[aria-current="page"] {
    color: var(--text);
    border-color: var(--border);
    background: var(--surface);
}

.dashboard-settings-nav button[aria-current="page"] {
    box-shadow: 0 3px 10px rgba(25, 25, 25, .05);
}

.dashboard-settings-panel {
    min-width: 0;
    overflow: auto;
    padding: 1rem;
    overscroll-behavior: contain;
}

.dashboard-settings-panel h3 {
    margin: 0 0 .85rem;
    color: var(--text);
    font-size: 1rem;
}

.dashboard-theme-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .7rem;
}

.dashboard-theme-option {
    display: grid;
    gap: .35rem;
    min-height: 100px;
    justify-items: start;
    padding: .85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    background: var(--surface-soft);
    text-align: left;
    cursor: pointer;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.dashboard-theme-option:hover {
    border-color: var(--accent);
}

.dashboard-theme-option[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}

.dashboard-theme-option strong {
    font-size: .9rem;
}

.dashboard-theme-option small {
    color: var(--muted);
    font-size: .74rem;
    line-height: 1.4;
}

.dashboard-theme-option-icon {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 9px;
    color: var(--accent);
    background: var(--bg);
    font-size: .95rem;
}

.dashboard-theme-status {
    min-height: 1.1rem;
    margin: .65rem 0 0;
    color: var(--muted);
    font-size: .76rem;
}

/* Share Modal */
.share-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(6px);
}

.share-modal.is-open {
    display: flex;
}

.share-dialog {
    position: relative;
    width: min(100%, 460px);
    padding: 1.4rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.share-dialog h2 {
    margin: 0 0 0.45rem;
    font-size: 1.15rem;
}

.share-dialog p {
    margin: 0 0 1rem;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.share-close {
    position: absolute;
    top: 0.8rem;
    right: 0.8rem;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text);
    background: var(--surface-soft);
    cursor: pointer;
}

.share-choice {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.9rem;
}

.share-choice .button {
    flex: 1;
}

.share-code-form {
    display: none;
    gap: 0.45rem;
    margin-bottom: 0.8rem;
}

.share-code-form.is-visible {
    display: flex;
}

.share-code-form input,
.share-url {
    min-width: 0;
    width: 100%;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    background: var(--bg);
    font: inherit;
    font-size: 0.8rem;
    outline: none;
}

.share-code-form input:focus,
.share-url:focus {
    border-color: var(--accent);
}

.share-code-form .button {
    flex: 0 0 auto;
}

.share-message {
    min-height: 1.2rem;
    margin: 0 0 0.6rem !important;
    color: var(--accent) !important;
}

.share-result {
    display: none;
    gap: 0.5rem;
}

.share-result.is-visible {
    display: flex;
}

.share-result .button {
    flex: 0 0 auto;
}

/* Quick Filter Modal */
.quick-filter-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 20;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(6px);
}

.quick-filter-modal.is-open {
    display: flex;
}

.quick-filter-dialog {
    width: min(100%, 620px);
    max-height: 90dvh;
    overflow-y: auto;
    padding: 1.4rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.quick-filter-dialog h2 {
    margin: 0 0 0.45rem;
    font-size: 1.15rem;
}

.quick-filter-desc,
.quick-filter-dialog p {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.quick-filter-block {
    margin-top: 0.9rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-soft);
}

.quick-filter-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.quick-filter-block-title {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.84rem;
}

.quick-filter-count {
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 700;
}

.quick-filter-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.45rem;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.quick-filter-row[hidden] {
    display: none;
}

.quick-filter-row-wrap {
    flex-wrap: wrap;
}

.quick-filter-textarea {
    width: 100%;
    min-height: 112px;
    margin-top: 0.6rem;
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    background: var(--bg);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    resize: vertical;
}

.quick-filter-option {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    margin-top: 0.65rem;
    color: var(--text);
    font-size: 0.8rem;
    line-height: 1.45;
    cursor: pointer;
}

.quick-filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 1px;
    flex-shrink: 0;
    accent-color: var(--accent);
}

.quick-filter-subfolder-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.55rem;
}

.quick-filter-subfolder-row[hidden] {
    display: none;
}

.quick-filter-subfolder-row label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.quick-filter-subfolder-input {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    background: var(--bg);
    font: inherit;
    font-size: 0.82rem;
}

.quick-filter-name {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.74rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-filter-status {
    min-height: 1.2rem;
    margin: 0.8rem 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.quick-filter-status.is-error {
    color: var(--danger);
}

.quick-filter-missing {
    margin-bottom: 0.8rem;
    padding: 0.75rem;
    border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
    border-radius: 10px;
    background: var(--surface-soft);
    font-size: 0.76rem;
}

.quick-filter-missing pre {
    max-height: 120px;
    overflow: auto;
    margin: 0.45rem 0 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.73rem;
    white-space: pre-wrap;
}

.quick-filter-start-btn {
    width: 100%;
    min-height: 44px;
}

.quick-filter-close {
    float: right;
}

@media (max-width: 600px) {
    .quick-filter-row,
    .quick-filter-subfolder-row {
        flex-direction: column;
        align-items: stretch;
    }

    .quick-filter-name {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

/* Export TXT Modal */
.viewer-export-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 25;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(6px);
}

.viewer-export-modal.is-open {
    display: flex;
}

.viewer-export-dialog {
    width: min(100%, 460px);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    padding: 1.35rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.viewer-export-dialog h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.viewer-export-group {
    display: grid;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.viewer-export-group > label,
.viewer-export-group legend {
    color: var(--text);
    font-size: 0.76rem;
    font-weight: 800;
}

.viewer-export-digits {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
}

.viewer-export-digits label,
.viewer-export-name {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text);
    font-size: 0.76rem;
}

.viewer-export-digits input,
.viewer-export-name input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

.viewer-export-select,
.viewer-export-custom {
    width: 100%;
    min-height: 40px;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    background: var(--surface);
    font: inherit;
    font-size: 0.76rem;
}

.viewer-export-preview {
    max-height: 7rem;
    overflow: auto;
    margin: 0;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: var(--surface-soft);
    font: 0.75rem/1.5 monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.viewer-export-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ZIP Progress Modal */
.viewer-zip-progress {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(6px);
}

.viewer-zip-progress.is-open {
    display: flex;
}

.viewer-zip-progress-dialog {
    width: min(100%, 480px);
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow);
}

:root[data-dashboard-theme="dark"] .viewer-zip-progress-dialog {
    background: var(--surface);
}

.viewer-zip-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.7rem;
}

.viewer-zip-progress-dialog h3 {
    margin: 0;
    font-size: 1.1rem;
}

.viewer-zip-progress-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text);
    background: var(--surface-soft);
    cursor: pointer;
}

.viewer-zip-progress-status {
    min-height: 1.4rem;
    margin: 0 0 0.9rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.viewer-zip-progress-bar {
    position: relative;
    overflow: hidden;
    height: 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
}

.viewer-zip-progress-fill {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #1f1f1f 0%, #4a4a4a 100%);
}

.viewer-zip-progress-percent {
    margin-top: 0.7rem;
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 800;
}

/* Floating Admin Chat Widget */
.admin-chat {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 240;
}

.admin-chat::before {
    content: '';
    position: absolute;
    inset: -9px;
    border: 2px solid rgba(255, 68, 88, .42);
    border-radius: 50%;
    pointer-events: none;
    animation: adminChatRing 2.8s ease-out infinite;
}

@keyframes adminChatRing {
    0%, 58%, 100% {
        opacity: 0;
        transform: scale(.82);
    }
    68% {
        opacity: 1;
        transform: scale(1);
    }
    88% {
        opacity: 0;
        transform: scale(1.28);
    }
}

.admin-chat-toggle {
    position: relative;
    display: flex;
    width: 58px;
    height: 58px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 3px solid rgba(255, 255, 255, .92);
    border-radius: 50%;
    background: linear-gradient(135deg, #d4af37, #f0cb5f);
    color: #fff;
    box-shadow: 0 12px 28px rgba(212, 175, 55, .35);
    font-size: 0;
    cursor: pointer;
    animation: adminChatPulse 2.8s ease-in-out infinite;
}

.admin-chat-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 13px;
    height: 13px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .25);
    animation: adminChatDot 1.8s ease-in-out infinite;
}

@keyframes adminChatDot {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.18);
    }
}

@keyframes adminChatPulse {
    0%, 65%, 100% {
        transform: scale(1);
        box-shadow: 0 12px 28px rgba(212, 175, 55, .35);
    }
    76% {
        transform: scale(1.08);
        box-shadow: 0 0 0 10px rgba(212, 175, 55, .12), 0 16px 32px rgba(212, 175, 55, .48);
    }
}

.admin-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 16px 32px rgba(212, 175, 55, .45);
    animation-play-state: paused;
}

.admin-chat-toggle:hover::after {
    animation-play-state: paused;
}

.admin-chat-mark {
    width: 2.15rem;
    height: 2.15rem;
    flex: 0 0 2rem;
    vertical-align: middle;
}

.admin-chat-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.admin-chat-panel {
    position: absolute;
    right: calc(100% + .75rem);
    bottom: 0;
    width: min(340px, calc(100vw - 5.5rem));
    padding: 1rem;
    border: 1px solid rgba(212, 175, 55, .24);
    border-radius: 16px;
    background: rgba(22, 19, 16, .97);
    color: #f7f3ea;
    box-shadow: 0 24px 48px rgba(0, 0, 0, .32);
    opacity: 0;
    pointer-events: none;
    transform: translateX(8px);
    transition: opacity .2s ease, transform .2s ease;
}

.admin-chat.open .admin-chat-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.admin-chat-panel h3 {
    margin: 0 0 .25rem;
    color: #f7f3ea;
    font-size: 1rem;
}

.admin-chat-panel > p {
    margin: 0 0 .7rem;
    color: #c8c1b4;
    font-size: .76rem;
    line-height: 1.45;
}

.admin-chat-messages {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    max-height: 190px;
    margin-bottom: .7rem;
    overflow-y: auto;
}

.admin-chat-empty {
    color: #c8c1b4;
    font-size: .74rem;
}

.admin-chat-bubble {
    max-width: 88%;
    padding: .5rem .65rem;
    border-radius: 10px;
    color: #f7f3ea;
    background: rgba(255, 255, 255, .1);
    font-size: .76rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.admin-chat-bubble.guest {
    align-self: flex-end;
    color: #fff;
    background: #75601a;
}

.admin-chat-bubble small {
    display: block;
    margin-bottom: .15rem;
    opacity: .7;
    font-size: .64rem;
}

.admin-chat-typing {
    min-height: 1.1rem;
    color: #e8c96b;
    font-size: .72rem;
    font-weight: 700;
}

.admin-chat-typing:not(:empty)::after {
    content: ' ...';
    display: inline-block;
    animation: typingDots 1s steps(3, end) infinite;
}

.admin-chat-panel textarea {
    width: 100%;
    min-height: 82px;
    padding: .7rem;
    border: 1px solid rgba(212, 175, 55, .24);
    border-radius: 10px;
    color: #f7f3ea;
    background: rgba(255, 255, 255, .06);
    font: inherit;
    font-size: .8rem;
    outline: none;
    resize: vertical;
}

.admin-chat-actions {
    display: flex;
    gap: .45rem;
    margin-top: .65rem;
}

.admin-chat-actions button {
    flex: 1;
    min-width: 0;
    min-height: 40px;
    padding: .6rem .45rem;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 9px;
    font: inherit;
    font-size: .72rem;
    font-weight: 800;
    cursor: pointer;
}

.admin-chat-report-toggle {
    color: #f7f3ea;
    background: rgba(255, 255, 255, .08);
}

.admin-chat-report-toggle.is-active {
    border-color: #dc2626;
    color: #fff;
    background: #b42318;
}

.admin-chat-submit {
    color: #211b0c;
    background: linear-gradient(135deg, #d4af37, #f0cb5f);
}

.admin-chat-actions button:disabled {
    cursor: wait;
    opacity: .65;
}

.admin-chat-message {
    min-height: 1.2rem;
    margin-top: .5rem;
    color: #c8c1b4;
    font-size: .72rem;
}

@keyframes typingDots {
    0%, 20% {
        opacity: .25;
    }
    50% {
        opacity: 1;
    }
    80%, 100% {
        opacity: .45;
    }
}
