/* ========================================
   FUJI Share - Estilos
   Diseño minimalista blanco con ondas
   ======================================== */

:root {
    /* Paleta de colores - Tema claro */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f0f1f3;
    --bg-hover: #e9eaec;
    
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: rgba(37, 99, 235, 0.1);
    --accent-glow: rgba(37, 99, 235, 0.08);
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    
    --error: #ef4444;
    --error-light: rgba(239, 68, 68, 0.1);
    
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    
    /* Ondas */
    --wave-color: rgba(37, 99, 235, 0.12);
    
    /* Tipografía */
    --font-main: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    
    /* Espaciado */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Bordes */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Transiciones */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

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

html, body {
    height: 100%;
    height: 100dvh; /* Dynamic viewport height */
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100%;
    min-height: 100dvh;
}

/* ========================================
   DRAG OVERLAY - Toda la pantalla
   ======================================== */

.drag-overlay {
    position: fixed;
    inset: 0;
    background: rgba(37, 99, 235, 0.03);
    border: 3px dashed var(--accent);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.drag-overlay.active {
    display: flex;
}

.drag-overlay-content {
    text-align: center;
    color: var(--accent);
}

.drag-overlay-content svg {
    margin-bottom: var(--spacing-sm);
    opacity: 0.8;
}

.drag-overlay-content p {
    font-size: 1.25rem;
    font-weight: 500;
}

/* Indicador visual cuando se arrastra */
body.dragover {
    background: rgba(37, 99, 235, 0.02);
}

/* Container principal */
.container {
    max-width: 340px;
    margin: 0 auto;
    padding: var(--spacing-md);
    min-height: 100%;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    z-index: 1;
}

/* Estados */
.state {
    display: none;
    animation: fadeIn var(--transition-normal) ease;
}

.state.active {
    display: flex;
    flex-direction: column;
}

#state-idle.active {
    display: block;
}

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

/* ========================================
   ESTADO IDLE - Logo centrado
   ======================================== */

#state-idle {
    text-align: center;
}

.logo-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    height: 160px;
}

.logo-waves {
    position: absolute;
    width: 100px;
    height: 100px;
}

.wave {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--wave-color);
    animation: wave-expand 3s ease-out infinite;
}

.wave:nth-child(1) { animation-delay: 0s; }
.wave:nth-child(2) { animation-delay: 0.6s; }
.wave:nth-child(3) { animation-delay: 1.2s; }
.wave:nth-child(4) { animation-delay: 1.8s; }
.wave:nth-child(5) { animation-delay: 2.4s; }

@keyframes wave-expand {
    0% {
        width: 100%;
        height: 100%;
        opacity: 0.5;
    }
    100% {
        width: 280%;
        height: 280%;
        opacity: 0;
    }
}

.logo-circle {
    position: relative;
    width: 80px;
    height: 80px;
    background: var(--bg-primary);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 4px 24px rgba(0, 0, 0, 0.08),
        0 0 0 1px var(--border);
    z-index: 2;
}

.logo-circle img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* Contenido idle */
.idle-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
}

.idle-hint {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: var(--spacing-lg);
}

.select-file-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: var(--spacing-sm) var(--spacing-md);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.select-file-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.select-file-btn:active {
    transform: scale(0.98);
}

.size-warning {
    margin-top: var(--spacing-md);
    color: var(--error);
    font-size: 0.85rem;
    min-height: 1.5em;
}

/* ========================================
   ESTADO UPLOADING
   ======================================== */

#state-uploading {
    display: none;
}

#state-uploading.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.uploading-box {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    border: 1px solid var(--border);
    width: 100%;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto var(--spacing-md);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.uploading-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
}

.uploading-filename {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md);
    word-break: break-all;
}

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

.progress-fill {
    background: var(--accent);
    height: 100%;
    width: 0%;
    border-radius: 100px;
    transition: width var(--transition-fast);
}

/* ========================================
   ESTADO SUCCESS
   ======================================== */

/* Success box - Sutil */
.success-box {
    text-align: center;
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.success-icon {
    color: var(--success);
    display: flex;
    align-items: center;
}

.success-icon svg {
    width: 24px;
    height: 24px;
}

.success-box h2 {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.success-filename {
    display: block;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 500;
    word-break: break-all;
    text-align: center;
    margin-bottom: var(--spacing-sm);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.success-filename:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* QR Section */
.qr-section {
    text-align: center;
    margin-bottom: var(--spacing-sm);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

.qr-section h3 {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
}

.qr-container {
    background: white;
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    display: inline-block;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
}

#qr-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.qr-hint {
    margin-top: var(--spacing-xs);
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Manual Code Section */
.manual-section {
    margin-bottom: var(--spacing-sm);
}

.manual-divider {
    display: flex;
    align-items: center;
    margin-bottom: var(--spacing-xs);
}

.manual-divider::before,
.manual-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.manual-divider span {
    padding: 0 var(--spacing-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.manual-hint {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
    margin-bottom: var(--spacing-xs);
}

.manual-code-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.manual-code {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent);
    word-break: break-all;
    user-select: all;
    cursor: text;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-family: var(--font-main);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

.copy-btn:hover {
    background: var(--accent-hover);
}

.copy-btn:active {
    transform: scale(0.98);
}

.copy-feedback {
    text-align: center;
    font-size: 0.75rem;
    color: var(--success);
    min-height: 1em;
    margin-top: 4px;
}

/* Reset Button */
.reset-btn {
    width: 100%;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px var(--spacing-md);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.reset-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

/* ========================================
   ESTADO ERROR
   ======================================== */

#state-error {
    display: none;
}

#state-error.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.error-box {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    border: 1px solid var(--error);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.error-box::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--error-light);
}

.error-icon {
    color: var(--error);
    margin-bottom: var(--spacing-sm);
    position: relative;
}

.error-box h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    position: relative;
    color: var(--text-primary);
}

.error-message {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md);
    position: relative;
}

.retry-btn {
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-lg);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.retry-btn:hover {
    filter: brightness(1.1);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 380px) {
    .container {
        padding: var(--spacing-md) var(--spacing-sm);
    }
    
    .idle-content h1 {
        font-size: 1.35rem;
    }
    
    .logo-container {
        height: 140px;
    }
    
    .logo-circle {
        width: 70px;
        height: 70px;
    }
    
    .logo-circle img {
        width: 42px;
        height: 42px;
    }
    
    .logo-waves {
        width: 80px;
        height: 80px;
    }
    
    .manual-code-box {
        flex-direction: column;
    }
    
    .manual-code {
        text-align: center;
        font-size: 0.75rem;
    }
    
    .copy-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Soporte para preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .wave {
        animation: none !important;
        opacity: 0.2;
    }
}
