*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-hover: #22263a;
    --border: #2d3348;
    --text: #e8eaef;
    --text-muted: #8b93a7;
    --primary: #5b8def;
    --primary-hover: #4a7de0;
    --danger: #ef5b5b;
    --success: #5bef8d;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Auth pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: radial-gradient(ellipse at top, #1a2240 0%, var(--bg) 60%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow);
}

.auth-card h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-card .subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--primary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 91, 91, 0.1);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.error-message {
    background: rgba(239, 91, 91, 0.12);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: none;
}

.error-message.visible {
    display: block;
}

/* Dashboard */
.dashboard {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.header h1 {
    font-size: 1.5rem;
}

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

.user-email {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.storage-bar-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.storage-bar-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.storage-bar-header span:last-child {
    color: var(--text-muted);
}

.storage-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7b5bef);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    margin-bottom: 24px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(91, 141, 239, 0.05);
}

.upload-zone p {
    color: var(--text-muted);
    margin-top: 8px;
    font-size: 0.9rem;
}

.upload-zone .icon {
    font-size: 2rem;
}

.upload-progress-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.upload-progress-list .upload-progress-item {
    margin-bottom: 0;
}

.upload-progress-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 24px;
    margin-bottom: 24px;
}

.upload-progress-panel.hidden {
    display: none;
}

.upload-progress-title {
    font-weight: 600;
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.upload-progress-item {
    margin-bottom: 16px;
}

.upload-progress-item:last-child {
    margin-bottom: 0;
}

.upload-progress-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.upload-progress-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.upload-cancel-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    line-height: 1.2;
}

.upload-progress-item.cancelled .upload-progress-meta {
    color: var(--text-muted);
}

.upload-progress-filename {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.upload-progress-stats {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.upload-progress-bar {
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #7b5bef);
    border-radius: 3px;
    width: 0%;
    transition: width 0.15s ease;
}

.upload-progress-bar-fill.indeterminate {
    width: 35% !important;
    animation: upload-indeterminate 1.4s ease-in-out infinite;
}

@keyframes upload-indeterminate {
    0% { margin-left: 0; }
    50% { margin-left: 65%; }
    100% { margin-left: 0; }
}

.upload-progress-meta {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.file-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.file-list-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    gap: 16px;
    transition: background 0.15s;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background: var(--surface-hover);
}

.file-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.file-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 0.9rem;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: var(--success);
}

@media (max-width: 600px) {
    .file-item {
        flex-wrap: wrap;
    }

    .file-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
