/* ============================================
   ExosWeb - Style moderne violet & blanc
   ============================================ */

:root {
    /* Couleurs principales */
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #5b21b6;
    --primary-gradient: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    
    /* Couleurs neutres */
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    
    /* Couleurs d'état */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    /* Ombres */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Bordures */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    
    /* Transitions */
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgb(124 58 237 / 0.3));
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--gray-500);
    font-size: 1.125rem;
    margin-top: 0.5rem;
}

/* Main content */
main {
    flex: 1;
}

/* Upload Section */
.upload-section {
    margin-bottom: 3rem;
}

.upload-area {
    background: var(--white);
    border: 2px dashed var(--primary-light);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--primary-gradient);
    opacity: 0;
    transition: var(--transition);
}

.upload-area:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.upload-area:hover::before {
    opacity: 0.03;
}

.upload-area.drag-over {
    border-color: var(--primary);
    background: rgb(124 58 237 / 0.05);
    transform: scale(1.02);
}

.upload-icon {
    color: var(--primary);
    margin-bottom: 1rem;
    position: relative;
}

.upload-area h2 {
    font-size: 1.5rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    position: relative;
}

.upload-area p {
    color: var(--gray-400);
    margin-bottom: 1rem;
    position: relative;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--gray-400);
    margin-top: 1rem;
}

/* Progress */
.upload-progress {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: var(--shadow);
}

.progress-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 100px;
    width: 0%;
    transition: width 0.3s ease;
}

#uploadStatus {
    font-size: 0.875rem;
    color: var(--gray-600);
    text-align: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    position: relative;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--white);
    box-shadow: 0 4px 14px rgb(124 58 237 / 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgb(124 58 237 / 0.5);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--gray-100);
    color: var(--gray-600);
    border-radius: var(--radius);
}

.btn-icon:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
}

.btn-danger:hover {
    background: var(--danger);
    color: var(--white);
}

/* Files Section */
.files-section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.file-count {
    background: var(--primary);
    color: var(--white);
    padding: 0.375rem 1rem;
    border-radius: 100px;
    font-size: 0.875rem;
    font-weight: 600;
}

/* Empty State */
.empty-state {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 4rem 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.empty-state svg {
    color: var(--gray-300);
    margin-bottom: 1.5rem;
}

.empty-state p {
    font-size: 1.25rem;
    color: var(--gray-600);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state span {
    color: var(--gray-400);
    font-size: 0.9375rem;
}

/* Files Grid */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* File Card */
.file-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.file-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.file-preview {
    aspect-ratio: 16/10;
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-slow);
}

.file-card:hover .file-preview img {
    transform: scale(1.05);
}

.file-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

.file-ext {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--primary);
    color: var(--white);
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
}

.file-info {
    padding: 1rem 1.25rem;
    flex: 1;
}

.file-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
    color: var(--gray-400);
}

.file-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

/* Error Section */
.error-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.error-content {
    text-align: center;
}

.error-code {
    font-size: 8rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.5rem;
    color: var(--gray-600);
    margin-bottom: 2rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: var(--white);
    padding: 1rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    transition: var(--transition-slow);
    z-index: 1000;
    font-weight: 500;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--gray-400);
    font-size: 0.875rem;
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .logo {
        width: 44px;
        height: 44px;
    }

    .upload-area {
        padding: 2rem 1.5rem;
    }

    .upload-area h2 {
        font-size: 1.25rem;
    }

    .files-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .error-code {
        font-size: 5rem;
    }
}

/* Animation keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-card {
    animation: fadeIn 0.3s ease forwards;
}

/* ============================================
   Admin Code Input (page principale)
   ============================================ */

.admin-code-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    justify-content: center;
    padding: 1rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.admin-code-section label {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
}

.admin-code-input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.875rem;
    width: 140px;
    transition: var(--transition);
}

.admin-code-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(124 58 237 / 0.1);
}

.admin-code-input.valid {
    border-color: var(--success);
    background: rgb(16 185 129 / 0.05);
}

.admin-link {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    font-size: 0.75rem;
    color: var(--gray-400);
    text-decoration: none;
    opacity: 0.5;
    transition: var(--transition);
}

.admin-link:hover {
    opacity: 1;
    color: var(--primary);
}

/* ============================================
   Login Page
   ============================================ */

.login-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.login-card {
    background: var(--white);
    padding: 3rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-icon {
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.login-card h2 {
    font-size: 1.5rem;
    color: var(--gray-800);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(124 58 237 / 0.1);
}

.error-message {
    background: rgb(239 68 68 / 0.1);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.btn-full {
    width: 100%;
}

.back-link {
    display: inline-block;
    margin-top: 1.5rem;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--primary);
}

/* ============================================
   Admin Dashboard
   ============================================ */

.admin-container {
    max-width: 1400px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.admin-badge {
    background: var(--primary);
    color: var(--white);
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    vertical-align: middle;
    font-weight: 600;
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: var(--white);
}

/* Stats Overview */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-gradient);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Extension Stats */
.extension-stats {
    margin-bottom: 2rem;
}

.extension-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.extension-card {
    background: var(--white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.extension-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.ext-badge {
    background: var(--primary-gradient);
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.ext-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ext-count {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.875rem;
}

.ext-size {
    font-size: 0.75rem;
    color: var(--gray-400);
}

.btn-danger-small {
    width: 28px;
    height: 28px;
    padding: 0;
    background: rgb(239 68 68 / 0.1);
    color: var(--danger);
    border-radius: var(--radius-sm);
}

.btn-danger-small:hover {
    background: var(--danger);
    color: var(--white);
}

/* Filters */
.filters-section {
    margin-bottom: 1.5rem;
}

.filters-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    transition: var(--transition);
    background: var(--white);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(124 58 237 / 0.1);
}

.filter-buttons {
    display: flex;
    gap: 0.75rem;
}

.filter-buttons select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
}

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

/* Files Table */
.files-table-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.files-table th {
    background: var(--gray-50);
    padding: 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
}

.files-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
    color: var(--gray-700);
}

.files-table tbody tr:hover {
    background: var(--gray-50);
}

.files-table tbody tr:last-child td {
    border-bottom: none;
}

.preview-cell {
    width: 60px;
}

.preview-thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.file-type-icon {
    width: 48px;
    height: 48px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
}

.name-cell {
    max-width: 250px;
}

.name-cell a {
    color: var(--gray-800);
    text-decoration: none;
    font-weight: 500;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.name-cell a:hover {
    color: var(--primary);
}

.ext-tag {
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.ip-cell code {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    background: var(--gray-100);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    color: var(--gray-600);
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn-icon {
    width: 32px;
    height: 32px;
}

.loading, .empty-message {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 0.75rem;
    color: var(--gray-800);
}

.modal-content p {
    color: var(--gray-600);
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Responsive Admin */
@media (max-width: 768px) {
    .header-row {
        flex-direction: column;
        text-align: center;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
    }

    .filters-row {
        flex-direction: column;
    }

    .search-box {
        width: 100%;
    }

    .filter-buttons {
        width: 100%;
    }

    .filter-buttons select {
        flex: 1;
    }

    .files-table-container {
        overflow-x: auto;
    }

    .files-table {
        min-width: 700px;
    }
}
