/* ============================================================
   Attachments — at-* classes
   ============================================================ */

/* ── Section ─────────────────────────────────────────────────────────────── */

.at-section { margin-top: 0; }

.at-count {
    font-weight: 400;
    color: #aaa;
    font-size: 12px;
    margin-left: 4px;
}

/* ── Storage unavailable banner ──────────────────────────────────────────── */

.at-unavailable {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    font-size: 12.5px;
    color: #856404;
    margin-bottom: 12px;
}

/* ── Drop zone ───────────────────────────────────────────────────────────── */

.at-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 20px;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    margin-bottom: 8px;
    text-align: center;
}

.at-dropzone:hover,
.at-dropzone-hover { border-color: #2d7dd2; background: #f0f7ff; }

.at-dropzone-uploading { opacity: 0.6; pointer-events: none; }
.at-dropzone-disabled  { opacity: 0.5; pointer-events: none; cursor: default; }

.at-dropzone-icon { font-size: 24px; color: #9ca3af; }
.at-dropzone-text { font-size: 13px; font-weight: 600; color: #374151; }
.at-dropzone-hint { font-size: 11px; color: #9ca3af; }

/* ── Progress bar ────────────────────────────────────────────────────────── */

.at-progress-wrap {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.at-progress-bar {
    height: 100%;
    background: #2d7dd2;
    border-radius: 2px;
    transition: width 0.2s ease;
    width: 0%;
}

/* ── Error message ───────────────────────────────────────────────────────── */

.at-upload-error {
    font-size: 12px;
    color: #dc3545;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: #fff5f5;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
}

/* ── File list ───────────────────────────────────────────────────────────── */

.at-empty {
    font-size: 12.5px;
    color: #9ca3af;
    padding: 10px 0 4px;
}

.at-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    transition: opacity 0.3s;
}

.at-item:last-child { border-bottom: none; }
.at-item-removing   { opacity: 0; }
.at-item-new        { animation: atFadeIn 0.25s ease; }

@keyframes atFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Icon */
.at-item-icon { font-size: 20px; flex-shrink: 0; }
.at-icon-pdf  { color: #dc3545; }
.at-icon-img  { color: #2d7dd2; }
.at-icon-gif  { color: #6f42c1; }

/* Info */
.at-item-info { flex: 1; min-width: 0; }

.at-item-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1a3a5c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.at-item-name:hover { text-decoration: underline; }

.at-item-meta {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 1px;
}

.at-version-badge {
    display: inline-block;
    margin-left: 5px;
    padding: 0 5px;
    background: #e0f0ff;
    color: #1a5fa8;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}

/* Action buttons */
.at-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.at-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.1s, color 0.1s;
    text-decoration: none;
    color: #6b7280;
}

.at-btn:hover          { background: #f3f4f6; color: #111; }
.at-btn-delete:hover   { background: #fee2e2; color: #dc3545; }

/* ── Delete confirm modal ────────────────────────────────────────────────── */

.at-confirm-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.at-confirm-backdrop.at-confirm-visible {
    opacity: 1;
    pointer-events: auto;
}

.at-confirm-backdrop .cm-dialog {
    transform: scale(0.92) translateY(8px);
    transition: transform 0.18s ease, opacity 0.18s ease;
    opacity: 0;
}

.at-confirm-backdrop.at-confirm-visible .cm-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ── Attachment viewer ────────────────────────────────────────────────────── */

.at-no-scroll { overflow: hidden; }

.at-viewer {
    position: fixed;
    inset: 0;
    z-index: 9990;
    background: rgba(10,10,18,0.96);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.at-viewer.at-viewer-open {
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.at-viewer-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    min-height: 56px;
}

.at-viewer-close {
    width: 36px; height: 36px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.08);
    color: #ccc;
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.at-viewer-close:hover { background: rgba(255,255,255,0.16); color: #fff; }

.at-viewer-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.at-viewer-filename {
    font-size: 14px;
    font-weight: 600;
    color: #e8e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.at-viewer-vbadge {
    background: #1a2d4a;
    color: #7ab4e8;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    flex-shrink: 0;
}

.at-viewer-counter {
    font-size: 11.5px;
    color: #666;
    flex-shrink: 0;
    margin-left: 4px;
}

.at-viewer-meta {
    font-size: 11.5px;
    color: #555;
    flex-shrink: 0;
    white-space: nowrap;
}

.at-viewer-hactions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.at-viewer-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 7px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: #ccc;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.at-viewer-action-btn:hover      { background: rgba(255,255,255,0.14); color: #fff; border-color: rgba(255,255,255,0.22); }
.at-viewer-delete-btn:hover      { background: rgba(220,53,69,0.2); color: #f87171; border-color: rgba(220,53,69,0.35); }

.at-viewer-btn-label {
    font-size: 12px;
}

/* Body */
.at-viewer-body {
    display: flex;
    align-items: center;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.at-viewer-frame {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.at-viewer-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.at-viewer-pdf {
    width: 100%;
    height: 100%;
    border: none;
}

.at-viewer-loading {
    color: #444;
    font-size: 28px;
}

@keyframes atSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.at-spin { animation: atSpin 0.9s linear infinite; display: inline-block; }

/* Nav arrows */
.at-viewer-nav {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.08);
    color: #ccc;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin: 0 12px;
    transition: background 0.15s, color 0.15s;
    z-index: 1;
}
.at-viewer-nav:hover:not(:disabled) { background: rgba(255,255,255,0.18); color: #fff; }
.at-viewer-nav:disabled { opacity: 0.2; cursor: default; }

/* Thumbnail strip */
.at-viewer-strip {
    flex-shrink: 0;
    padding: 10px 16px;
    gap: 8px;
    background: rgba(0,0,0,0.5);
    border-top: 1px solid rgba(255,255,255,0.07);
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: thin;
    scrollbar-color: #333 transparent;
    max-height: 110px;
}

.at-viewer-strip::-webkit-scrollbar { height: 4px; }
.at-viewer-strip::-webkit-scrollbar-track { background: transparent; }
.at-viewer-strip::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

.at-viewer-thumb {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, opacity 0.15s;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.at-viewer-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
}

.at-viewer-thumb-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px;
    font-size: 10px;
    color: #888;
    text-align: center;
    width: 100%;
}

.at-viewer-thumb-icon i { font-size: 22px; }

.at-viewer-thumb:hover  { opacity: 0.85; border-color: rgba(255,255,255,0.25); }
.at-thumb-active        { border-color: #2d7dd2 !important; }

/* Make row items clickable */
.at-item { cursor: pointer; }
.at-item:hover .at-item-name { text-decoration: underline; }
.at-item-name { text-decoration: none; color: #1a3a5c; }

/* ── Dark mode ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .at-unavailable {
    background: #2d2500;
    border-color: #7a5c00;
    color: #ffd95a;
}

[data-theme="dark"] .at-dropzone {
    border-color: #2e2e4a;
}

[data-theme="dark"] .at-dropzone:hover,
[data-theme="dark"] .at-dropzone-hover {
    border-color: #4a8fd4;
    background: #141428;
}

[data-theme="dark"] .at-dropzone-icon  { color: #555570; }
[data-theme="dark"] .at-dropzone-text  { color: #c0c0d8; }
[data-theme="dark"] .at-dropzone-hint  { color: #555570; }

[data-theme="dark"] .at-progress-wrap  { background: #2e2e4a; }
[data-theme="dark"] .at-progress-bar   { background: #4a8fd4; }

[data-theme="dark"] .at-upload-error {
    background: #2a0a0a;
    border-color: #7a2020;
    color: #f87171;
}

[data-theme="dark"] .at-item          { border-color: #1e1e35; }
[data-theme="dark"] .at-empty         { color: #555570; }
[data-theme="dark"] .at-item-name     { color: #90c4f8; }
[data-theme="dark"] .at-item-meta     { color: #555570; }
[data-theme="dark"] .at-version-badge { background: #1a2d4a; color: #7ab4e8; }

[data-theme="dark"] .at-btn           { color: #666688; }
[data-theme="dark"] .at-btn:hover     { background: #252535; color: #c0c0d8; }
[data-theme="dark"] .at-btn-delete:hover { background: #2a1010; color: #f87171; }

[data-theme="dark"] .at-confirm-backdrop .cm-dialog { background: #1e1e2e; box-shadow: 0 24px 60px rgba(0,0,0,0.5); }
[data-theme="dark"] .at-confirm-backdrop .cm-title   { color: #e0e0e8; }
[data-theme="dark"] .at-confirm-backdrop .cm-message { color: #888; }
[data-theme="dark"] .at-confirm-backdrop .cm-btn-cancel { background: #1e1e2e; border-color: #3a3a5a; color: #aaa; }
[data-theme="dark"] .at-confirm-backdrop .cm-btn-cancel:hover { background: #2a2a3e; }
[data-theme="dark"] .at-confirm-backdrop .cm-icon    { background: #3a1a1a; }

[data-theme="dark"] .at-item-name { color: #90c4f8; }
