/* ==================== CSS VARIABLES ==================== */
:root {
    --bg-primary: #0a0a14;
    --bg-secondary: #12121f;
    --bg-card: rgba(22, 22, 38, 0.85);
    --bg-card-hover: rgba(30, 30, 52, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-strong: rgba(255, 255, 255, 0.08);
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f0f8;
    --text-secondary: #8888a8;
    --text-muted: #5a5a78;
    --accent-primary: #6c5ce7;
    --accent-secondary: #a55eea;
    --accent-gradient: linear-gradient(135deg, #6c5ce7 0%, #a55eea 50%, #e056a0 100%);
    --accent-gradient-subtle: linear-gradient(135deg, rgba(108, 92, 231, 0.15) 0%, rgba(165, 94, 234, 0.15) 100%);
    --danger: #ff6b6b;
    --danger-bg: rgba(255, 107, 107, 0.12);
    --success: #51cf66;
    --success-bg: rgba(81, 207, 102, 0.12);
    --warning: #ffd43b;
    --fab-photo: #6c5ce7;
    --fab-video: #e056a0;
    --fab-gallery: #00b894;
    --fab-scanner: #fd9644;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.25);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==================== RESET & BASE ==================== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-user-select: none;
    user-select: none;
}

input,
button,
textarea {
    font-family: var(--font);
    border: none;
    outline: none;
}

img,
video {
    display: block;
    max-width: 100%;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ==================== SCREEN MANAGEMENT ==================== */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    transition: opacity 0.35s ease, transform 0.35s ease;
    z-index: 1;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(30px);
    z-index: 0;
}

.screen.slide-out {
    opacity: 0;
    transform: translateX(-30px);
}

/* ==================== WELCOME SCREEN ==================== */
.welcome-container {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 2rem;
    text-align: center;
}

.welcome-icon-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 30px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-glow);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.welcome-icon {
    font-size: 48px;
    color: white;
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.4rem;
    letter-spacing: -0.5px;
}

.welcome-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    font-weight: 400;
}

.welcome-form {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-bg-orbs {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
}

.orb-1 {
    width: 300px;
    height: 300px;
    background: #6c5ce7;
    top: -80px;
    right: -60px;
    animation: orbMove1 8s ease-in-out infinite;
}

.orb-2 {
    width: 250px;
    height: 250px;
    background: #e056a0;
    bottom: 10%;
    left: -50px;
    animation: orbMove2 10s ease-in-out infinite;
}

.orb-3 {
    width: 200px;
    height: 200px;
    background: #00b894;
    bottom: -50px;
    right: 20%;
    animation: orbMove3 7s ease-in-out infinite;
}

@keyframes orbMove1 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(-30px, 40px);
    }
}

@keyframes orbMove2 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(40px, -30px);
    }
}

@keyframes orbMove3 {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(-20px, -40px);
    }
}

/* ==================== INPUT GROUP ==================== */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 22px;
    pointer-events: none;
    transition: color var(--transition);
}

.input-group input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    border-radius: var(--radius-md);
    background: var(--bg-glass-strong);
    border: 1.5px solid var(--border-medium);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    transition: all var(--transition);
}

.input-group input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.input-group input:focus {
    border-color: var(--accent-primary);
    background: rgba(108, 92, 231, 0.08);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.input-group input:focus+.input-icon,
.input-group input:focus~.input-icon {
    color: var(--accent-primary);
}

/* ==================== BUTTONS ==================== */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    transition: background var(--transition);
}

.btn-primary:hover::before {
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary:disabled::before {
    display: none;
}

.btn-secondary {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass-strong);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
    border-color: var(--border-subtle);
}

.btn-danger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    background: var(--danger);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-danger:active {
    transform: scale(0.97);
}

.btn-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--bg-glass-strong);
    color: var(--text-primary);
}

.btn-icon .material-icons-round {
    font-size: 22px;
}

/* ==================== APP HEADER ==================== */
.app-header {
    padding: 16px 20px 12px;
    background: rgba(10, 10, 20, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.header-info {
    flex: 1;
    min-width: 0;
}

.header-title {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-greeting {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.header-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.detail-header .header-top {
    margin-bottom: 0;
}

/* ==================== SEARCH BAR ==================== */
.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 20px;
    pointer-events: none;
    transition: color var(--transition);
}

.search-bar input {
    width: 100%;
    padding: 10px 40px 10px 42px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass-strong);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 400;
    transition: all var(--transition);
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-bar input:focus {
    border-color: var(--accent-primary);
    background: rgba(108, 92, 231, 0.06);
}

.search-bar input:focus~.search-icon {
    color: var(--accent-primary);
}

.btn-clear-search {
    position: absolute;
    right: 6px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-clear-search .material-icons-round {
    font-size: 18px;
}

.btn-clear-search:hover {
    background: var(--bg-glass-strong);
    color: var(--text-primary);
}

/* ==================== FOLDERS LIST VIEW ==================== */
.folders-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 100px;
}

.folders-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.folder-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

.folder-row::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition);
}

.folder-row:hover,
.folder-row:active {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
}

.folder-row:hover::before,
.folder-row.long-pressing::before {
    opacity: 1;
}

.folder-row.long-pressing {
    transform: scale(0.98);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.folder-row-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.folder-row-icon .material-icons-round {
    font-size: 22px;
    color: var(--accent-secondary);
}

.folder-row-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.folder-row-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-row-details {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.folder-row-detail {
    display: flex;
    align-items: center;
    gap: 3px;
}

.folder-row-detail .material-icons-round {
    font-size: 13px;
}

.folder-row-modifier {
    display: flex;
    align-items: center;
    gap: 3px;
    color: var(--accent-secondary);
    font-weight: 500;
}

.folder-row-modifier .material-icons-round {
    font-size: 13px;
}

.folder-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.folder-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.folder-action-btn .material-icons-round {
    font-size: 19px;
}

.folder-action-btn.download-btn {
    background: rgba(81, 207, 102, 0.1);
    color: var(--success);
}

.folder-action-btn.download-btn:hover {
    background: rgba(81, 207, 102, 0.2);
}

.folder-action-btn.download-btn:active {
    transform: scale(0.9);
}

.folder-action-btn.delete-btn {
    background: var(--danger-bg);
    color: var(--danger);
}

.folder-action-btn.delete-btn:hover {
    background: rgba(255, 107, 107, 0.2);
}

.folder-action-btn.delete-btn:active {
    transform: scale(0.9);
}

.folder-action-btn.download-btn.downloading {
    pointer-events: none;
    opacity: 0.5;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.folder-action-btn.downloading .material-icons-round {
    animation: spin 1s linear infinite;
}

/* ==================== MEDIA GRID ==================== */
.media-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 120px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.media-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-secondary);
    transition: transform var(--transition-fast);
}

.media-item:active {
    transform: scale(0.96);
}

.media-item img,
.media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-badge .material-icons-round {
    font-size: 16px;
    color: white;
}

.media-date {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 6px 4px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
}

/* PDF Document Thumbnail */
.media-doc-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(253, 150, 68, 0.08) 0%, rgba(224, 112, 85, 0.08) 100%);
    padding: 8px;
}

.media-doc-thumb>.material-icons-round {
    font-size: 36px;
    color: var(--fab-scanner);
}

.media-doc-name {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
    font-weight: 500;
}

.media-badge.doc-badge {
    background: rgba(253, 150, 68, 0.7);
}

/* ==================== FAB BUTTONS ==================== */
.fab {
    position: fixed;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transition: all var(--transition-bounce);
    z-index: 20;
}

.fab:hover {
    transform: scale(1.08);
}

.fab:active {
    transform: scale(0.95);
}

.fab .material-icons-round {
    font-size: 26px;
}

#addFolderFab {
    bottom: 28px;
    right: 24px;
}

.fab-group {
    position: fixed;
    bottom: 24px;
    right: 20px;
    display: flex;
    flex-direction: column-reverse;
    gap: 14px;
    z-index: 20;
}

.fab-secondary {
    width: 52px;
    height: 52px;
    position: relative;
    box-shadow: var(--shadow-md);
}

#fabCamera {
    background: var(--fab-photo);
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
}

#fabVideo {
    background: var(--fab-video);
    box-shadow: 0 4px 20px rgba(224, 86, 160, 0.4);
}

#fabGallery {
    background: var(--fab-gallery);
    box-shadow: 0 4px 20px rgba(0, 184, 148, 0.4);
}

#fabScanner {
    background: var(--fab-scanner);
    box-shadow: 0 4px 20px rgba(253, 150, 68, 0.4);
}

#fabFicha {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

.fab-secondary .material-icons-round {
    font-size: 24px;
}

/* Mobile only class */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }
}

@media (hover: none) and (pointer: coarse) {
    .mobile-only {
        display: flex;
    }
}

/* ==================== MODALS ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 20px;
    transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 28px 24px 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.25s ease;
    text-align: center;
}

.modal-overlay:not(.hidden) .modal {
    transform: scale(1);
}

.modal-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.modal-icon-wrapper.danger {
    background: var(--danger-bg);
}

.modal-icon-wrapper.danger .material-icons-round {
    color: var(--danger);
    font-size: 28px;
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal .input-group {
    margin-bottom: 12px;
}

.ficha-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.ficha-option {
    width: 100%;
}

.modal-error {
    font-size: 0.8rem;
    color: var(--danger);
    margin-bottom: 12px;
    text-align: center;
    transition: all var(--transition);
}

.modal-error.hidden {
    display: none;
}

.modal-error.shake {
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions button {
    flex: 1;
}

/* ==================== MEDIA VIEWER ==================== */
.media-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
}

.media-viewer.hidden {
    opacity: 0;
    pointer-events: none;
}

.viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.5);
}

.viewer-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: transparent;
    color: white;
}

.viewer-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.viewer-info {
    flex: 1;
    text-align: center;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.7);
}

.viewer-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
}

.viewer-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.viewer-content video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
}

/* ==================== TOAST ==================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 300;
    opacity: 0;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.hidden {
    display: none;
}

.toast-icon {
    font-size: 22px;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast.info .toast-icon {
    color: var(--accent-primary);
}

/* ==================== UPLOAD PROGRESS MODAL ==================== */
.upload-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 250;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.3s ease;
}

.upload-modal.hidden {
    display: none;
}

.upload-modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    animation: fadeInUp 0.3s ease;
}

.upload-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-gradient-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.upload-icon {
    font-size: 32px;
    color: var(--accent-secondary);
}

.upload-icon.spinning {
    animation: spin 1.5s linear infinite;
}

.upload-icon-wrapper.success {
    background: rgba(81, 207, 102, 0.15);
}

.upload-icon-wrapper.success .upload-icon {
    color: var(--success);
    animation: none;
}

.upload-icon-wrapper.error {
    background: var(--danger-bg);
}

.upload-icon-wrapper.error .upload-icon {
    color: var(--danger);
    animation: none;
}

.upload-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.upload-status {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.upload-progress-track {
    width: 100%;
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

.upload-progress-bar.success {
    background: var(--success);
    box-shadow: 0 0 10px rgba(81, 207, 102, 0.4);
}

.upload-progress-bar.error {
    background: var(--danger);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.4);
}

.upload-progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.upload-done-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.upload-done-btn.hidden {
    display: none;
}

/* ==================== LONG PRESS INDICATOR ==================== */
.long-press-indicator {
    position: fixed;
    width: 64px;
    height: 64px;
    z-index: 50;
    pointer-events: none;
    transform: translate(-50%, -50%);
    transition: opacity 0.2s ease;
}

.long-press-indicator.hidden {
    opacity: 0;
}

.long-press-indicator svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.lp-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 4;
}

.lp-progress {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 3s linear;
}

.lp-progress.animating {
    stroke-dashoffset: 0;
}

.lp-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    color: var(--accent-primary);
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 64px;
    color: var(--text-muted);
    opacity: 0.4;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    max-width: 260px;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.folder-row {
    animation: fadeInUp 0.35s ease backwards;
}

.media-item {
    animation: fadeInUp 0.3s ease backwards;
}

/* ==================== DOCUMENT SCANNER ==================== */
.scanner-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 500;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
}

.scanner-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.scanner-camera-view,
.scanner-review-view,
.scanner-pages-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
}

.scanner-review-view.hidden,
.scanner-pages-view.hidden {
    display: none;
}

.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10;
}

.scanner-btn {
    background: rgba(255, 255, 255, 0.12);
    border-color: transparent;
    color: white;
}

.scanner-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.scanner-header-title {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.scanner-page-count {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
}

/* Viewfinder */
.scanner-viewfinder {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.scanner-viewfinder video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-frame {
    position: absolute;
    top: 8%;
    left: 6%;
    right: 6%;
    bottom: 8%;
    pointer-events: none;
}

.scanner-corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: var(--fab-scanner);
    border-style: solid;
    border-width: 0;
}

.scanner-corner.tl {
    top: 0;
    left: 0;
    border-top-width: 3px;
    border-left-width: 3px;
    border-top-left-radius: 8px;
}

.scanner-corner.tr {
    top: 0;
    right: 0;
    border-top-width: 3px;
    border-right-width: 3px;
    border-top-right-radius: 8px;
}

.scanner-corner.bl {
    bottom: 0;
    left: 0;
    border-bottom-width: 3px;
    border-left-width: 3px;
    border-bottom-left-radius: 8px;
}

.scanner-corner.br {
    bottom: 0;
    right: 0;
    border-bottom-width: 3px;
    border-right-width: 3px;
    border-bottom-right-radius: 8px;
}

.scanner-guide-text {
    position: absolute;
    bottom: 2%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
    backdrop-filter: blur(4px);
}

/* Bottom bar with capture button */
.scanner-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 20px 32px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
}

.scanner-action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.scanner-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.scanner-action-btn .material-icons-round {
    font-size: 24px;
}

.scanner-capture-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: transparent;
    border: 3px solid rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
}

.scanner-capture-btn:hover {
    border-color: white;
    transform: scale(1.05);
}

.scanner-capture-btn:active {
    transform: scale(0.95);
}

.capture-ring {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.scanner-capture-btn:active .capture-ring {
    transform: scale(0.9);
    opacity: 0.8;
}

.capture-dot {
    display: none;
}

/* Scanner flash animation */
@keyframes scannerFlash {
    0% {
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.scanner-viewfinder::after {
    content: '';
    position: absolute;
    inset: 0;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
}

.scanner-viewfinder.flash::after {
    animation: scannerFlash 0.3s ease-out;
}

/* Review / Edit View */
.scanner-preview-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
    background: #0a0a0a;
}

.scanner-preview-area canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.scanner-edit-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 14px 12px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    overflow-x: auto;
}

.scanner-edit-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    white-space: nowrap;
    min-width: 62px;
}

.scanner-edit-btn .material-icons-round {
    font-size: 22px;
}

.scanner-edit-btn span:last-child {
    font-size: 0.68rem;
    font-weight: 500;
}

.scanner-edit-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.scanner-edit-btn.active {
    color: var(--fab-scanner);
    background: rgba(253, 150, 68, 0.12);
    border-color: rgba(253, 150, 68, 0.3);
}

/* Pages View */
.scanner-pages-view {
    background: var(--bg-primary);
}

.scanner-pages-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    align-content: start;
}

.scanner-page-thumb {
    position: relative;
    aspect-ratio: 0.707;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all var(--transition);
    animation: fadeInUp 0.3s ease backwards;
}

.scanner-page-thumb:hover {
    border-color: var(--fab-scanner);
    box-shadow: 0 0 15px rgba(253, 150, 68, 0.2);
}

.scanner-page-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-page-number {
    position: absolute;
    top: 6px;
    left: 6px;
    height: 24px;
    padding: 0 8px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: white;
}

.scanner-page-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 107, 107, 0.85);
    backdrop-filter: blur(4px);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    color: white;
}

.scanner-page-delete .material-icons-round {
    font-size: 16px;
}

.scanner-page-delete:hover {
    background: var(--danger);
    transform: scale(1.1);
}

.scanner-export-bar {
    padding: 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.scanner-name-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-glass-strong);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

.scanner-name-input-group .material-icons-round {
    font-size: 22px;
    color: var(--fab-scanner);
    flex-shrink: 0;
}

.scanner-name-input-group input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-weight: 500;
    outline: none;
}

.scanner-name-input-group input::placeholder {
    color: var(--text-muted);
}

.scanner-export-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    gap: 8px;
    background: linear-gradient(135deg, #fd9644 0%, #e17055 100%);
}

.scanner-export-btn:hover::before {
    background: rgba(255, 255, 255, 0.1);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
    .media-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 3px;
    }

    .welcome-title {
        font-size: 2rem;
    }

    .header-title {
        font-size: 1.2rem;
    }

    .folder-row-actions {
        gap: 4px;
    }

    .folder-action-btn {
        width: 32px;
        height: 32px;
    }

    .folder-action-btn .material-icons-round {
        font-size: 17px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .media-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 769px) {
    .media-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .media-item {
        border-radius: 8px;
    }

    .folders-list {
        max-width: 800px;
        margin: 0 auto;
    }
}

@media (min-width: 1024px) {
    .media-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}
