/* Estilos Generales */
html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
    /* Previene scroll horizontal por las burbujas */
}

/* Skip Link para Accesibilidad */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 10000;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* --- Variables de Tema --- */
:root,
[data-theme="light"] {
    --bg-color: #ffffff;
    --text-color: #212529;
    --card-bg: #ffffff;
    --navbar-bg: rgba(248, 249, 250, 0.7);
    --light-bg: #f8f9fa;
    --primary-color: #0d6efd;
    --form-control-bg: #fff;
    --border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --card-bg: #1e1e1e;
    --navbar-bg: rgba(30, 30, 30, 0.7);
    --light-bg: #1e1e1e;
    --form-control-bg: #2a2a2a;
    --border-color: rgba(255, 255, 255, 0.15);
}

/* --- Fondo Animado --- */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    contain: layout style paint;
}

@keyframes move {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(40vw, -30vh) scale(1.2);
    }

    50% {
        transform: translate(-20vw, 20vh) scale(0.8);
    }

    75% {
        transform: translate(30vw, 40vh) scale(1.1);
    }
}

.blob {
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(0, 123, 255, 0.4), rgba(0, 123, 255, 0));
    border-radius: 50%;
    filter: blur(80px);
    /* Reducido de 100px para mejor performance */
    animation: move 30s infinite alternate;
    will-change: transform;
    /* Optimización de performance */
}

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    .blob {
        animation: none;
    }

    html {
        scroll-behavior: auto;
    }

    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.blob:nth-child(1) {
    top: -50px;
    left: -80px;
    animation-duration: 25s;
}

.blob:nth-child(2) {
    bottom: -100px;
    right: -150px;
    animation-duration: 35s;
    animation-delay: -5s;
}

.blob:nth-child(3) {
    top: 50%;
    left: 40%;
    width: 300px;
    height: 300px;
    animation-duration: 40s;
    animation-delay: -10s;
}

.blob:nth-child(4) {
    top: 60%;
    left: -100px;
    width: 350px;
    height: 350px;
    animation-duration: 28s;
    animation-delay: -15s;
}

.blob:nth-child(5) {
    top: 10%;
    left: 80%;
    width: 250px;
    height: 250px;
    animation-duration: 32s;
    animation-delay: -2s;
}

/* Pantalla de Carga */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #FBF8F1;
    /* Se mantiene blanco para el inicio */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

/* Sección Hero */
.hero-section {
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('https://images.unsplash.com/photo-1522071820081-009f0129c71c?q=80&w=2070&auto=format&fit=crop');
    height: 60vh;
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
}

.hero-section h1 {
    font-weight: 700;
}

/* Tarjetas de Proyecto con Efecto Flip */
.flip-card {
    background-color: transparent;
    width: 100%;
    height: 250px;
    perspective: 1000px;
    /* Efecto 3D */
    cursor: pointer;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}

.flip-card.is-flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    /* Safari */
    backface-visibility: hidden;
    border-radius: 0.375rem;
    /* Mismo borde que las cards de bootstrap */
}

.flip-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.375rem;
}

.flip-card-back {
    background-color: var(--light-bg);
    color: var(--text-color);
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

/* Botón en tarjetas de proyecto - texto negro en modo oscuro */
[data-theme="dark"] .flip-card-back .btn-primary {
    color: #000000 !important;
}

/* Estilos para las cards de servicios y generales */
.card {
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s;
    contain: layout style paint;
    /* Performance optimization */
}

.card h1,
.card h2,
.card h3,
.card h4,
.card h5,
.card p,
.card label {
    color: var(--text-color) !important;
}

#servicios .card:hover {
    transform: translateY(-10px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Estilos para la barra de navegación */
.navbar {
    background-color: var(--navbar-bg) !important;
    transition: background-color 0.3s;
    border-bottom: 1px solid var(--border-color);
}

@supports (backdrop-filter: blur(10px)) {
    .navbar {
        backdrop-filter: blur(10px);
    }
}

.navbar .nav-link {
    position: relative;
    transition: color 0.3s;
    color: var(--text-color) !important;
}

.navbar .nav-link:hover {
    color: var(--primary-color) !important;
}

.navbar .nav-link::after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--primary-color);
    transform-origin: bottom right;
    transition: transform 0.25s ease-out;
}

.navbar .nav-link:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

.navbar-toggler-icon {
    filter: invert(var(--is-dark));
}

[data-theme="dark"] {
    --is-dark: 1;
}

[data-theme="light"] {
    --is-dark: 0;
}

/* Botones de Idioma y Tema */
.btn-lang {
    background-color: #dc3545 !important;
    color: black !important;
    border-radius: 50px;
    font-weight: bold;
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
}

.btn-lang:hover {
    background-color: #c82333;
    color: white;
}

#theme-switch i {
    color: var(--text-color);
    transition: color 0.3s;
}

/* Formularios */
.form-control {
    background-color: var(--form-control-bg);
    color: var(--text-color);
    border-color: var(--border-color);
}

.form-control:focus {
    background-color: var(--form-control-bg);
    color: var(--text-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(var(--primary-color-rgb), 0.25);
}

[data-theme="light"] {
    --primary-color-rgb: 13, 110, 253;
}

[data-theme="dark"] {
    --primary-color-rgb: 13, 110, 253;
    /* Mantener el mismo azul para el foco */
}

/* Secciones con fondo claro */
.bg-light {
    background-color: var(--light-bg) !important;
    transition: background-color 0.3s;
}

/* Clases de texto de Bootstrap */
[data-theme="dark"] .text-body-secondary,
[data-theme="dark"] .text-muted {
    color: rgba(255, 255, 255, 0.5) !important;
}

.bg-primary .text-muted {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Footer */
footer {
    background-color: #1e1e1e !important;
    border-top: 1px solid var(--border-color);
}

footer .bi {
    transition: color 0.3s ease;
}

footer a:hover .bi {
    color: var(--primary-color) !important;
}

/* --- Estilos para Nuevas Secciones --- */

/* Sección Frase */
#quote {
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.6)), url('https://images.unsplash.com/photo-1489533119213-66a5cd877091?q=80&w=2071&auto=format&fit=crop');
    background-attachment: fixed;
    background-position: center;
    background-size: cover;
}

/* Sección Testimonios */


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

.testimonial-card {
    max-width: 800px;
    margin: auto;
}

/* Sección FAQ (Acordeón) */
.accordion-button {
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

.accordion-button:not(.collapsed) {
    background-color: var(--light-bg);
    color: var(--primary-color);
}

.accordion-button:focus {
    box-shadow: none;
    border-color: var(--border-color);
}

.accordion-item {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s, border-color 0.3s;
}

.accordion-body {
    color: var(--text-color);
    transition: color 0.3s;
}

[data-theme="dark"] .accordion-button::after {
    filter: brightness(0) invert(1);
}

/* Media Queries para Responsividad */
@media (max-width: 768px) {
    .hero-section {
        height: 40vh;
    }

    .hero-section h1 {
        font-size: 2.5rem;
    }

    .flip-card {
        height: 220px;
        /* Altura menor en móviles */
    }
}

/* --- Estilos para la sección de Branding --- */
.branding-section {
    position: relative;
    overflow: hidden;
}

.paint-stain-animation {
    position: relative;
    transform: scale(0.8);
    opacity: 0;
    transition: transform 1s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 1s ease-out;
}

.paint-stain-animation.is-visible {
    transform: scale(1);
    opacity: 1;
}

.paint-stain-animation::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    background-image: url('https://www.transparentpng.com/thumb/paint-splatter/paint-splatter-hd-png-image-9.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.8s ease-out 0.3s, opacity 0.8s ease-out 0.3s;
    z-index: -1;
}

.paint-stain-animation.is-visible::before {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.paint-stain-animation img {
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}


/* --- Ajustes de Estilo Adicionales --- */

/* Sol amarillo en modo oscuro */
[data-theme="dark"] #theme-switch i.bi-sun-fill {
    color: #ffc107 !important;
}

/* Tarjeta de contacto directo */
#direct-contact-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#direct-contact-card h3,
#direct-contact-card h4 {
    color: var(--primary-color) !important;
}

#direct-contact-card div a {
    color: var(--primary-color) !important;
    transition: opacity 0.3s;
}

#direct-contact-card div a:hover {
    opacity: 0.7;
}

#direct-contact-card .btn-success {
    background-color: #198754 !important;
    border-color: #198754 !important;
    color: white !important;
}

/* Tarjeta de Formulario de Contacto */
#form-card {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

#form-card .form-label {
    color: white !important;
    font-weight: bold !important;
}

#form-card .form-control {
    background-color: white !important;
    color: black !important;
}