/* Reset y base */
#yotramito-grants * {
    box-sizing: border-box;
}

#yotramito-grants a {
    text-decoration: none !important;
}

/* Contenedor principal */
#yotramito-grants {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    font-family: var(--yotramito-font-family);
    color: var(--yotramito-text);
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

#yotramito-grants .yotramito-container {
    background: #ffffff;
    padding: 35px;
    border-radius: var(--yotramito-radius-large);
    box-shadow: var(--yotramito-shadow);
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Selector Autónomo / Empresa */
#yotramito-grants .tipo-busqueda {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (min-width: 768px) {
    #yotramito-grants .tipo-busqueda {
        flex-direction: row;
        gap: 30px;
    }
}

#yotramito-grants .tipo-busqueda .opcion {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px;
    border: 2px solid var(--yotramito-border);
    border-radius: var(--yotramito-radius);
    background-color: var(--yotramito-secondary);
    cursor: pointer;
    transition: var(--yotramito-transition);
    position: relative;
    min-height: 70px;
}

#yotramito-grants .tipo-busqueda .opcion:hover {
    border-color: var(--yotramito-primary);
    transform: translateY(-2px);
    box-shadow: var(--yotramito-shadow-hover);
}

#yotramito-grants .tipo-busqueda .opcion.active {
    border-color: var(--yotramito-primary);
    background-color: rgba(0, 102, 204, 0.1);
    box-shadow: var(--yotramito-shadow);
}

#yotramito-grants .tipo-busqueda .opcion svg {
    width: 42px;
    height: 42px;
    padding: 10px;
    border-radius: 10px;
    background-color: rgba(0, 102, 204, 0.1);
    stroke: var(--yotramito-primary);
    flex-shrink: 0;
}

#yotramito-grants .tipo-busqueda .opcion span {
    font-weight: 600;
    font-size: 16px;
    color: var(--yotramito-text);
}

/* Sección de búsqueda */
#yotramito-grants .busqueda-section {
    flex-direction: column;
    gap: 10px;
}

#yotramito-grants .busqueda-form {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: space-between;
    align-items: flex-end;
}

@media (max-width: 767px) {
    #yotramito-grants .busqueda-form {
        flex-direction: column;
        gap: 20px;
    }
}

/* Campos del formulario */
#yotramito-grants .form-field {
    flex: 1;
    min-width: 200px;
    position: relative;
}

@media (max-width: 767px) {
    #yotramito-grants .form-field {
        width: 100%;
    }
}


#yotramito-grants .form-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--yotramito-text);
    font-size: 14px;
    transition: var(--yotramito-transition);
}

#yotramito-grants .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#yotramito-grants .input-wrapper input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border: 2px solid var(--yotramito-border);
    border-radius: var(--yotramito-radius);
    font-size: 16px;
    background-color: #ffffff;
    transition: var(--yotramito-transition);
    outline: none;
}

#yotramito-grants .input-wrapper input:focus {
    border-color: var(--yotramito-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

#yotramito-grants .input-wrapper input::placeholder {
    color: var(--yotramito-text-light);
}

#yotramito-grants .input-wrapper input.error {
    border-color: var(--yotramito-error);
}

#yotramito-grants .input-wrapper input.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

/* Iconos en inputs */
#yotramito-grants .input-icon {
    position: absolute;
    left: 12px;
    top: 15px;
    z-index: 2;
    pointer-events: none;
}

#yotramito-grants .input-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--yotramito-text-light);
    transition: var(--yotramito-transition);
}

#yotramito-grants .input-wrapper input:focus + .input-icon svg,
#yotramito-grants .input-wrapper:hover .input-icon svg {
    stroke: var(--yotramito-primary);
}

#yotramito-grants .input-icon-end {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 2;
}

#yotramito-grants .info-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--yotramito-transition);
}

#yotramito-grants .info-btn:hover {
    background-color: rgba(0, 102, 204, 0.1);
}

#yotramito-grants .info-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--yotramito-text-light);
}

/* Autocomplete */
#yotramito-grants .autocomplete-wrapper {
    position: relative;
}

#yotramito-grants .autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 2px solid var(--yotramito-border);
    border-top: none;
    border-radius: 0 0 var(--yotramito-radius) var(--yotramito-radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--yotramito-shadow);
}

#yotramito-grants .dropdown-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    transition: var(--yotramito-transition);
}

#yotramito-grants .dropdown-item:last-child {
    border-bottom: none;
}

#yotramito-grants .dropdown-item:hover,
#yotramito-grants .dropdown-item.selected {
    background-color: rgba(0, 102, 204, 0.1);
}

#yotramito-grants .dropdown-item.no-results,
#yotramito-grants .dropdown-item.error {
    cursor: default;
    color: var(--yotramito-text-light);
    text-align: center;
    font-style: italic;
}

#yotramito-grants .dropdown-item.error {
    color: var(--yotramito-error);
}


#yotramito-grants .autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

#yotramito-grants .autocomplete-item:hover,
#yotramito-grants .autocomplete-item.selected {
    background-color: #f8f9fa;
}

#yotramito-grants .autocomplete-item:last-child {
    border-bottom: none;
}

#yotramito-grants .autocomplete-item .cnae-code {
    font-weight: 600;
    color: #2563eb;
    font-size: 13px;
    margin-bottom: 4px;
}

#yotramito-grants .autocomplete-item .cnae-name {
    color: #374151;
    font-size: 14px;
    line-height: 1.5;
}

#yotramito-grants .autocomplete-item.no-results,
#yotramito-grants .autocomplete-item.error {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    cursor: default;
    background-color: #f9fafb;
}

#yotramito-grants .autocomplete-item.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    background-color: #f9fafb;
}

#yotramito-grants .autocomplete-item.loading .loading-spinner {
    margin-right: 8px;
    animation: spin 1s linear infinite;
}

#yotramito-grants .autocomplete-item.loading .loading-spinner svg {
    width: 16px;
    height: 16px;
}

#yotramito-grants .cnae-code {
    font-weight: 600;
    color: var(--yotramito-primary);
    font-size: 14px;
}

#yotramito-grants .cnae-name {
    font-size: 13px;
    color: var(--yotramito-text);
    margin-top: 2px;
    line-height: 1.3;
}

/* Botón de búsqueda */
#yotramito-grants .btn-buscar {
    background-color: var(--yotramito-primary);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--yotramito-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--yotramito-transition);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 158px;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    #yotramito-grants .btn-buscar {
        width: 100%;
        justify-content: center;
    }
}

#yotramito-grants .btn-buscar:hover:not(:disabled) {
    background-color: var(--yotramito-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--yotramito-shadow-hover);
}

#yotramito-grants .btn-buscar:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

#yotramito-grants .loading-spinner svg {
    animation: spin 1s linear infinite;
}

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

/* Botón de otros métodos de búsqueda */
#yotramito-grants .btn-options {
    background-color: var(--yotramito-secondary);
    color: #444444;
    border: 1px solid #444444;
    padding: 12px 24px;
    border-radius: var(--yotramito-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--yotramito-transition);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 158px;
    justify-content: center;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    #yotramito-grants .btn-options {
        width: 100%;
        justify-content: center;
    }
}

#yotramito-grants .btn-options:hover:not(:disabled) {
    background-color: var(--yotramito-secondary-dark);
    transform: translateY(-2px);
    box-shadow: var(--yotramito-shadow-hover);
    color: #ffffff;
}

#yotramito-grants .btn-options:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Errores de campo */
#yotramito-grants .field-error {
    color: var(--yotramito-error);
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

#yotramito-grants .field-error::before {
    content: "⚠";
    font-size: 14px;
}

/* Contenedor de resultados */
#yotramito-grants .resultados-container {
    margin-top: 40px;
    display: none;
}

#yotramito-grants .resultados-header {
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#yotramito-grants .resultados-header .resultados-header-left {
    text-align: left;
}

#yotramito-grants .resultados-header .resultados-header-left h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--yotramito-text);
    margin: 0 0 8px 0;
}

#yotramito-grants .resultados-header .resultados-header-left .resultados-subtitle {
    font-size: 20px;
    color: var(--yotramito-text-light);
    margin: 0;
}

#yotramito-grants .resultados-header .resultados-header-right {
    text-align: right;
}

#yotramito-grants .resultados-header .resultados-header-right a {
    font-size: 16px;
    color: var(--yotramito-text);
    margin: 0;
}

/* Grid de resultados */
#yotramito-grants .resultados-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (max-width: 767px) {
    #yotramito-grants .resultados-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Tarjetas de resultado */
#yotramito-grants .result-card {
    text-decoration: none;
    background: var(--yotramito-background);
    border-radius: var(--yotramito-radius);
    padding: 24px;
    transition: var(--yotramito-transition);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#yotramito-grants .result-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--yotramito-shadow-hover);
}

#yotramito-grants .result-card.yotramito_express {
    border-left: 13px solid var(--yotramito-color-blue);
}

#yotramito-grants .result-card.yotramito_active {
    border-left: 13px solid var(--yotramito-color-active);
}

#yotramito-grants .result-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

#yotramito-grants .result-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--yotramito-text);
    margin: 0;
    line-height: 1.3;
}

#yotramito-grants .result-description {
    color: var(--yotramito-text);
    font-size: 15px;
    line-height: 1.5;
    margin: 0;
}

#yotramito-grants .result-actions {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#yotramito-grants .pill {
    padding-top: .25rem;
    padding-bottom: .25rem;
    padding-left: .75rem;
    padding-right: .75rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 500;
    font-size: .875rem;
    line-height: 1.25rem;
    border-radius: .5rem;
    gap: .5rem;
    width: fit-content;
    margin-right: .5rem;
}

#yotramito-grants .pill.pill-yotramito-express {
    background-color: var(--yotramito-color-express-light);
    color: var(--yotramito-color-express-text);
}

#yotramito-grants .pill.pill-yotramito-active {
    background-color: var(--yotramito-color-active-light);
    color: var(--yotramito-color-active-text);
}

#yotramito-grants .pill.pill-yotramito-location {
    background-color: var(--yotramito-color-location-light);
    color: var(--yotramito-color-location);
    padding-top: .5rem;
    padding-bottom: .5rem;
}

#yotramito-grants .btn-ver-detalle {
    background-color: var(--yotramito-primary);
    color: #ffffff;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: var(--yotramito-radius);
    border: none;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--yotramito-transition);
    cursor: pointer;
}

#yotramito-grants .btn-ver-detalle:hover {
    background-color: var(--yotramito-primary-dark);
    transform: translateY(-2px);
    text-decoration: none;
    color: #ffffff;
}

#yotramito-grants .btn-ver-detalle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* Sin resultados */
#yotramito-grants .no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--yotramito-text-light);
}

#yotramito-grants .no-results-icon {
    margin-bottom: 24px;
    opacity: 0.5;
}

#yotramito-grants .no-results-icon svg {
    width: 64px;
    height: 64px;
    stroke: currentColor;
}

#yotramito-grants .no-results h3 {
    font-size: 24px;
    color: var(--yotramito-text);
    margin: 0 0 12px 0;
    font-weight: 600;
}

#yotramito-grants .no-results p {
    font-size: 16px;
    margin: 0 0 32px 0;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

#yotramito-grants .no-results-suggestions {
    text-align: left;
    background-color: var(--yotramito-secondary);
    padding: 24px;
    border-radius: var(--yotramito-radius);
    max-width: 600px;
    margin: 0 auto;
}

#yotramito-grants .no-results-suggestions h4 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: var(--yotramito-text);
}

#yotramito-grants .no-results-suggestions ul {
    margin: 0;
    padding-left: 20px;
}

#yotramito-grants .no-results-suggestions li {
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
}

/* Error */
#yotramito-grants .error-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--yotramito-error);
}

#yotramito-grants .error-icon {
    margin-bottom: 24px;
}

#yotramito-grants .error-icon svg {
    width: 48px;
    height: 48px;
    stroke: currentColor;
}

#yotramito-grants .error-results h3 {
    font-size: 24px;
    color: var(--yotramito-error);
    margin: 0 0 12px 0;
    font-weight: 600;
}

#yotramito-grants .error-results p {
    font-size: 16px;
    margin: 0 0 24px 0;
    color: var(--yotramito-text);
}

#yotramito-grants .btn-retry {
    background-color: var(--yotramito-primary);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--yotramito-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--yotramito-transition);
}

#yotramito-grants .btn-retry:hover {
    background-color: var(--yotramito-primary-dark);
}

/* Animaciones de entrada */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#yotramito-grants .resultados-container,
#yotramito-grants .no-results,
#yotramito-grants .error-results {
    animation: fadeInUp 0.5s ease-out;
}

#yotramito-grants .result-card {
    animation: fadeInUp 0.5s ease-out;
}

#yotramito-grants .result-card:nth-child(2) { animation-delay: 0.1s; }
#yotramito-grants .result-card:nth-child(3) { animation-delay: 0.2s; }
#yotramito-grants .result-card:nth-child(4) { animation-delay: 0.3s; }

/* Focus visible para navegación con teclado */
#yotramito-grants .tipo-busqueda .opcion:focus-visible,
#yotramito-grants .btn-buscar:focus-visible,
#yotramito-grants .btn-ver-detalle:focus-visible,
#yotramito-grants .dropdown-item:focus-visible,
#yotramito-grants .info-btn:focus-visible {
    outline: 2px solid var(--yotramito-primary);
    outline-offset: 2px;
}

#yotramito-grants .input-wrapper input:focus-visible {
    outline: none; /* Ya manejado con box-shadow */
}

/* Estados de hover para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
    #yotramito-grants .result-card:hover {
        transform: none;
    }
    
    #yotramito-grants .btn-buscar:hover,
    #yotramito-grants .btn-ver-detalle:hover {
        transform: none;
    }
    
    #yotramito-grants .tipo-busqueda .opcion:hover {
        transform: none;
    }
}

/* Mejoras para pantallas pequeñas */
@media (max-width: 480px) {
    #yotramito-grants .yotramito-container {
        padding: 20px;
        gap: 24px;
    }
    
    #yotramito-grants .tipo-busqueda .opcion {
        padding: 12px;
        min-height: 60px;
    }
    
    #yotramito-grants .tipo-busqueda .opcion span {
        font-size: 14px;
    }
    
    #yotramito-grants .input-wrapper input {
        padding: 10px 12px 10px 40px;
        font-size: 16px; /* Evita zoom en iOS */
    }
    
    #yotramito-grants .result-card {
        padding: 20px;
    }
    
    #yotramito-grants .resultados-header h3 {
        font-size: 24px;
    }
    
    #yotramito-grants .result-title {
        font-size: 18px;
    }
}

/* Modo alto contraste */
@media (prefers-contrast: high) {
    :root {
        --yotramito-border: #000000;
        --yotramito-text-light: #333333;
    }
    
    #yotramito-grants .input-wrapper input {
        border-width: 3px;
    }
    
    #yotramito-grants .result-card {
        border-width: 3px;
    }
    
    #yotramito-grants .tipo-busqueda .opcion {
        border-width: 3px;
    }
}

/* Print styles */
@media print {
    #yotramito-grants {
        box-shadow: none;
    }
    
    #yotramito-grants .yotramito-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    #yotramito-grants .btn-buscar,
    #yotramito-grants .btn-ver-detalle,
    #yotramito-grants .btn-retry {
        display: none;
    }
    
    #yotramito-grants .result-card {
        border: 1px solid #000;
        break-inside: avoid;
        margin-bottom: 20px;
    }
    
    #yotramito-grants .loading-spinner {
        display: none !important;
    }
}

/* Utilidades adicionales */
#yotramito-grants .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Scrollbar personalizado para el dropdown */
#yotramito-grants .autocomplete-dropdown::-webkit-scrollbar {
    width: 8px;
}

#yotramito-grants .autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#yotramito-grants .autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: var(--yotramito-border);
    border-radius: 4px;
}

#yotramito-grants .autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: var(--yotramito-primary);
}

/* Mejoras para la carga progresiva */
#yotramito-grants .yotramito-container {
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* Estados de carga específicos */
#yotramito-grants .btn-buscar[data-loading="true"] span {
    opacity: 0.7;
}

#yotramito-grants .btn-buscar[data-loading="true"] .loading-spinner {
    display: block !important;
}

/* Tooltips para información adicional */
#yotramito-grants .tooltip {
    position: relative;
    cursor: help;
    opacity: 1 !important;
}

#yotramito-grants .tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 54px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1001;
    width: 300px;
}

#yotramito-grants .tooltip::after {
    content: '';
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 15px solid rgba(0, 0, 0, 0.9);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1001;
}

#yotramito-grants .tooltip:hover::before,
#yotramito-grants .tooltip:hover::after {
    opacity: 1;
}

/* Skeleton loading para mejorar la percepción de velocidad */
@keyframes skeleton-loading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

#yotramito-grants .skeleton {
    background-color: #eee;
    background-image: linear-gradient(90deg, #eee, #f5f5f5, #eee);
    background-size: 200px 100%;
    background-repeat: no-repeat;
    border-radius: 4px;
    animation: skeleton-loading 1.3s ease-in-out infinite;
}

/* Estados específicos para mejor feedback */
#yotramito-grants .form-field.success input {
    border-color: var(--yotramito-success);
}

#yotramito-grants .form-field.success .input-icon svg {
    stroke: var(--yotramito-success);
}

/* Mejora de la experiencia de usuario en formularios largos */
#yotramito-grants .form-progress {
    height: 4px;
    background: var(--yotramito-border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 20px;
}

#yotramito-grants .form-progress-bar {
    height: 100%;
    background: var(--yotramito-primary);
    width: 0%;
    transition: width 0.3s ease;
}

/* Animación para resultados individuales */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#yotramito-grants .result-card.animate-in {
    animation: slideInLeft 0.5s ease-out;
}

#yotramito-grants input:not([type=submit]) {
    padding: 7px 40px;
}

#yotramito-grants .busqueda-section.active {
    display: flex;
}

#yotramito-grants .display-none {
   display: none;
}
