/* ===================================================
   Smart Document Manager Pro — Frontend Styles v2.3
=================================================== */

body.sdm-no-scroll { overflow: hidden; }

/* ── Wrapper & Grid ── */
.sdm-wrap { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.sdm-heading { font-size: 22px; font-weight: 700; margin-bottom: 20px; color: #1e293b; }

.sdm-cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sdm-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 768px) {
    .sdm-cols-2, .sdm-cols-3 { grid-template-columns: 1fr; }
}

/* ── TOP-LEVEL Folder Card ── */
.sdm-folder {
    border-radius: 12px;
    margin-bottom: 18px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.07);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.sdm-folder-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    cursor: pointer;
    user-select: none;
    transition: background .2s;
}
.sdm-folder-header:hover  { background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.sdm-folder-header:focus  { outline: 3px solid #818cf8; outline-offset: -3px; }

.sdm-folder-icon { font-size: 20px; flex-shrink: 0; }
.sdm-folder-name { flex: 1; font-weight: 600; font-size: 15px; }
.sdm-folder-count {
    font-size: 12px;
    background: rgba(255,255,255,.15);
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

/* Chevron animation */
.sdm-chevron { font-size: 18px; transition: transform .28s; display: inline-block; }
.sdm-folder.sdm-open  > .sdm-folder-header  .sdm-chevron,
.sdm-subfolder.sdm-open > .sdm-subfolder-header .sdm-chevron { transform: rotate(180deg); }

/* Folder / subfolder bodies hidden by default in accordion mode */
.sdm-folder.sdm-accordion    > .sdm-folder-body    { display: none; }
.sdm-subfolder.sdm-accordion  > .sdm-subfolder-body { display: none; }
.sdm-folder.sdm-open          > .sdm-folder-body    { display: block; }
.sdm-subfolder.sdm-open       > .sdm-subfolder-body { display: block; }

.sdm-folder-body   { padding: 0; }
.sdm-subfolder-body { padding: 0; }

/* ── SUB-FOLDER (nested inside parent) ── */
.sdm-subfolder {
    margin: 12px 16px 4px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.sdm-subfolder:last-child { margin-bottom: 16px; }

.sdm-subfolder-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f1f5f9;
    color: #334155;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}
.sdm-subfolder-header:hover { background: #e2e8f0; }
.sdm-subfolder-header:focus { outline: 2px solid #818cf8; outline-offset: -2px; }
.sdm-subfolder-header .sdm-folder-name { flex: 1; }
.sdm-subfolder-header .sdm-folder-count {
    font-size: 11px;
    background: rgba(0,0,0,.08);
    color: #475569;
    padding: 2px 8px;
    border-radius: 20px;
}

/* ── Table ── */
.sdm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.sdm-table thead tr {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}
.sdm-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #64748b;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.sdm-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.sdm-doc-row:hover td { background: #fafbff; }
.sdm-doc-row:last-child td { border-bottom: none; }

.sdm-th-name   { width: auto; }
.sdm-th-date   { width: 120px; }
.sdm-th-action { width: 190px; text-align: right; }
.sdm-td-action { text-align: right; white-space: nowrap; }
.sdm-td-name   { vertical-align: middle; }

/* Doc name cell */
.sdm-doc-name-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.sdm-doc-icon      { font-size: 18px; flex-shrink: 0; }
.sdm-doc-title     { font-weight: 500; color: #1e293b; text-decoration: none; }
a.sdm-doc-title    { color: #2563eb; }
a.sdm-doc-title:hover { text-decoration: underline; color: #1d4ed8; }
.sdm-badge {
    display: inline-block; font-size: 11px; padding: 2px 8px;
    background: #eff6ff; color: #2563eb; border-radius: 12px;
    border: 1px solid #bfdbfe; font-weight: 500; margin-left: 6px; flex-shrink: 0;
}

/* ── Buttons ── */
.sdm-btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: 6px; font-size: 12px;
    font-weight: 500; cursor: pointer; text-decoration: none;
    border: 1px solid transparent; transition: all .15s;
    line-height: 1; white-space: nowrap;
}
.sdm-btn + .sdm-btn { margin-left: 4px; }
.sdm-btn-sm { padding: 4px 9px; font-size: 11px; }

.sdm-btn-preview  { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.sdm-btn-preview:hover  { background: #dbeafe; }
.sdm-btn-download { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.sdm-btn-download:hover { background: #dcfce7; }
.sdm-btn-toggle   { background: #faf5ff; border-color: #e9d5ff; color: #7c3aed; }
.sdm-btn-toggle:hover { background: #f3e8ff; }

.sdm-no-file { color: #94a3b8; font-size: 12px; }

/* ── Multi-file sub-list ── */
.sdm-subfiles-row td { background: #f8fafc; padding: 8px 16px 14px; }
.sdm-subfiles-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sdm-subfiles-list li {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; background: #fff;
    border: 1px solid #e2e8f0; border-radius: 6px; font-size: 13px;
}
.sdm-sub-name    { flex: 1; color: #334155; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdm-sub-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Empty state ── */
.sdm-empty { padding: 14px 20px; color: #94a3b8; font-size: 13px; font-style: italic; }

/* ── Preview Modal ── */
.sdm-modal { position: fixed; inset: 0; z-index: 99999; display: flex; align-items: center; justify-content: center; }
.sdm-modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(3px);
}
.sdm-modal-box {
    position: relative; z-index: 1;
    background: #fff; border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0,0,0,.3);
    width: 92vw; max-width: 900px;
    max-height: 92vh; display: flex; flex-direction: column; overflow: hidden;
}
.sdm-modal-header {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; border-bottom: 1px solid #e2e8f0;
    background: #f8fafc; flex-shrink: 0;
}
.sdm-modal-title {
    flex: 1; font-weight: 600; font-size: 14px; color: #1e293b;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sdm-modal-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.sdm-modal-close {
    width: 32px; height: 32px; border-radius: 50%;
    border: none; background: #fee2e2; color: #dc2626;
    font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.sdm-modal-close:hover { background: #fecaca; }
.sdm-modal-body {
    flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center;
    min-height: 300px; background: #f1f5f9;
}
.sdm-modal-body iframe { width: 100%; height: 75vh; border: none; }
.sdm-modal-body img   { max-width: 100%; max-height: 75vh; object-fit: contain; border-radius: 4px; }
