/* Copyright: 2boom 2023-2026 */

/* ============================================
   CSS Variables (Custom Properties)
   ============================================ */
:root {
    /* Base colors */
    --primary: #00A4E9;
    --success: #00D672;
    --warning: #FF6433;
    --error: #FF2337;
    --secondary: #F8AE3C;
    
    /* Button colors */
    --btn-red: #fb7185;
    --btn-red-hover: #f43f5e;
    --btn-green: #a8cf83;
    --btn-green-hover: #7fb65c;
    --btn-blue: #60a5fa;
    --btn-blue-hover: #3b82f6;
    --btn-grey: #94a3b8;
    --btn-grey-hover: #64748b;
    --btn-purple: #c084fc;
    --btn-purple-hover: #a855f7;
    --btn-orange: #fdba74;
    --btn-orange-hover: #fb923c;
    --btn-teal: #4fa3c7;
    --btn-teal-hover: #358bb0;
}

/* ============================================
   Dark Theme
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --color-scheme-background: #252525;
        --color-scheme-text-color: white;
        --mapp: #B9B9C8;
        --mdesc: #969696;
        --mbkg: #383838;
        --msbkg: #2B2B2B;
        --mhbkg: #454545;
        --mhbor: #FF595E;
        --mborder: #666666;
        --imgbkg: #2B2B2B;
    }
    .header-logo {
        filter: brightness(0) saturate(100%) invert(62%) sepia(87%) saturate(402%) hue-rotate(160deg) brightness(95%) contrast(93%);
    }
}

/* ============================================
   Light Theme
   ============================================ */
@media (prefers-color-scheme: light) {
    :root {
        --color-scheme-background: #f2f2f2;
        --color-scheme-text-color: #424251;
        --mapp: #313140;
        --mdesc: #696969;
        --mbkg: #F5F5F5;
        --msbkg: #FAFAFA;
        --mhbkg: #EEEEEE;
        --mhbor: #FF6368;
        --mborder: #CFCFCF;
        --imgbkg: #EBEBEB;
    }
    .header-logo {
        filter: brightness(0) saturate(100%) invert(54%) sepia(99%) saturate(2260%) hue-rotate(165deg) brightness(99%) contrast(101%);
    }
}

/* ============================================
   Base Styles
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background: var(--color-scheme-background);
    color: var(--color-scheme-text-color);
    height: 100%;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow: hidden;
}

/* ============================================
   Layout Containers
   ============================================ */
.mainpage {
    max-width: 1480px;
    width: 95%;
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 20px 60px;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Header Section
   ============================================ */
.file-manager-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: var(--color-scheme-background);
    z-index: 20;
    padding: 15px 0;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 10px;
    text-align: center;
}

.header-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.header-logo {
    width: 35px;
    height: 35px;
    background-image: url('/static/favicon.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.file-manager-title {
    color: var(--mapp);
    font-size: 2.5em;
    font-weight: 600;
    margin: 0;
}

.file-manager-subtitle {
    color: var(--mdesc);
    font-size: 1em;
    margin: 0 0 15px;
    max-width: 800px;
}

/* ============================================
   Upload Area
   ============================================ */
.upload-area-wrapper {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.upload-area {
    background: linear-gradient(135deg, var(--msbkg) 0%, var(--mbkg) 100%);
    border: 1px solid var(--mborder);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-bottom: 1em;
    width: 100%;
}

.upload-instructions {
    color: var(--mdesc);
    font-size: 0.95em;
    margin-bottom: 10px;
    line-height: 1.5;
    padding: 10px;
    background: var(--imgbkg);
    border-radius: 8px;
    border-left: 3px solid var(--btn-blue);
    text-align: center;
}

/* Drag & Drop Zone */
.drag-drop-zone {
    background: var(--msbkg);
    border: 2px dashed var(--mborder);
    border-radius: 10px;
    padding: 40px 20px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.drag-drop-zone:hover {
    background: linear-gradient(135deg, var(--mbkg) 0%, var(--imgbkg) 100%);
    border-color: var(--btn-red);
}

.drag-drop-zone.drag-over {
    background: var(--imgbkg);
    border-color: var(--btn-red-hover);
    border-style: solid;
    animation: pulse 1.5s infinite;
}

.drag-drop-content {
    text-align: center;
}

.drag-drop-highlight {
    color: var(--mapp);
    font-weight: 500;
    font-size: 1.2em;
    display: block;
    white-space: nowrap;
}

.drag-drop-or {
    color: var(--mdesc);
    font-size: 0.95em;
    opacity: 0.8;
    white-space: nowrap;
}

.drag-drop-zone.drag-over .drag-drop-highlight {
    color: var(--btn-blue-hover);
    font-weight: 600;
}

/* Upload Button */
.upload-button {
    background: var(--btn-green);
    color: white;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 12px 24px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    margin: 20px auto 0;
    min-width: 160px;
    font-weight: 500;
    width: 100%;
    max-width: 200px;
    opacity: 0.7;
}

.upload-button:hover:not(:disabled) {
    background: var(--btn-green-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.upload-button:disabled {
    background: var(--btn-green);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.2;
}

.upload-button:not(:disabled) {
    opacity: 1;
}

.upload-button:focus:not(:disabled) {
    outline: none;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.3);
}

.upload-button:active:not(:disabled) {
    transform: translateY(0);
}

/* Progress Bar */
#progressContainer {
    display: none;
    margin-top: 15px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--mborder);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: var(--btn-blue);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    color: var(--mdesc);
    font-size: 1em;
    text-align: center;
}

/* ============================================
   Files Section
   ============================================ */
.files-section {
    max-width: 900px;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 0 auto;
    width: 100%;
}

.files-container-wrapper {
    flex: 1;
    overflow: hidden;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    padding: 0 10px;
}

#filesContainer {
    height: 100%;
    overflow: auto;
    padding-right: 5px;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
}

/* Custom scrollbar */
#filesContainer::-webkit-scrollbar {
    width: 8px;
}

#filesContainer::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

#filesContainer::-webkit-scrollbar-thumb {
    background: var(--mborder);
    border-radius: 4px;
}

#filesContainer::-webkit-scrollbar-thumb:hover {
    background: var(--mdesc);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--mdesc);
    max-width: 800px;
    margin: 0 auto;
}

.empty-message {
    font-size: 1.3em;
    margin-bottom: 15px;
    color: var(--mapp);
    font-weight: 500;
}

.empty-submessage {
    font-size: 1.1em;
    opacity: 0.8;
}

/* ============================================
   Table Styles (Fixed Header Solution)
   ============================================ */
#filesContainer {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

.files-table-header-fixed {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(135deg, var(--msbkg) 0%, var(--mbkg) 100%);
    border-bottom: 2px solid var(--mborder);
    width: 100%;
    min-width: 800px;
}

.files-table-body-scrollable {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    max-height: calc(100vh - 400px);
    width: 100%;
}

/* Tables */
.files-table-header-fixed .files-table,
.files-table-body-scrollable .files-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

/* Header */
.files-table-header-fixed .files-table thead {
    display: table;
    width: 100%;
}

.files-table-header-fixed .files-table th {
    padding: 16px 12px;
    text-align: left;
    color: var(--mapp);
    font-weight: 600;
    font-size: 0.95em;
    white-space: nowrap;
    background: var(--msbkg);
}

/* Body */
.files-table-body-scrollable .files-table tbody {
    display: block;
}

.files-table-body-scrollable .files-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
    border-bottom: 1px solid var(--mborder);
    transition: all 0.2s ease;
}

.files-table-body-scrollable .files-table td {
    padding: 8px 12px;
    vertical-align: middle;
}

/* Column widths */
.files-table-header-fixed .file-name-column,
.files-table-body-scrollable .file-name-cell {
    width: 30%;
}

.files-table-header-fixed .file-size-column,
.files-table-body-scrollable .file-size-cell {
    width: 15%;
}

.files-table-header-fixed .file-date-column,
.files-table-body-scrollable .file-date-cell {
    width: 20%;
}

.files-table-header-fixed .file-time-column,
.files-table-body-scrollable .file-time-cell {
    width: 15%;
}

.files-table-header-fixed .file-actions-column,
.files-table-body-scrollable .file-actions-cell {
    width: 15%;
}

/* Cell content */
.file-name-cell {
    min-width: 100px;
    max-width: 250px;
}

.file-name {
    color: var(--mapp);
    font-weight: 500;
    word-break: break-all;
    line-height: 1.2;
}

.file-size-cell,
.file-date-cell,
.file-time-cell {
    min-width: 90px;
    white-space: nowrap;
}

.file-size,
.file-date,
.file-time {
    color: var(--mdesc);
    font-size: 0.95em;
}

.file-actions-cell {
    min-width: 180px;
    text-align: right;
}

/* Action buttons */
.files-table-body-scrollable .file-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.file-action-button {
    padding: 6px 6px;
    min-width: 80px;
    font-size: 0.9em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.download-button {
    background: var(--btn-blue);
    color: white;
    opacity: 0.8;
}

.download-button:hover {
    background: var(--btn-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.delete-button {
    background: var(--btn-red);
    color: white;
    opacity: 0.8;
}

.delete-button:hover {
    background: var(--btn-red-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Delete Confirmation Modal
   ============================================ */
.delete-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.delete-modal {
    background: linear-gradient(135deg, var(--msbkg) 0%, var(--mbkg) 100%);
    border: 1px solid var(--mborder);
    border-radius: 12px;
    padding: 20px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideUpScale 0.4s ease forwards;
}

.delete-modal-header {
    margin-bottom: 15px;
    text-align: center;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--mborder);
}

.delete-modal-title {
    color: var(--mapp);
    font-size: 1.4em;
    font-weight: 600;
    margin: 0 0 15px;
}

.delete-modal-message {
    color: var(--mdesc);
    font-size: 1em;
    line-height: 1.5;
    text-align: center;
    margin: 0;
}

.delete-modal-filename {
    color: var(--mapp);
    font-weight: 600;
    background: var(--imgbkg);
    padding: 10px 15px;
    border-radius: 8px;
    margin: 15px 0;
    word-break: break-all;
    border-left: 3px solid var(--btn-red);
    font-size: 0.95em;
}

.delete-modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
}

.delete-modal-button {
    padding: 12px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    min-width: 120px;
    transition: all 0.2s ease;
}

.delete-modal-cancel {
    background: var(--btn-grey);
    color: white;
}

.delete-modal-cancel:hover {
    background: var(--btn-grey-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.delete-modal-confirm {
    background: var(--btn-red);
    color: white;
}

.delete-modal-confirm:hover {
    background: var(--btn-red-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.delete-modal-button:active {
    transform: translateY(0);
}

.delete-modal-button:disabled {
    background: var(--btn-grey);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================
   Alert System
   ============================================ */
.alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    max-width: 350px;
}

.alert {
    background: linear-gradient(135deg, var(--msbkg) 0%, var(--mbkg) 100%);
    border: 1px solid var(--mborder);
    border-radius: 12px;
    padding: 10px 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease forwards;
}

.alert-success {
    border-left: 4px solid var(--btn-green);
}

.alert-error {
    border-left: 4px solid var(--btn-red);
}

.alert-info {
    border-left: 4px solid var(--btn-blue);
}

.alert-title {
    color: var(--mapp);
    font-weight: 500;
    margin: 0 0 8px;
    font-size: 1.2em;
}

.alert-message {
    color: var(--mdesc);
    font-size: 1em;
    line-height: 1.5;
    margin: 0;
}

/* ============================================
   Footer
   ============================================ */
.footer {
    position: fixed;
    bottom: 0.2em;
    left: 0;
    right: 0;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--mborder);
    background: transparent;
    padding: 0 10%;
    z-index: 10;
    flex-shrink: 0;
}

.footer-btn {
    display: inline-flex;
    text-decoration: none;
    align-items: center;
    background: transparent;
    color: var(--mborder);
    border: none;
    font-size: 12px;
    cursor: pointer;
}

.footer-btn:hover {
    color: var(--mdesc);
}

/* ============================================
   Body Visibility Transition
   ============================================ */
.body_hide {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.body_visible {
    opacity: 1;
}

/* ============================================
   Animations
   ============================================ */
@keyframes pulse {
    0%, 100% { 
        border-color: var(--btn-blue-hover);
    }
    50% { 
        border-color: var(--btn-blue);
    }
}

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

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUpScale {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 900px) {
    .footer {
        display: none;
    }
    
    .files-table-header-fixed,
    .files-table-body-scrollable .files-table {
        min-width: 900px;
    }
    
    .files-table-body-scrollable {
        max-height: calc(100vh - 350px);
    }
    
    .file-manager-title {
        font-size: 2em;
    }
    
    .upload-area-wrapper {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    .footer {
        display: none;
    }
    
    .mainpage {
        width: 98%;
        padding: 0 10px 60px;
    }
    
    .upload-area {
        padding: 20px;
    }
    
    .header-logo {
        width: 18px;
        height: 18px;
    }
    
    .file-manager-title {
        font-size: 1.8em;
    }
    
    .files-table-header-fixed,
    .files-table-body-scrollable .files-table {
        min-width: 650px;
    }
    
    .files-table-body-scrollable {
        max-height: calc(100vh - 320px);
    }
    
    .drag-drop-zone {
        padding: 30px 15px;
        min-height: 80px;
    }
    
    .drag-drop-highlight {
        font-size: 1.1em;
    }
    
    .upload-button {
        padding: 10px 20px;
        min-width: 140px;
        font-size: 1em;
        margin: 15px auto 0;
    }
    
    .delete-modal {
        padding: 25px;
        width: 95%;
    }
    
    .delete-modal-title {
        font-size: 1.2em;
    }
    
    .delete-modal-button {
        padding: 10px 20px;
        min-width: 100px;
        font-size: 0.95em;
    }
}

@media (max-width: 480px) {
    .footer {
        display: none;
    }
    
    .file-manager-title {
        font-size: 1.6em;
    }
    
    .header-logo {
        width: 16px;
        height: 16px;
    }
    
    .file-manager-subtitle {
        font-size: 0.95em;
        margin-bottom: 20px;
    }
    
    .upload-area {
        padding: 15px;
    }
    
    .upload-instructions {
        font-size: 0.9em;
    }
    
    .drag-drop-zone {
        padding: 20px 10px;
        min-height: 70px;
    }
    
    .drag-drop-highlight {
        font-size: 1em;
    }
    
    .upload-button {
        padding: 10px 15px;
        min-width: 120px;
        font-size: 0.95em;
        margin: 10px auto 0;
    }
    
    .delete-modal {
        padding: 20px;
    }
    
    .delete-modal-actions {
        flex-direction: column;
    }
    
    .delete-modal-button {
        width: 100%;
    }
}