/**
 * Solwater PRO - UX/UI Expert Design v7.0.0
 * Dark Mode Premium | Industrial Precision
 */

:root {
    --bg-base: #0a0f1e;
    --bg-surface: #161e31;
    --bg-item: #1e293b;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.4);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-dim: rgba(255, 255, 255, 0.08);
    --border-bright: rgba(255, 255, 255, 0.15);
    --success: #10b981;
    --danger: #f43f5e;
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
    --glass-bg: rgba(10, 15, 30, 0.7);
    --radius-lg: 24px;
    --radius-md: 16px;
}

* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding-top: var(--safe-top);
    line-height: 1.4;
    overflow-x: hidden;
}

.app-container {
    max-width: 1100px;
    margin: 10px auto;
    padding: 0 12px;
    padding-bottom: calc(90px + var(--safe-bottom));
}

/* Header Premium Glassmorphism */
.app-header {
    background: var(--glass-bg);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    padding: calc(16px + var(--safe-top)) 20px 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 2000;
    border-bottom: 1px solid var(--border-dim);
    margin: 0 -20px;
}



/* View Headers contextuales */
.view-header {
    padding: 0px 10px 10px 10px;
    position: relative;
    margin-bottom: 0px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 42px;
}

.header-side {
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.header-center {
    flex: 1;
    text-align: center;
}

.view-header h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 2px 0;
    letter-spacing: -1px;
}

.view-header p {
    font-size: 0.6rem;
    color: var(--accent);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    font-weight: 700;
    opacity: 0.9;
}

.view-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.view-actions .btn {
    border-radius: 12px;
    font-size: 0.6rem;
    padding: 8px 16px;
    height: auto;
    font-weight: 800;
    letter-spacing: 1px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Listas y Tarjetas Premium */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 10px;
}

.ux-card {
    background: linear-gradient(145deg, var(--bg-surface), #0f172a);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.2s;
    width: 90%;
    margin: auto;
    z-index: 9;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.ux-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.05), transparent 60%);
    pointer-events: none;
}

.ux-card.is-pressed {
    transform: scale(0.97);
    border-color: var(--accent);
}

/* Desactivar interactividad en tarjeta de resultados para no obstruir botones */
.ux-card.results-card:active {
    transform: none !important;
    border-color: var(--border-dim) !important;
}

.results-card .card-body {
    cursor: default !important;
}

.card-body {
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.card-info strong {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.card-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.card-badge {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 800;
    border: 1px solid var(--accent-glow);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Accordion Styles */
.ux-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s;
    background: rgba(0, 0, 0, 0.15);
}

.ux-card.expanded .ux-accordion-content {
    max-height: 2000px;
    /* Suficiente para el grid y análisis de IA */
    padding-bottom: 20px;
}

.ux-card.expanded {
    border-color: var(--accent-glow);
    background: linear-gradient(145deg, var(--bg-surface), #1e293b);
    z-index: 10;
}

.ux-chevron-icon {
    transition: transform 0.3s !important;
    color: var(--text-secondary) !important;
    transform: rotate(0deg) !important;
    display: inline-block !important;
}

.ux-card.expanded .ux-chevron-icon {
    transform: rotate(90deg) !important;
    color: var(--accent) !important;
}

/* Photo & Asset Grids (inside accordion) */
.ux-photos,
.ux-assets {
    padding: 10px 18px 18px 18px;
    position: relative;
    z-index: 1;
    max-height: 250px;
    display: flex;
    flex-direction: column;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 12px;
}

.asset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 100px);
    gap: 12px;
}

.photo-slot,
.asset-slot {
    background: rgba(10, 15, 30, 0.5);
    border: 1px solid var(--border-dim);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.photo-slot {
    aspect-ratio: 1/1;
}

.asset-slot {
    height: 100px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.2s;
    position: relative;
}

.photo-slot:active,
.asset-slot:active {
    transform: scale(0.92);
    border-color: var(--accent);
    background: rgba(56, 189, 248, 0.05);
}

.photo-slot.has-image {
    border-style: solid;
    border-color: var(--border-bright);
}

.photo-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.asset-slot span {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(--text-secondary);
    margin-top: 4px;
}

.asset-slot.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.asset-slot.active span,
.asset-slot.active i {
    color: #f43f5e;
}

/* Action Buttons Header */
.header-action-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border-dim);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
}

.header-action-btn:active {
    transform: scale(0.9);
}

/* Navigation Bar Premium */
.nav-bar {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 70px;
    background: var(--glass-bg);
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
    border: 1px solid var(--border-dim);
    border-radius: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    z-index: 3000;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    gap: 4px;
    transition: all 0.3s;
}

.nav-link.active {
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent-glow);
}

.nav-link i {
    font-size: 1.4rem;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-link span {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1;
}

/* Views & Centering */
.ux-view {
    display: none;
    position: relative;
    min-height: calc(100vh - 180px);
}

.ux-view-centered {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 180px);
    padding-bottom: 50px;
}

.ux-view-centered.active {
    display: flex;
    animation: viewSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.ux-view.active {
    display: block;
    animation: viewSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes viewSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
        filter: blur(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    background: rgba(244, 63, 94, 0.2);
    backdrop-filter: blur(5px);
    color: var(--danger) !important;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: 1px solid rgba(244, 63, 94, 0.3);
    transition: all 0.2s ease;
}

.delete-btn:active {
    background: var(--danger);
    color: white !important;
    transform: scale(0.9);
}

/* Pulse animation for active sensors */
.pulse-success {
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Premium Modals & Overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 550px;
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-title {
    font-family: 'Montserrat';
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-subtitle {
    font-size: 0.65rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    margin-top: 4px;
}

.modal-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

.modal-footer .btn {
    flex: 1;
    border-radius: 12px;
    font-weight: 800;
    font-size: 0.7rem;
}

/* Toast Notification Premium */
.toast-container {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    width: max-content;
}

.toast {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #0f172a;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 800;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    width: max-content;
    max-width: 90vw;
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s;
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s;
}

.toast.error {
    background: #fff1f2;
    color: #9f1239;
    border-color: #fda4af;
}

.toast i {
    color: var(--accent);
}

.toast.error i {
    color: #f43f5e;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ux-card.editing {
    border: 1px dashed var(--accent) !important;
    position: relative;
}

.ux-card.dragging {
    opacity: 0.5 !important;
    transform: scale(1.02);
    z-index: 1000;
}

/* Estilo Nativo iOS para Borrado - Corregido sin bordes rojos */
.delete-btn-editing {
    width: 36px;
    height: 36px;
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: 12px;
    display: none;
    opacity: 0;
    transform: scale(0.5);
    align-items: center;
    justify-content: center;
    color: var(--danger);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.is-editing .delete-btn-editing,
.editing .delete-btn-editing {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

.delete-btn-editing:active {
    transform: scale(0.9);
    background: var(--danger);
    color: white;
}

.chevron-home {
    transition: all 0.2s;
}

.is-editing .chevron-home {
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
}

/* Cleanup de estilos antiguos */
.swipe-container {
    position: relative;
    margin-bottom: 12px;
    transition: transform 0.3s;
}

.swipe-actions {
    display: none;
    /* Ocultar antiguo swipe */
}

.swipe-content {
    position: relative;
    z-index: 2;
    background: var(--bg-surface);
}

/* Botón Listo Superior */
.ready-btn {
    position: fixed;
    top: calc(16px + var(--safe-top));
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: white;
    padding: 10px 25px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 1px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    z-index: 3000;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: viewSlideIn 0.3s ease-out;
}

.floating-back,
.floating-gps {
    position: fixed;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    z-index: 4000;
    transition: all 0.3s;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.floating-back {
    left: 20px;
    top: calc(14px + var(--safe-top));
}

.floating-gps {
    right: 20px;
    top: calc(16px + var(--safe-top));
    display: none;
}

.floating-back:active,
.floating-gps:active {
    transform: scale(0.9);
    background: var(--accent);
    color: white;
}

.gps-sticky-bar {
    position: fixed;
    bottom: 100px;
    left: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 16px;
    z-index: 5;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: background 0.3s, border-color 0.3s, transform 0.3s;
}

.gps-pulse {
    width: 8px;
    height: 8px;
    background: #38bdf8;
    border-radius: 50%;
    box-shadow: 0 0 0 rgba(56, 189, 248, 0.4);
    animation: pulseGps 1.5s infinite;
}

@keyframes pulseGps {
    0% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(56, 189, 248, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(56, 189, 248, 0);
    }
}

.gps-sticky-bar.active {
    display: flex;
}

.gps-text {
    color: #38bdf8;
    /* Azul claro */
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.view-title-minimal {
    color: #38bdf8;
    text-align: center;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin: 4px 0 16px 0;
    text-transform: uppercase;
}

/* Etiqueta de Estado GPS */
.gps-status-label {
    position: fixed;
    bottom: 95px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    padding: 10px;
    z-index: 2000;
    display: none;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.gps-status-label.no-gps {
    color: var(--danger);
    display: block;
}

.gps-status-label.has-gps {
    color: #4ade80;
    /* Verde vibrante */
    display: block;
}

/* Sync Button States */
.nav-link.pending i {
    color: var(--danger);
    animation: pulseSync 2s infinite;
}

.nav-link.pending span {
    color: var(--danger);
}

@keyframes pulseSync {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.sync-badge {
    position: absolute;
    top: 10px;
    right: 25%;
    background: var(--danger);
    color: white;
    font-size: 0.55rem;
    font-weight: 900;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-surface);
}