/* --- Reset & Variables --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Dark Mode (default) */
    --bg-color: #0a0a0a;
    --panel-color: #121212;
    --border-color: #222222;
    --text-main: #eaeaea;
    --text-muted: #666666;
    --accent: #ffffff;
    --accent-hover: #cccccc;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    /* Slots machine colors */
    --slots-machine-primary: #FFD700;
    --slots-machine-secondary: #FFA500;
    --slots-machine-border: #8B4513;
    --slots-machine-text: #8B0000;
    --slots-machine-reel-bg: #333;
    --slots-machine-reel-text: #333;
}

html[data-theme="dark"] {
    --bg-color: #0a0a0a;
    --panel-color: #121212;
    --border-color: #222222;
    --text-main: #eaeaea;
    --text-muted: #666666;
    --accent: #ffffff;
    --accent-hover: #cccccc;
    /* Slots machine colors */
    --slots-machine-primary: #FFD700;
    --slots-machine-secondary: #FFA500;
    --slots-machine-border: #8B4513;
    --slots-machine-text: #8B0000;
    --slots-machine-reel-bg: #333;
    --slots-machine-reel-text: #333;
}

html[data-theme="light"] {
    --bg-color: #f5f5f5;
    --panel-color: #ffffff;
    --border-color: #e0e0e0;
    --text-main: #1a1a1a;
    --text-muted: #999999;
    --accent: #000000;
    --accent-hover: #333333;
    /* Slots machine colors */
    --slots-machine-primary: #FFD700;
    --slots-machine-secondary: #FFA500;
    --slots-machine-border: #8B4513;
    --slots-machine-text: #8B0000;
    --slots-machine-reel-bg: #f0f0f0;
    --slots-machine-reel-text: #1a1a1a;
}

html[data-theme="catppuccin"] {
    --bg-color: #1e1e2e;
    --panel-color: #313244;
    --border-color: #45475a;
    --text-main: #cdd6f4;
    --text-muted: #9399b2;
    --accent: #a6e3a1;
    --accent-hover: #94e2d5;
    /* Slots machine colors */
    --slots-machine-primary: #a6e3a1;
    --slots-machine-secondary: #94e2d5;
    --slots-machine-border: #313244;
    --slots-machine-text: #f38ba8;
    --slots-machine-reel-bg: #181825;
    --slots-machine-reel-text: #cdd6f4;
}

html[data-theme="nord"] {
    --bg-color: #2e3440;
    --panel-color: #3b4252;
    --border-color: #434c5e;
    --text-main: #eceff4;
    --text-muted: #d08770;
    --accent: #81a1c1;
    --accent-hover: #88c0d0;
    /* Slots machine colors */
    --slots-machine-primary: #88c0d0;
    --slots-machine-secondary: #81a1c1;
    --slots-machine-border: #2e3440;
    --slots-machine-text: #bf616a;
    --slots-machine-reel-bg: #2e3440;
    --slots-machine-reel-text: #eceff4;
}

html[data-theme="tokyonight"] {
    --bg-color: #1a1a2e;
    --panel-color: #16213e;
    --border-color: #0f3460;
    --text-main: #eaeaea;
    --text-muted: #a0a9cb;
    --accent: #00d9ff;
    --accent-hover: #00b8d4;
    /* Slots machine colors */
    --slots-machine-primary: #00d9ff;
    --slots-machine-secondary: #00b8d4;
    --slots-machine-border: #0f3460;
    --slots-machine-text: #ff006e;
    --slots-machine-reel-bg: #0f3460;
    --slots-machine-reel-text: #eaeaea;
}

html[data-theme="dracula"] {
    --bg-color: #282a36;
    --panel-color: #21222c;
    --border-color: #44475a;
    --text-main: #f8f8f2;
    --text-muted: #6272a4;
    --accent: #ff79c6;
    --accent-hover: #ff92df;
    /* Slots machine colors */
    --slots-machine-primary: #ff79c6;
    --slots-machine-secondary: #8be9fd;
    --slots-machine-border: #44475a;
    --slots-machine-text: #ffb86c;
    --slots-machine-reel-bg: #1e1f29;
    --slots-machine-reel-text: #f8f8f2;
}

html[data-theme="midnight"] {
    --bg-color: #000000;
    --panel-color: #000000;
    --border-color: #1a1a1a;
    --text-main: #ffffff;
    --text-muted: #808080;
    --accent: #ff0000;
    --accent-hover: #cc0000;
    /* Slots machine colors */
    --slots-machine-primary: #ff0000;
    --slots-machine-secondary: #cc0000;
    --slots-machine-border: #ffffff;
    --slots-machine-text: #ffff00;
    --slots-machine-reel-bg: #0a0a0a;
    --slots-machine-reel-text: #ffffff;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    letter-spacing: -0.01em;
    padding: 40px 20px;
}

/* --- Header Layout --- */
.archive-header {
    max-width: 900px;
    margin: 0 auto 60px auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 20px;
}

.archive-header + .archive-header {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 22px;
    margin-top: 22px;
}

html[data-theme="light"] .archive-header + .archive-header {
    border-color: rgba(0, 0, 0, 0.1);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: #00ff66;
    border-radius: 50%;
}

.file-count {
    color: var(--text-muted);
}

/* --- Search Input --- */
.search-wrapper {
    flex-grow: 1;
    max-width: 300px;
}

#canvas {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 1; /* Puts it underneath the list */
background-color: var(--bg-color); /* Uses theme color */
}

.ui-wrapper {
    position: relative;
    z-index: 2; /* Floats above the canvas */
    max-width: 900px;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 24px 28px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    animation: windowOpen 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;

    /* CRITICAL FOR INTERACTIVE CANVAS BACKGROUNDS:
     *      This allows mouse movements to pass right through the empty layout container
     *      so the stars connect to your mouse pointer. */
    pointer-events: none;
}

html[data-theme="light"] .ui-wrapper {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.15);
}

html[data-theme="catppuccin"] .ui-wrapper {
    background: rgba(30, 30, 46, 0.95);
    border-color: rgba(205, 214, 244, 0.1);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

html[data-theme="nord"] .ui-wrapper {
    background: rgba(46, 52, 64, 0.95);
    border-color: rgba(236, 239, 244, 0.1);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

html[data-theme="tokyonight"] .ui-wrapper {
    background: rgba(26, 26, 46, 0.95);
    border-color: rgba(0, 217, 255, 0.15);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

html[data-theme="dracula"] .ui-wrapper {
    background: rgba(40, 42, 54, 0.95);
    border-color: rgba(255, 121, 198, 0.15);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

html[data-theme="midnight"] .ui-wrapper {
    background: rgba(0, 0, 0, 0.98);
    border-color: rgba(255, 0, 0, 0.15);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8);
}

.window-frame {
    position: relative;
    pointer-events: auto !important;
}

@keyframes windowOpen {
    0% {
        opacity: 0;
        transform: scale(0.85) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.window-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    margin: -24px -28px 22px -28px;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    background: rgba(12, 12, 12, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .window-toolbar {
    background: rgba(240, 240, 240, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="catppuccin"] .window-toolbar {
    background: rgba(49, 50, 68, 0.95);
    border-color: rgba(205, 214, 244, 0.1);
}

html[data-theme="nord"] .window-toolbar {
    background: rgba(59, 66, 82, 0.95);
    border-color: rgba(236, 239, 244, 0.1);
}

html[data-theme="tokyonight"] .window-toolbar {
    background: rgba(15, 52, 96, 0.95);
    border-color: rgba(0, 217, 255, 0.15);
}

html[data-theme="dracula"] .window-toolbar {
    background: rgba(33, 34, 44, 0.95);
    border-color: rgba(255, 121, 198, 0.15);
}

html[data-theme="midnight"] .window-toolbar {
    background: rgba(0, 0, 0, 0.98);
    border-color: rgba(255, 0, 0, 0.15);
}

.tab-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 2px;
}

.tab-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 auto 24px auto;
    max-width: 900px;
    gap: 20px;
}

.theme-dropdown-wrapper {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.theme-selector {
    appearance: none;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 10px 14px 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23eaeaea' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

html[data-theme="light"] .theme-selector {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231a1a1a' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
}

html[data-theme="catppuccin"] .theme-selector {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23cdd6f4' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

html[data-theme="nord"] .theme-selector {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23eceff4' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

html[data-theme="tokyonight"] .theme-selector {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300d9ff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

html[data-theme="dracula"] .theme-selector {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ff79c6' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

html[data-theme="midnight"] .theme-selector {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ff0000' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
}

.theme-selector:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="light"] .theme-selector:hover {
    border-color: rgba(0, 0, 0, 0.2);
    background-color: rgba(0, 0, 0, 0.08);
}

.theme-selector:focus {
    outline: none;
    border-color: var(--accent);
}

.theme-selector option {
    background: var(--panel-color);
    color: var(--text-main);
}

.tab-button {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
    padding: 10px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    font: inherit;
}

.tab-button:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

html[data-theme="light"] .tab-button:hover {
    border-color: rgba(0, 0, 0, 0.2);
}

.tab-button.active {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--accent);
}

html[data-theme="light"] .tab-button.active {
    background: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}

.window-controls {
    display: flex;
    gap: 8px;
}

.window-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    background: #ff5f56;
    border: 1px solid rgba(0, 0, 0, 0.15);
    pointer-events: auto !important;
}

.window-btn.minimize {
    background: #ffbd2e;
}

.window-btn.maximize {
    background: #27c93f;
}

.window-title {
    color: var(--text-muted);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    display: inline-block;
    padding: 0 6px;
    animation: glowPulse 3.5s ease-in-out infinite;
}

.window-title::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.18), transparent 55%);
    opacity: 0;
    animation: pulseSoft 3.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes glowPulse {
    0%, 100% {
        color: var(--text-muted);
        text-shadow: 0 0 0 rgba(255,255,255,0);
    }
    50% {
        color: #ffffff;
        text-shadow: 0 0 16px rgba(255,255,255,0.12);
    }
}

@keyframes pulseSoft {
    0%, 100% {
        opacity: 0;
    }
    50% {
        opacity: 0.18;
    }
}

#searchInput {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 13px;
    padding: 6px 0 6px 28px;
    outline: none;
    transition: border-color 0.2s ease;
}

#searchInput:focus {
    border-color: var(--accent);
}

.search-wrapper {
    position: relative;
    max-width: 300px;
}

.search-icon {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.download-btn {
    color: var(--text-main);
    text-decoration: none;
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    cursor: pointer;
    font: inherit;
    line-height: 1;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: currentColor;
    vertical-align: middle;
    line-height: 0;
}

.btn-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}


/* --- Main Container & List Matrix --- */
.archive-container {
    max-width: 900px;
    margin: 0 auto;
}

.table-header, .file-item {
    display: grid;
    grid-template-columns: 3.5fr 1fr 1fr 1fr;
    align-items: center;
    padding: 14px 0;
}

.table-header {
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: bold;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}

.file-list {
    list-style: none;
}

.file-item {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.1s ease;
}

.file-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.file-name {
    color: var(--text-main);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.col-type, .col-size {
    color: var(--text-muted);
}

/* --- Minimal Action Buttons --- */
.col-action {
    text-align: right;
}

.download-btn {
    color: var(--text-main);
    text-decoration: none;
    border: 1px solid var(--border-color);
    padding: 4px 12px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: inline-block;
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.download-btn:hover {
    background-color: var(--accent);
    color: var(--bg-color);
    border-color: var(--accent);
}

.file-list,
.file-item,
.download-btn,
.archive-header,
.brand,
#searchInput {
position: relative;
z-index: 3;
pointer-events: auto !important;
}

/* --- Footer --- */
.archive-footer {
    max-width: 900px;
    margin: 80px auto 0 auto;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    color: var(--text-muted);
    font-size: 11px;
}

/* --- Responsive Layout adjustments --- */
@media (max-width: 700px) {
    .table-header {
        display: none;
    }
    
    .file-item {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 20px 0;
    }
    
    .col-type, .col-size {
        font-size: 11px;
    }

    .col-action {
        text-align: left;
        margin-top: 5px;
    }
    
    .search-wrapper {
        max-width: 100%;
    }
}
