@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Core Palette */
    --bg:        #09090b;
    --bg2:       #111114;
    --bg3:       #18181c;
    --bg4:       #1e1e24;
    --surface:   rgba(255,255,255,0.03);
    --surface2:  rgba(255,255,255,0.06);

    /* Borders */
    --border:    rgba(255,255,255,0.07);
    --border2:   rgba(255,255,255,0.12);

    /* Brand */
    --brand:     #6c63ff;
    --brand-dim: rgba(108,99,255,0.12);
    --brand-mid: rgba(108,99,255,0.25);
    --cyan:      #22d3ee;
    --cyan-dim:  rgba(34,211,238,0.1);
    --emerald:   #10b981;
    --amber:     #f59e0b;
    --rose:      #f43f5e;

    /* Text */
    --text:      #e4e4e7;
    --text2:     #a1a1aa;
    --text3:     #52525b;
    --text-inv:  #09090b;

    /* Misc */
    --radius:    10px;
    --radius-sm: 6px;
    --row-hover: rgba(255,255,255,0.03);
    --shadow:    0 4px 24px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Subtle grid background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(108,99,255,0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================================
   LOADING BAR
   ============================================================ */
.loading-bar {
    position: fixed;
    top: 0; left: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--brand), var(--cyan));
    z-index: 999;
    transition: width 0.35s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 0 12px rgba(108,99,255,0.7);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border2);
    background: var(--bg3);
    backdrop-filter: blur(16px);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    box-shadow: var(--shadow-lg);
    pointer-events: all;
    animation: toastIn 0.3s cubic-bezier(.34,1.56,.64,1) both;
    max-width: 340px;
}

.toast.fade-out { animation: toastOut 0.3s ease forwards; }
.toast-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.toast.success .toast-dot { background: var(--emerald); }
.toast.error .toast-dot { background: var(--rose); }
.toast.info .toast-dot { background: var(--cyan); }
.toast.warn .toast-dot { background: var(--amber); }

@keyframes toastIn { from { opacity:0; transform:translateX(20px) scale(.95); } to { opacity:1; transform:none; } }
@keyframes toastOut { to { opacity:0; transform:translateX(20px) scale(.95); } }

/* ============================================================
   HEADER
   ============================================================ */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 64px;
    border-bottom: 1px solid var(--border);
    background: rgba(9,9,11,0.85);
    backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
    filter: invert(1) brightness(0.9);
}

.logo-divider {
    width: 1px;
    height: 22px;
    background: var(--border2);
}

.logo-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
}

.logo-sub {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: var(--text3);
    text-transform: uppercase;
    margin-top: 1px;
}

.logo-text-group {
    display: flex;
    flex-direction: column;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text2);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    letter-spacing: 0;
    white-space: nowrap;
}

.btn:hover {
    border-color: var(--border2);
    color: var(--text);
    background: var(--surface2);
}

.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-primary:hover {
    background: #7c75f8;
    border-color: #7c75f8;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
main {
    position: relative;
    z-index: 1;
    padding: 28px 32px 48px;
    max-width: 1440px;
    margin: 0 auto;
}

/* ============================================================
   PAGE TITLE
   ============================================================ */
.page-header {
    margin-bottom: 24px;
    animation: fadeUp 0.4s ease both;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.82rem;
    color: var(--text3);
    margin-top: 4px;
    font-weight: 400;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
    animation: fadeUp 0.4s 0.05s ease both;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}

.stat-card:hover {
    border-color: var(--border2);
    transform: translateY(-1px);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--brand), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.stat-card:hover::before { opacity: 0.6; }

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.purple { background: rgba(108,99,255,0.12); color: var(--brand); }
.stat-icon.cyan   { background: var(--cyan-dim); color: var(--cyan); }
.stat-icon.green  { background: rgba(16,185,129,0.1); color: var(--emerald); }
.stat-icon.amber  { background: rgba(245,158,11,0.1); color: var(--amber); }

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--text);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--text3);
    letter-spacing: 0.01em;
    text-transform: uppercase;
}

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: fadeUp 0.4s 0.1s ease both;
    flex-wrap: wrap;
    align-items: center;
}

.search-wrap {
    flex: 1;
    min-width: 220px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text3);
    pointer-events: none;
    display: flex;
}

.search-input {
    width: 100%;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 14px 9px 38px;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.83rem;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.search-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
}

.search-input::placeholder { color: var(--text3); }

.filter-select {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 34px 9px 12px;
    color: var(--text2);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' viewBox='0 0 12 7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2352525b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.15s;
}

.filter-select:focus { border-color: var(--brand); outline: none; }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    font-size: 0.77rem;
    font-weight: 500;
    color: var(--text3);
    animation: fadeUp 0.4s 0.15s ease both;
}

.breadcrumb a {
    color: var(--brand);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.15s;
}
.breadcrumb a:hover { color: #9d98ff; text-decoration: underline; }
.breadcrumb .sep {
    color: var(--text3);
    font-size: 0.7rem;
}

/* ============================================================
   FILE TABLE
   ============================================================ */
.file-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeUp 0.4s 0.18s ease both;
    background: var(--bg2);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead tr {
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
}

th {
    padding: 11px 16px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text3);
    text-align: left;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.15s;
}

th:hover { color: var(--text2); }
th.active-sort { color: var(--brand); }

.sort-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.35;
    font-style: normal;
    font-size: 0.65rem;
}
th.active-sort .sort-icon { opacity: 1; }

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child { border-bottom: none; }

td {
    padding: 11px 16px;
    font-size: 0.84rem;
    vertical-align: middle;
}

/* File name cell */
.file-name-cell {
    display: flex;
    align-items: center;
    gap: 11px;
    cursor: default;
}
.folder-row .file-name-cell { cursor: pointer; }

.file-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    font-weight: 600;
    flex-shrink: 0;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

/* Icon variants */
.icon-folder { background: rgba(34,211,238,0.1); color: var(--cyan); border: 1px solid rgba(34,211,238,0.2); }
.icon-7z     { background: rgba(245,158,11,0.1); color: var(--amber); border: 1px solid rgba(245,158,11,0.2); }
.icon-zip    { background: rgba(245,158,11,0.1); color: var(--amber); border: 1px solid rgba(245,158,11,0.2); }
.icon-rar    { background: rgba(244,63,94,0.1); color: #fb7185; border: 1px solid rgba(244,63,94,0.2); }
.icon-csv    { background: rgba(16,185,129,0.1); color: var(--emerald); border: 1px solid rgba(16,185,129,0.2); }
.icon-xlsx   { background: rgba(16,185,129,0.12); color: #34d399; border: 1px solid rgba(16,185,129,0.2); }
.icon-pdf    { background: rgba(244,63,94,0.1); color: var(--rose); border: 1px solid rgba(244,63,94,0.2); }
.icon-txt    { background: rgba(161,161,170,0.1); color: #a1a1aa; border: 1px solid rgba(161,161,170,0.15); }
.icon-db     { background: rgba(167,139,250,0.1); color: #a78bfa; border: 1px solid rgba(167,139,250,0.2); }
.icon-json   { background: rgba(251,191,36,0.1); color: #fbbf24; border: 1px solid rgba(251,191,36,0.2); }
.icon-aria2  { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(34,211,238,0.2); }
.icon-default{ background: rgba(82,82,91,0.15); color: var(--text3); border: 1px solid rgba(82,82,91,0.2); }

.file-name-text {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 340px;
}
.folder-row .file-name-text { color: var(--cyan); }

/* Type badge */
.type-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Size / Date cells */
.size-cell, .date-cell {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text3);
    white-space: nowrap;
    font-weight: 400;
}

/* Actions */
.actions-cell { display: flex; gap: 5px; align-items: center; }

.action-btn {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.action-btn:hover {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}
.action-btn.dl:hover {
    background: var(--cyan-dim);
    border-color: rgba(34,211,238,0.3);
    color: var(--cyan);
}
.action-btn.info:hover {
    background: rgba(108,99,255,0.1);
    border-color: rgba(108,99,255,0.3);
    color: var(--brand);
}
.action-btn svg { width: 14px; height: 14px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text3);
}
.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--bg3);
    border: 1px solid var(--border);
    margin: 0 auto 18px;
    color: var(--text3);
}
.empty-state-icon svg { width: 24px; height: 24px; }
.empty-state h3 { font-size: 0.95rem; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.empty-state p { font-size: 0.78rem; margin-bottom: 20px; }

/* ============================================================
   TABLE FOOTER / PAGINATION
   ============================================================ */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    background: var(--bg3);
    border-top: 1px solid var(--border);
    font-size: 0.73rem;
    color: var(--text3);
    gap: 10px;
    flex-wrap: wrap;
}

.pagination { display: flex; gap: 4px; }

.page-btn {
    min-width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text3);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}
.page-btn:hover { border-color: var(--border2); color: var(--text); background: var(--surface); }
.page-btn.active { background: var(--brand-dim); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.page-btn:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none; }

/* ============================================================
   INFO MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: 14px;
    padding: 28px;
    width: 460px;
    max-width: 92vw;
    transform: translateY(16px) scale(0.98);
    transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), opacity 0.2s;
    box-shadow: var(--shadow-lg);
}
.modal-overlay.active .modal { transform: none; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.modal-title-wrap { display: flex; align-items: center; gap: 10px; }
.modal-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
}
.modal-x {
    width: 28px; height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text3);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.15s; flex-shrink: 0;
}
.modal-x:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.modal-x svg { width: 14px; height: 14px; }

.modal-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.82rem;
    align-items: flex-start;
}
.modal-key {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text3);
    min-width: 80px;
    padding-top: 2px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.modal-val { color: var(--text); word-break: break-all; line-height: 1.5; }
.modal-val a { color: var(--brand); text-decoration: none; }
.modal-val a:hover { text-decoration: underline; }

.modal-footer { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; display: flex; gap: 8px; }

/* ============================================================
   DOWNLOAD MODAL
   ============================================================ */
.dl-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(10px);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.dl-modal-overlay.active { opacity: 1; pointer-events: all; }

.dl-modal {
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: 14px;
    padding: 40px 36px;
    text-align: center;
    min-width: 320px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    transform: translateY(16px) scale(0.98);
    transition: transform 0.2s cubic-bezier(.34,1.56,.64,1);
}
.dl-modal-overlay.active .dl-modal { transform: none; }

.dl-spinner-wrap {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--brand-dim);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 22px;
    position: relative;
}
.dl-spinner-wrap::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--brand);
    animation: spin 0.8s linear infinite;
}
.dl-spinner-wrap svg { width: 22px; height: 22px; color: var(--brand); }

@keyframes spin { to { transform: rotate(360deg); } }

.dl-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}
.dl-modal-sub {
    font-size: 0.77rem;
    color: var(--text3);
    line-height: 1.5;
}
.dl-modal-error {
    color: var(--rose);
    font-size: 0.8rem;
    margin-top: 14px;
    line-height: 1.5;
}

/* ============================================================
   HIGHLIGHT
   ============================================================ */
.highlight {
    color: var(--brand);
    background: var(--brand-dim);
    border-radius: 3px;
    padding: 0 2px;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

@keyframes rowIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

tbody tr { animation: rowIn 0.25s ease both; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    main { padding: 20px 16px 40px; }
    header { padding: 0 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .file-name-text { max-width: 180px; }
}

@media (max-width: 640px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    th:nth-child(4), td:nth-child(4),
    th:nth-child(3), td:nth-child(3) { display: none; }
    .file-name-text { max-width: 140px; }
}

/* ============================================================
   SECTION DIVIDER
   ============================================================ */
.section-sep {
    height: 1px;
    background: var(--border);
    margin: 28px 0;
}
