/* DocWin public styles — Professional Design v2 */
:root {
    --docwin-primary: #2563eb;
    --docwin-primary-dark: #1d4ed8;
    --docwin-primary-soft: rgba(37, 99, 235, 0.12);
    --docwin-bg: #ffffff;
    --docwin-bg-light: #f8fafc;
    --docwin-bg-lighter: #f1f5f9;
    --docwin-border: #e2e8f0;
    --docwin-border-dark: #cbd5e1;
    --docwin-text: #0f172a;
    --docwin-text-light: #475569;
    --docwin-text-muted: #94a3b8;
    --docwin-accent-green: #059669;
    --docwin-accent-amber: #d97706;
    --docwin-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
    --docwin-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --docwin-shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    --docwin-radius: 10px;
    --docwin-radius-sm: 6px;
    --docwin-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --docwin-bg: #0f172a;
        --docwin-bg-light: #1e293b;
        --docwin-bg-lighter: #334155;
        --docwin-border: #334155;
        --docwin-border-dark: #475569;
        --docwin-text: #f1f5f9;
        --docwin-text-light: #cbd5e1;
        --docwin-text-muted: #94a3b8;
        --docwin-primary-soft: rgba(96, 165, 250, 0.18);
    }
}

/* Wrap */
.docwin-wrap {
    margin: 2rem 0;
    font-family: 'Segoe UI Variable', 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
    color: var(--docwin-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Title */
.docwin-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 1.5rem;
    color: var(--docwin-text);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.01em;
}
.docwin-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.25rem;
    background: linear-gradient(180deg, var(--docwin-primary), var(--docwin-primary-dark));
    border-radius: 2px;
}

/* ======================= SEARCH BAR ======================= */
.docwin-search-container {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--docwin-bg);
    padding: 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.docwin-search-container.docwin-stuck {
    border-bottom-color: var(--docwin-border);
    box-shadow: 0 4px 6px -4px rgba(15, 23, 42, 0.1);
}

.docwin-search-box {
    position: relative;
    max-width: 600px;
}

.docwin-wrap .docwin-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px !important;
    height: 20px !important;
    color: var(--docwin-text-muted);
    pointer-events: none;
    z-index: 1;
    max-width: none;
}

.docwin-wrap .docwin-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 44px 12px 44px;
    border: 1.5px solid var(--docwin-border);
    border-radius: var(--docwin-radius);
    background: var(--docwin-bg);
    color: var(--docwin-text);
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.4;
    margin: 0;
    transition: var(--docwin-transition);
}
.docwin-search-input::placeholder { color: var(--docwin-text-muted); }
.docwin-search-input:focus {
    outline: none;
    border-color: var(--docwin-primary);
    box-shadow: 0 0 0 4px var(--docwin-primary-soft);
}

.docwin-wrap .docwin-search-clear {
    box-sizing: border-box;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 0;
    padding: 0;
    margin: 0;
    line-height: 0;
    background: var(--docwin-bg-lighter);
    color: var(--docwin-text-light);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: none;
    transition: var(--docwin-transition);
}
.docwin-wrap .docwin-search-clear svg {
    width: 14px !important;
    height: 14px !important;
    display: block;
    flex-shrink: 0;
    max-width: none;
}
.docwin-search-clear:hover { background: var(--docwin-border-dark); color: var(--docwin-text); }
.docwin-search-clear.docwin-visible { display: inline-flex; }

/* ======================= GROUPS (YEAR/MONTH) ======================= */
.docwin-groups { display: flex; flex-direction: column; gap: 10px; }

.docwin-group {
    border: 1px solid var(--docwin-border);
    border-radius: var(--docwin-radius);
    background: var(--docwin-bg);
    overflow: hidden;
    transition: var(--docwin-transition);
}
.docwin-group:hover { border-color: var(--docwin-border-dark); }
.docwin-group.docwin-group-current {
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 0 0 3px var(--docwin-primary-soft);
}

.docwin-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(180deg, var(--docwin-bg-light), var(--docwin-bg));
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid transparent;
    transition: var(--docwin-transition);
}
.docwin-group-header:hover {
    background: linear-gradient(180deg, var(--docwin-bg-lighter), var(--docwin-bg-light));
}
.docwin-group-header[aria-expanded="true"] {
    border-bottom-color: var(--docwin-border);
}
.docwin-group-header:focus-visible {
    outline: 2px solid var(--docwin-primary);
    outline-offset: -2px;
}

.docwin-group-chevron {
    width: 16px; height: 16px;
    color: var(--docwin-text-light);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}
.docwin-group-header[aria-expanded="true"] .docwin-group-chevron {
    transform: rotate(90deg);
}

/* Folder glyph — Windows 11 Fluent (two-plane: back tab + front face, with highlight) */
.docwin-group-icon {
    width: 28px;
    height: 23px;
    flex-shrink: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.18));
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'><defs><linearGradient id='a' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%2366B8E6'/><stop offset='1' stop-color='%232989C8'/></linearGradient><linearGradient id='b' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%234CAEE0'/><stop offset='1' stop-color='%230F70C5'/></linearGradient></defs><path d='M1 4 a1.5 1.5 0 0 1 1.5 -1.5 h6 l2 2 h12 a1.5 1.5 0 0 1 1.5 1.5 v12 a1.5 1.5 0 0 1 -1.5 1.5 h-20 a1.5 1.5 0 0 1 -1.5 -1.5 z' fill='url(%23a)'/><path d='M1 7 h22 v10.5 a1.5 1.5 0 0 1 -1.5 1.5 h-19 a1.5 1.5 0 0 1 -1.5 -1.5 z' fill='url(%23b)'/><rect x='1' y='7' width='22' height='0.7' fill='%23ffffff' opacity='0.55'/></svg>");
}
/* Red variant — sub-folders (level 1) */
.docwin-group-icon-red {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'><defs><linearGradient id='a' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23F08E8E'/><stop offset='1' stop-color='%23C83C3C'/></linearGradient><linearGradient id='b' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23E86E6E'/><stop offset='1' stop-color='%23A81F1F'/></linearGradient></defs><path d='M1 4 a1.5 1.5 0 0 1 1.5 -1.5 h6 l2 2 h12 a1.5 1.5 0 0 1 1.5 1.5 v12 a1.5 1.5 0 0 1 -1.5 1.5 h-20 a1.5 1.5 0 0 1 -1.5 -1.5 z' fill='url(%23a)'/><path d='M1 7 h22 v10.5 a1.5 1.5 0 0 1 -1.5 1.5 h-19 a1.5 1.5 0 0 1 -1.5 -1.5 z' fill='url(%23b)'/><rect x='1' y='7' width='22' height='0.7' fill='%23ffffff' opacity='0.55'/></svg>");
}
/* Orange variant — deeper levels (2+) */
.docwin-group-icon-orange {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 20'><defs><linearGradient id='a' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23FFC878'/><stop offset='1' stop-color='%23F5901F'/></linearGradient><linearGradient id='b' x1='0' y1='0' x2='0' y2='1'><stop offset='0' stop-color='%23FFB356'/><stop offset='1' stop-color='%23D6710C'/></linearGradient></defs><path d='M1 4 a1.5 1.5 0 0 1 1.5 -1.5 h6 l2 2 h12 a1.5 1.5 0 0 1 1.5 1.5 v12 a1.5 1.5 0 0 1 -1.5 1.5 h-20 a1.5 1.5 0 0 1 -1.5 -1.5 z' fill='url(%23a)'/><path d='M1 7 h22 v10.5 a1.5 1.5 0 0 1 -1.5 1.5 h-19 a1.5 1.5 0 0 1 -1.5 -1.5 z' fill='url(%23b)'/><rect x='1' y='7' width='22' height='0.7' fill='%23ffffff' opacity='0.55'/></svg>");
}

.docwin-group-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--docwin-text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.005em;
}

/* Badges */
.docwin-badge-current {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: white;
    background: linear-gradient(135deg, var(--docwin-accent-green), #10b981);
    border-radius: 999px;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.3);
}

.docwin-badge-new {
    display: inline-block;
    padding: 1px 7px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: white;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-radius: 999px;
    text-transform: uppercase;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(217, 119, 6, 0.3);
}

.docwin-group-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--docwin-primary);
    background: var(--docwin-primary-soft);
    padding: 3px 10px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.docwin-group-body { padding: 0; }
.docwin-group-body > .docwin-groups { padding: 10px; }

/* ======================= TABLE & ROWS ======================= */
.docwin-table {
    width: 100%;
    background: var(--docwin-bg);
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--docwin-radius);
    overflow: hidden;
    border: 1px solid var(--docwin-border);
}
.docwin-group .docwin-table {
    border: 0;
    border-radius: 0;
}
/* Files placed next to subfolders: shown below the subfolders */
.docwin-wrap > .docwin-groups + .docwin-table { margin-top: 10px; }
.docwin-group-body > .docwin-groups + .docwin-table { border-top: 1px solid var(--docwin-border); }

.docwin-document-item {
    transition: background-color 0.15s ease;
    border-bottom: 1px solid var(--docwin-bg-lighter);
    animation: docwin-row-in 0.35s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}
.docwin-document-item:last-child { border-bottom: 0; }
.docwin-document-item:hover { background-color: var(--docwin-bg-light); }

@keyframes docwin-row-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.docwin-document-item:nth-child(1)  { animation-delay: 0.02s; }
.docwin-document-item:nth-child(2)  { animation-delay: 0.04s; }
.docwin-document-item:nth-child(3)  { animation-delay: 0.06s; }
.docwin-document-item:nth-child(4)  { animation-delay: 0.08s; }
.docwin-document-item:nth-child(5)  { animation-delay: 0.10s; }
.docwin-document-item:nth-child(6)  { animation-delay: 0.12s; }
.docwin-document-item:nth-child(7)  { animation-delay: 0.14s; }
.docwin-document-item:nth-child(n+8){ animation-delay: 0.16s; }

.docwin-content-cell {
    padding: 14px 18px;
    border: none;
    vertical-align: middle;
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ======================= DOCUMENT ICON (PROFESSIONAL) ======================= */
/*
 * Each icon is an inline SVG shaped like a real document with a folded corner
 * and a colored label band that carries the extension (PDF, DOCX, XLSX...).
 * The color is driven by the `color` CSS var via `currentColor` in the SVG.
 */
.docwin-document-icon {
    width: 46px;
    height: 58px;
    flex-shrink: 0;
    display: inline-block;
    color: #64748b;
    filter: drop-shadow(0 3px 5px rgba(15, 23, 42, 0.22));
    transition: filter 0.2s ease, transform 0.2s ease;
}
.docwin-document-icon svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
    overflow: visible;
    max-width: none;
}
.docwin-document-item:hover .docwin-document-icon {
    filter: drop-shadow(0 6px 12px rgba(15, 23, 42, 0.28));
    transform: translateY(-1px) scale(1.05);
}

/* Per-type color (Office / Windows 11 official tones) */
.docwin-file-pdf        { color: #d83b01; }
.docwin-file-word       { color: #185ABD; }
.docwin-file-excel      { color: #107C41; }
.docwin-file-powerpoint { color: #C43E1C; }
.docwin-file-archive    { color: #6B4E3D; }
.docwin-file-text       { color: #4B5563; }
.docwin-file-generic    { color: #5E5E5E; }

/* Document body — clean Win11 white paper with thin outline */
.docwin-document-icon .docwin-doc-body {
    fill: #ffffff;
    stroke: #d1d5db;
    stroke-width: 0.5;
}
.docwin-document-icon .docwin-doc-fold { fill: #e5e7eb; stroke: #d1d5db; stroke-width: 0.5; }
.docwin-document-icon .docwin-doc-line { fill: #e5e7eb; }
@media (prefers-color-scheme: dark) {
    .docwin-document-icon .docwin-doc-body { fill: #f8fafc; stroke: #cbd5e1; }
    .docwin-document-icon .docwin-doc-fold { fill: #cbd5e1; stroke: #94a3b8; }
    .docwin-document-icon .docwin-doc-line { fill: #cbd5e1; }
}

/* ======================= CONTENT ======================= */
.docwin-document-content {
    flex: 1;
    min-width: 0;
}

.docwin-wrap .docwin-document-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--docwin-text);
    text-decoration: none !important;
    line-height: 1.35;
    margin: 0 0 3px;
    padding: 0;
    box-shadow: none;
    background: transparent;
    transition: color 0.15s ease;
    letter-spacing: -0.005em;
    word-break: break-word;
}
.docwin-wrap .docwin-document-title:hover {
    color: var(--docwin-primary);
    text-decoration: none !important;
    background: transparent;
}
.docwin-wrap .docwin-document-title:focus-visible {
    outline: 2px solid var(--docwin-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.docwin-document-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--docwin-text-light);
}

.docwin-file-size {
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.docwin-file-date {
    color: var(--docwin-text-muted);
    font-variant-numeric: tabular-nums;
}

/* ======================= DOWNLOAD BUTTON ======================= */
.docwin-wrap .docwin-download-btn {
    box-sizing: border-box;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    color: var(--docwin-text-muted);
    background: var(--docwin-bg-lighter);
    border: 0;
    border-radius: 50%;
    text-decoration: none !important;
    box-shadow: none;
    opacity: 0.7;
    transition: var(--docwin-transition);
}
.docwin-wrap .docwin-download-btn svg {
    width: 18px !important;
    height: 18px !important;
    display: block;
    flex-shrink: 0;
    max-width: none;
}
.docwin-document-item:hover .docwin-download-btn {
    opacity: 1;
    color: var(--docwin-primary);
    background: var(--docwin-primary-soft);
}
.docwin-wrap .docwin-download-btn:hover,
.docwin-wrap .docwin-download-btn:focus-visible {
    color: #ffffff;
    background: var(--docwin-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
    outline: none;
    text-decoration: none !important;
}

/* ======================= EMPTY STATE ======================= */
.docwin-empty-state {
    padding: 3.5rem 1rem;
    text-align: center;
    background: var(--docwin-bg-light);
    border-radius: var(--docwin-radius);
    border: 1px dashed var(--docwin-border);
}
.docwin-empty-icon {
    margin: 0 auto 1rem;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--docwin-bg-lighter);
    color: var(--docwin-text-muted);
}
.docwin-empty-state p {
    font-size: 1rem;
    color: var(--docwin-text-light);
    margin: 0 0 0.35rem;
    font-weight: 500;
}
.docwin-empty-state p.docwin-empty-sub {
    color: var(--docwin-text-muted);
    font-size: 0.875rem;
    font-weight: 400;
}

.docwin-notice {
    padding: 12px 16px;
    border-radius: var(--docwin-radius-sm);
    font-size: 0.9rem;
    border: 1px solid;
}
.docwin-notice.docwin-error {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

/* ======================= RESPONSIVE ======================= */
@media (max-width: 768px) {
    .docwin-content-cell { padding: 12px 14px; gap: 12px; }
    .docwin-document-icon { width: 42px; height: 53px; }
    .docwin-group-icon { width: 26px; height: 21px; }
    .docwin-document-title { font-size: 0.9rem; }
    .docwin-group-header { padding: 10px 14px; }
}
@media (max-width: 480px) {
    .docwin-content-cell { padding: 10px 12px; gap: 10px; }
    .docwin-document-icon { width: 38px; height: 48px; }
    .docwin-group-icon { width: 24px; height: 20px; }
    .docwin-group-title { font-size: 0.875rem; }
    .docwin-group-count { padding: 2px 8px; font-size: 11px; }
}

/* ======================= THEME OVERRIDES ======================= */
/* Block auto-injected file-type icons that some themes/plugins add to
   links ending in .pdf, .docx, etc. (via ::before, ::after, or <img>). */
.docwin-wrap .docwin-document-title::before,
.docwin-wrap .docwin-document-title::after,
.docwin-wrap .docwin-download-btn::before,
.docwin-wrap .docwin-download-btn::after {
    content: none !important;
    display: none !important;
    background: none !important;
    background-image: none !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}
.docwin-wrap .docwin-document-title img,
.docwin-wrap .docwin-download-btn img {
    display: none !important;
}
/* Hide any stray images/icons the theme may inject inside our rows,
   but keep our own SVGs (inside .docwin-document-icon and .docwin-download-btn). */
.docwin-wrap .docwin-document-content > a img,
.docwin-wrap .docwin-document-content > a svg:not(.docwin-keep) {
    display: none !important;
}

/* ======================= A11Y ======================= */
@media (prefers-reduced-motion: reduce) {
    .docwin-document-item { animation: none; }
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
