.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    max-width: 100%;
    overflow: hidden;
}

/* Móviles pantalla mediana */
@media (min-width: 375px) {
    .card {
        padding: 1.35rem;
    }
}

/* Móviles pantalla grande */
@media (min-width: 425px) {
    .card {
        padding: 1.5rem;
    }
}

/* Tablets */
@media (min-width: 768px) {
    .card {
        padding: 1.75rem;
    }
}

/* Ordenadores */
@media (min-width: 1024px) {
    .card {
        padding: 2rem;
    }
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--border-hover);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.card-icon {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.4));
}

.card h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
    margin: 0;
    word-break: break-word;
}

/* Móviles pantalla mediana */
@media (min-width: 375px) {
    .card h2 {
        font-size: 1.15rem;
    }
}

/* Móviles pantalla grande */
@media (min-width: 425px) {
    .card h2 {
        font-size: 1.25rem;
    }
}

/* Tablets */
@media (min-width: 768px) {
    .card h2 {
        font-size: 1.375rem;
    }
}

/* Ordenadores */
@media (min-width: 1024px) {
    .card h2 {
        font-size: 1.5rem;
    }
}

.card-preview {
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--bg-dark-secondary) 100%);
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 0.875rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: var(--transition);
    background: var(--bg-dark-secondary);
    color: var(--text-primary);
    font-family: 'Poppins', sans-serif;
    max-width: 100%;
    box-sizing: border-box;
}

/* Móviles pantalla mediana */
@media (min-width: 375px) {
    input[type="text"],
    input[type="password"],
    select,
    textarea {
        padding: 0.8rem 0.95rem;
        font-size: 0.95rem;
    }
}

/* Móviles pantalla grande y superiores */
@media (min-width: 425px) {
    input[type="text"],
    input[type="password"],
    select,
    textarea {
        padding: 0.875rem 1rem;
        font-size: 1rem;
    }
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
    background: var(--card-bg);
}

input::placeholder {
    color: var(--text-tertiary);
}

.btn {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    font-family: 'Poppins', sans-serif;
    min-height: 44px;
    box-sizing: border-box;
}

/* Móviles pantalla mediana */
@media (min-width: 375px) {
    .btn {
        padding: 0.8rem 1.35rem;
        font-size: 0.95rem;
    }
}

/* Móviles pantalla grande y superiores */
@media (min-width: 425px) {
    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: var(--text-tertiary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
}

.btn-autofill {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.btn-autofill:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.btn-download {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.btn-download:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

.btn-icon {
    font-size: 1.2rem;
}

.search-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-container input {
    flex: 1;
}

.btn-search {
    width: auto;
    padding: 0.875rem 1.25rem;
    min-width: 60px;
}

.search-results {
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Móviles pantalla mediana */
@media (min-width: 375px) {
    .search-results {
        max-height: 320px;
    }
}

/* Móviles pantalla grande */
@media (min-width: 425px) {
    .search-results {
        max-height: 350px;
    }
}

/* Tablets y superiores */
@media (min-width: 768px) {
    .search-results {
        max-height: 400px;
    }
}

.search-results:empty::after {
    content: "No hay resultados";
    display: block;
    text-align: center;
    color: var(--text-tertiary);
    padding: 2rem;
}

.song-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.5rem;
    border: 2px solid transparent;
    background: var(--bg-dark-secondary);
    max-width: 100%;
    overflow: hidden;
}

/* Móviles pantalla mediana y superiores */
@media (min-width: 375px) {
    .song-item {
        gap: 0.875rem;
        padding: 0.875rem;
    }
}

/* Móviles pantalla grande y superiores */
@media (min-width: 425px) {
    .song-item {
        gap: 1rem;
    }
}

.song-item:hover {
    background: var(--card-bg-hover);
    transform: translateX(4px);
    border-color: var(--border-hover);
}

.song-item.selected {
    background: var(--primary-light);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-glow);
}

.song-item img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

/* Móviles pantalla mediana y superiores */
@media (min-width: 375px) {
    .song-item img {
        width: 52px;
        height: 52px;
    }
}

/* Móviles pantalla grande y superiores */
@media (min-width: 425px) {
    .song-item img {
        width: 56px;
        height: 56px;
    }
}

.song-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.song-title {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

/* Móviles pantalla mediana y superiores */
@media (min-width: 375px) {
    .song-title {
        font-size: 0.9rem;
    }
}

/* Móviles pantalla grande y superiores */
@media (min-width: 425px) {
    .song-title {
        font-size: 0.95rem;
    }
}

.song-artist {
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Móviles pantalla mediana y superiores */
@media (min-width: 375px) {
    .song-artist {
        font-size: 0.825rem;
    }
}

/* Móviles pantalla grande y superiores */
@media (min-width: 425px) {
    .song-artist {
        font-size: 0.875rem;
    }
}

.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-dark-secondary);
    border-radius: var(--radius-md);
    min-height: 300px;
    padding: 0.75rem;
    border: 2px dashed var(--border-color);
    max-width: 100%;
    overflow: hidden;
}

/* Móviles pantalla mediana */
@media (min-width: 375px) {
    .preview-container {
        min-height: 350px;
        padding: 1rem;
    }
}

/* Móviles pantalla grande */
@media (min-width: 425px) {
    .preview-container {
        min-height: 400px;
        padding: 1.25rem;
    }
}

/* Tablets */
@media (min-width: 768px) {
    .preview-container {
        min-height: 500px;
        padding: 1.5rem;
    }
}

/* Ordenadores */
@media (min-width: 1024px) {
    .preview-container {
        min-height: 600px;
        padding: 2rem;
    }
}

.preview-empty {
    text-align: center;
    color: var(--text-tertiary);
    padding: 1.5rem;
    max-width: 280px;
}

/* Móviles pantalla mediana y superiores */
@media (min-width: 375px) {
    .preview-empty {
        padding: 1.75rem;
        max-width: 300px;
    }
}

/* Móviles pantalla grande y superiores */
@media (min-width: 425px) {
    .preview-empty {
        padding: 2rem;
        max-width: 320px;
    }
}

.preview-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
    filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.3));
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.preview-empty p {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.preview-hint {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    display: block;
}

canvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.5s ease-out;
    display: block;
}

@media (max-width: 374px) {
    canvas {
        max-width: calc(100vw - 3rem);
    }
}

.char-counter {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    text-align: right;
    font-weight: 500;
}

/* Select styling */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2310b981' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

select option {
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 0.5rem;
}

/* Loading state */
.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive improvements */
@media (max-width: 374px) {
    .card {
        padding: 1rem;
    }
    
    .card h2 {
        font-size: 1rem;
    }
    
    .song-item img {
        width: 44px;
        height: 44px;
    }
    
    .btn {
        padding: 0.7rem 1rem;
        font-size: 0.875rem;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .btn-search {
        width: 100%;
    }
}

@media (min-width: 375px) and (max-width: 424px) {
    .song-item {
        gap: 0.75rem;
    }
}

@media (min-width: 425px) and (max-width: 767px) {
    .input-group label {
        font-size: 0.9rem;
    }
}

/* Button Group stretch in cards */
.button-group {
    width: 100%;
}

/* Ajustes globales para prevenir desbordamiento */
* {
    max-width: 100%;
}

img, canvas, video {
    max-width: 100%;
    height: auto;
}

/* Prevenir scroll horizontal en móviles */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Ajuste del contenedor de búsqueda en móviles muy pequeños */
@media (max-width: 374px) {
    .search-container {
        gap: 0.5rem;
    }
    
    .btn-search {
        min-width: 50px;
        padding: 0.7rem 1rem;
    }
}

/* Mejoras táctiles para dispositivos móviles */
@media (pointer: coarse) {
    .btn, .song-item, input, select, textarea {
        min-height: 44px;
    }
    
    .song-item {
        padding: 1rem 0.875rem;
    }
}

/* Optimización de animaciones en dispositivos de bajo rendimiento */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}