/*
 * Modern re-skin for the Baran Download Center file manager.
 * Every selector below targets IDs/classes the existing inline JS already
 * uses — nothing here renames or removes a hook the script depends on.
 */

@font-face {
    font-family: 'Vazir';
    src: url('../../../Vazir.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --dc-bg: #f4f6fb;
    --dc-surface: #ffffff;
    --dc-surface-2: #f8f9fc;
    --dc-border: #e6e9f2;
    --dc-text: #1c2233;
    --dc-text-muted: #6b7280;
    --dc-primary: #6d5ef8;
    --dc-primary-dark: #5a4de0;
    --dc-primary-soft: #eeeafe;
    --dc-green: #16a34a;
    --dc-red: #dc2626;
    --dc-red-soft: #fdecec;
    --dc-shadow: 0 4px 20px rgba(30, 34, 60, 0.06);
    --dc-shadow-lg: 0 12px 34px rgba(30, 34, 60, 0.1);
    --dc-radius: 14px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --dc-bg: #12131c;
        --dc-surface: #1b1d2b;
        --dc-surface-2: #20223350;
        --dc-border: #2b2e42;
        --dc-text: #eef0fa;
        --dc-text-muted: #9195b3;
        --dc-primary: #8577ff;
        --dc-primary-dark: #6d5ef8;
        --dc-primary-soft: #262244;
        --dc-red-soft: #3a1616;
        --dc-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
        --dc-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
    }
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazir', 'lucida grande', 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    width: auto;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px 3em;
    background: var(--dc-bg);
    color: var(--dc-text);
}

/* New header bar (purely additive markup, does not replace #top) */
.dc-header {
    margin: 0 -20px 22px;
    padding: 22px 20px;
    background: linear-gradient(135deg, var(--dc-primary), var(--dc-primary-dark));
    color: #fff;
    box-shadow: var(--dc-shadow-lg);
}
.dc-header-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
}
.dc-logo { width: 46px; height: 46px; object-fit: contain; background: #fff; border-radius: 12px; padding: 6px; }
.dc-header h1 { font-size: 19px; margin: 0 0 2px; }
.dc-header p { font-size: 12.5px; margin: 0; color: #e4e0ff; }

/* Toolbar */
#top {
    height: auto;
    min-height: 52px;
    background: var(--dc-surface);
    border: 1px solid var(--dc-border);
    border-radius: var(--dc-radius);
    box-shadow: var(--dc-shadow);
    padding: 16px 18px;
    margin-bottom: 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
}

#mkdir { display: inline-flex; align-items: flex-end; gap: 8px; float: none; padding-top: 0; }
#mkdir label { display: block; font-size: 11px; color: var(--dc-text-muted); margin-bottom: 4px; }
#mkdir input[type=text] {
    padding: 8px 12px; border-radius: 9px; border: 1px solid var(--dc-border);
    background: var(--dc-surface-2); color: var(--dc-text); font-family: inherit; font-size: 13px;
}
#mkdir input[type=submit] {
    padding: 8px 16px; border-radius: 9px; border: none; cursor: pointer;
    background: linear-gradient(135deg, var(--dc-primary), var(--dc-primary-dark)); color: #fff; font-family: inherit; font-size: 13px;
}

label { display: block; font-size: 11px; color: var(--dc-text-muted); }

.uploader_container { display: none; }
.uploader_container.show { display: flex; animation: dc-fade-in .25s ease; }

.upload-wizard {
    display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
    padding: 8px 12px; border-radius: 12px;
    background: var(--dc-primary-soft);
    border: 1px solid var(--dc-border);
}
.upload-step { display: flex; align-items: center; gap: 8px; }
.step-badge {
    flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
    background: linear-gradient(135deg, var(--dc-primary), var(--dc-primary-dark)); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700;
}
.step-label { font-size: 10.5px; color: var(--dc-text-muted); margin: 0 0 3px; font-weight: 600; }

.pack_number_container { display: flex; flex-direction: column; }
#pack_number_input {
    font-size: 13px !important; padding: 6px 10px !important; border-radius: 8px !important;
    border: 1.5px solid var(--dc-border) !important; background: var(--dc-surface); color: var(--dc-text);
    font-family: inherit; outline: none; transition: border-color .15s, box-shadow .15s; width: 110px;
}
#pack_number_input:focus { border-color: var(--dc-primary) !important; box-shadow: 0 0 0 3px var(--dc-primary-soft); }
.error_message small {
    display: block; font-size: 10px; margin-top: 4px; max-width: 220px; line-height: 1.5;
    transition: color .15s;
}
.error_message small button {
    background: linear-gradient(135deg, var(--dc-primary), var(--dc-primary-dark)) !important;
    color: #fff !important; border: none !important; border-radius: 7px !important;
    padding: 4px 10px !important; font-family: inherit !important; font-size: 11px !important;
}

#file_drop_target {
    width: 240px; max-width: 100%; padding: 8px 12px; border: 1.5px dashed var(--dc-border);
    border-radius: 10px; font-size: 11px; color: var(--dc-text-muted);
    text-align: center; float: none; margin-right: 0; background: var(--dc-surface);
    transition: border-color .15s, color .15s, background .15s;
    display: flex; align-items: center; gap: 8px; position: relative;
}
.drop-icon {
    flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
    background: var(--dc-primary-soft); color: var(--dc-primary);
    display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.drop-icon::before { content: "⬆"; }
.drop-text { text-align: right; overflow: hidden; }
.drop-title { margin: 0; font-size: 10.5px; color: var(--dc-text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drop-sub { margin: 0; font-size: 9.5px; color: var(--dc-text-muted); }
.drop-sub b { color: var(--dc-primary); }

#file_drop_target.drag_over { border-color: var(--dc-primary); color: var(--dc-primary); background: var(--dc-primary-soft); }
#file_drop_target.drag_over .drop-icon { background: var(--dc-primary); color: #fff; }
#file_drop_target.success { border-color: var(--dc-green); }
#file_drop_target.error { border-color: var(--dc-red); display: none; }
#file_drop_target input[type=file] {
    flex-shrink: 0; font-size: 10.5px; color: var(--dc-text-muted); max-width: 90px;
}
#file_drop_target input[type=file]::file-selector-button,
#file_drop_target input[type=file]::-webkit-file-upload-button {
    padding: 5px 10px; border-radius: 7px; border: 1px solid var(--dc-border);
    background: var(--dc-surface-2); color: var(--dc-text); font-family: inherit; font-size: 10.5px;
    cursor: pointer; transition: background .15s;
}
#file_drop_target input[type=file]::file-selector-button:hover,
#file_drop_target input[type=file]::-webkit-file-upload-button:hover { background: var(--dc-primary-soft); }

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

#upload_progress { padding: 4px 0; display: flex; flex-direction: column; gap: 8px; }
#upload_progress > div {
    padding: 10px 14px; background: var(--dc-surface); border: 1px solid var(--dc-border);
    border-radius: 10px; display: flex; align-items: center; gap: 10px; font-size: 12.5px; box-shadow: var(--dc-shadow);
    animation: dc-fade-in .2s ease;
}
#upload_progress > div::before {
    content: "📄"; flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px;
    background: var(--dc-primary-soft); display: flex; align-items: center; justify-content: center; font-size: 13px;
}
#upload_progress .error { color: var(--dc-red); background: var(--dc-red-soft); border-color: transparent; }
#upload_progress .error::before { content: "⚠"; background: var(--dc-red-soft); }
#upload_progress .fileuploadname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#upload_progress .resume-btn, #upload_progress .resume-cancel-wrap button {
    border: 1px solid var(--dc-border); background: var(--dc-surface-2); color: var(--dc-text);
    border-radius: 8px; padding: 5px 10px; cursor: pointer; font-family: inherit; font-size: 11.5px;
}
#upload_progress .retry-status {
    font-size: 11px; color: var(--dc-amber, #b45309); flex-basis: 100%;
}

.no_write #mkdir, .no_write #file_drop_target { display: none; }

.progress_track {
    display: inline-block; width: 160px; height: 8px; border-radius: 999px;
    background: var(--dc-border); margin: 0 4px 0 10px; overflow: hidden; border: none;
}
.progress {
    background: linear-gradient(90deg, var(--dc-primary), var(--dc-primary-dark));
    background-size: 200% 100%; height: 8px; width: 0; transition: width .2s;
    animation: dc-progress-shimmer 1.2s linear infinite;
}
@keyframes dc-progress-shimmer { from { background-position: 200% 0; } to { background-position: 0 0; } }

footer {
    font-size: 11.5px; color: var(--dc-text-muted); padding: 3em 0 0; text-align: center !important;
}
footer a, footer a:visited { color: var(--dc-text-muted); }

#breadcrumb {
    padding-top: 0; font-size: 13.5px; color: var(--dc-text-muted); display: inline-flex; float: none;
    align-items: center; gap: 4px; flex-wrap: wrap;
}
#breadcrumb a { color: var(--dc-primary); }

#folder_actions { width: auto; float: none; }

a, a:visited { color: var(--dc-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.sort_hide { display: none; }

table { border-collapse: collapse; width: 100%; background: var(--dc-surface); border-radius: var(--dc-radius); overflow: hidden; box-shadow: var(--dc-shadow); }
thead { max-width: 100%; border-top: none; border-bottom: 1px solid var(--dc-border); border-left: none; border-right: none; background: var(--dc-surface-2); }
th {
    font-weight: 600; color: var(--dc-text-muted); background: transparent; padding: .9em 1em .9em .2em;
    text-align: right; cursor: pointer; user-select: none; font-size: 12px; text-transform: none;
}
th .indicator { margin-left: 6px; color: var(--dc-primary); }

td { padding: .7em 1em .7em .2em; border-bottom: 1px solid var(--dc-border); height: auto; font-size: 12.5px; white-space: nowrap; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--dc-surface-2); }
td.first { font-size: 13.5px; white-space: normal; }
td.empty { color: var(--dc-text-muted); font-style: italic; text-align: center; padding: 3em 0; }

.is_dir .size { color: transparent; font-size: 0; }
.is_dir .size:before { content: "—"; font-size: 13px; color: var(--dc-text-muted); }
.is_dir .download { visibility: hidden; }

a.delete {
    display: inline-block; color: var(--dc-red); background: var(--dc-red-soft);
    margin-left: 8px; font-size: 11px; padding: 4px 10px; border-radius: 999px;
}
a.delete:hover { text-decoration: none; filter: brightness(0.95); }

.name {
    padding: .5em 0 .5em 0;
    font-weight: 500;
}
.is_dir .name {
    font-weight: 600;
    color: var(--dc-text);
}
.is_dir .name:before { content: "📁 "; }
tr:not(.is_dir) .name:before { content: "📄 "; }

.download {
    padding: 4px 10px; border-radius: 999px; background: var(--dc-primary-soft); color: var(--dc-primary);
    font-size: 11px; margin-left: 8px;
}

@media (max-width: 720px) {
    body { padding: 0 12px 3em; }
    .dc-header { margin: 0 -12px 18px; }
    #top { flex-direction: column; align-items: stretch; }
    #file_drop_target { width: 100%; }
    .upload-wizard { flex-direction: column; align-items: stretch; padding: 10px; }
    .upload-step { flex: 1 1 auto; }
    table, thead, tbody, th, td, tr { display: block; }
    thead tr { position: absolute; top: -9999px; left: -9999px; }
    td { border-bottom: none; padding: 4px .2em; }
    tbody tr { border-bottom: 1px solid var(--dc-border); padding: 8px 4px; }
}
