/* ===== DIGESTO MOBILE MODERN STYLES ===== */

:root {
    --primary-color: #6c5ce7;
    --primary-dark: #5b4bd6;
    --secondary-color: #74b9ff;
    --accent-color: #00cec9;
    --success-color: #00b894;
    --warning-color: #fdcb6e;
    --danger-color: #e17055;
    --dark-color: #2d3436;
    --light-color: #ddd;
    --bg-color: #f8f9fa;
    --card-shadow: 0 4px 6px rgba(108, 92, 231, 0.1);
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
}

/* Hero Section */
.digesto-hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.digesto-hero::before {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    height: 60px;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 1200 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M321.39,56.44c58-10.79,114.16-30.13,172-41.86,82.39-16.72,168.19-17.73,250.45-.39C823.78,31,906.67,72,985.66,92.83c70.05,18.48,146.53,26.09,214.34,3V0H0V27.35A600.21,600.21,0,0,0,321.39,56.44Z' fill='%23ffffff'%3E%3C/path%3E%3C/svg%3E") no-repeat center bottom;
    background-size: cover;
    transform: scaleY(-1);
}

.digesto-hero-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.digesto-hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.digesto-hero p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 0;
}

/* Main Container */
.digesto-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Search Cards Layout */
.search-cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.search-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: var(--transition);
    border: 1px solid #e9ecef;
}

.search-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(108, 92, 231, 0.15);
}

.search-card h3 {
    color: var(--primary-color);
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.search-card h3::before {
    content: '🔍';
    font-size: 1.2rem;
}

/* Advanced Search - Special styling */
.advanced-search-card {
    grid-row: span 2;
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
    border: 2px solid var(--primary-color);
}

.advanced-search-card h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 2rem;
}

.advanced-search-card h3::before {
    content: '⚙️';
}

/* Form Sections */
.form-section {
    margin-bottom: 2rem;
    padding: 1rem;
    background: rgba(108, 92, 231, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.form-section-title {
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
    text-align: center;
}

/* Form Inputs */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 0.875rem 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--dark-color);
    background-color: #fff;
    transition: var(--transition);
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
    background-color: #fff;
}

.form-control::placeholder {
    color: #8e9297;
    font-style: italic;
    opacity: 1;
    font-size: 0.95rem;
}

/* Mejoras específicas para legibilidad */
.form-control::-webkit-input-placeholder {
    color: #8e9297;
    opacity: 1;
}

.form-control::-moz-placeholder {
    color: #8e9297;
    opacity: 1;
}

.form-control:-ms-input-placeholder {
    color: #8e9297;
    opacity: 1;
}

.form-control:-moz-placeholder {
    color: #8e9297;
    opacity: 1;
}

/* Select inputs */
select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 3rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Texto de ayuda mejorado */
.text-muted,
small.text-muted {
    color: #6c757d !important;
    font-size: 0.875rem !important;
    line-height: 1.4 !important;
    margin-top: 0.25rem !important;
    display: block !important;
    font-weight: 400 !important;
}

/* Mejoras para datalist */
input[list] {
    position: relative;
}

datalist {
    font-size: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 48px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-primary::before {
    content: '🔍';
}

.btn-block {
    width: 100%;
    margin-top: 1rem;
}

/* Simple Search Cards */
.simple-search-cards {
    display: grid;
    gap: 1.5rem;
}

.simple-search-card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 1.5rem;
    transition: var(--transition);
}

.word-search-card h3::before {
    content: '📝';
}

.general-search-card h3::before {
    content: '🎯';
}

/* Results Container */
.results-container {
    margin-top: 2rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.results-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1.5rem;
    text-align: center;
}

.results-header h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
}

/* Tab Navigation */
.nav-tabs {
    border-bottom: 2px solid var(--primary-color);
    background: #f8f9fa;
    padding: 0;
    margin: 0;
}

.nav-tabs .nav-item {
    margin-bottom: 0;
}

.nav-tabs .nav-link {
    border: none;
    padding: 1rem 2rem;
    color: var(--dark-color);
    font-weight: 500;
    transition: var(--transition);
    background: transparent;
}

.nav-tabs .nav-link:hover {
    background: rgba(108, 92, 231, 0.1);
    color: var(--primary-color);
}

.nav-tabs .nav-link.active {
    background: var(--primary-color);
    color: white;
    border-radius: 8px 8px 0 0;
}

/* Tables */
.table {
    margin: 0;
    background: white;
}

.table thead th {
    background: linear-gradient(135deg, #f8f9ff 0%, #e9ecef 100%);
    color: var(--dark-color);
    font-weight: 600;
    padding: 1rem;
    border: none;
    text-align: center;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f3f4;
}

.table tbody tr:hover {
    background: rgba(108, 92, 231, 0.05);
}

/* Action Buttons */
.btn-modal {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-modal:hover {
    background: var(--primary-color);
    transform: scale(1.05);
}

.btn-modal img {
    width: 16px;
    height: 16px;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--primary-color);
}

.loading::before {
    content: '⏳';
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
    font-size: 1.2rem;
}

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

/* Error/Info Messages */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    border: none;
    font-weight: 500;
}

.alert-danger {
    background: linear-gradient(135deg, #ff7675 0%, #e17055 100%);
    color: white;
}

.alert-info {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: white;
}

/* Modal Enhancements */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    border: none;
}

.modal-header .close {
    color: white;
    text-shadow: none;
    opacity: 0.8;
    font-size: 1.5rem;
}

.modal-header .close:hover {
    opacity: 1;
    color: white;
}

.modal-body {
    padding: 2rem;
}

.modal-title {
    font-weight: 600;
    font-size: 1.2rem;
}

/* Normativa Details Styling */
.normativa-details {
    font-family: inherit;
}

.normativa-details .row {
    margin-bottom: 1rem;
}

.normativa-details strong {
    color: var(--dark-color);
    font-weight: 600;
    font-size: 0.9rem;
}

.normativa-details .text-primary {
    font-size: 1.1rem;
    font-weight: 500;
}

.normativa-details .text-info {
    font-size: 1.1rem;
    font-weight: 500;
}

.normativa-details .badge {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.normativa-details .bg-light {
    background-color: #f8f9fa !important;
    border-radius: 8px;
    font-style: italic;
    color: var(--dark-color);
}

.downloads-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #e9ecef;
}

.downloads-section h5 {
    color: var(--primary-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.downloads-section .btn {
    border-radius: 8px;
    font-weight: 500;
    padding: 0.75rem 1rem;
    transition: var(--transition);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.downloads-section .btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

.downloads-section .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.4);
}

.downloads-section .btn-outline-secondary {
    border: 2px solid #6c757d;
    color: #6c757d;
    background: white;
}

.downloads-section .btn-outline-secondary:hover {
    background: #6c757d;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

/* Loading spinner in modal */
.modal-body .loading {
    padding: 3rem 0;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Error states in modal */
.modal-body .alert {
    border-radius: 8px;
    border: none;
}

.modal-body .alert-danger {
    background: linear-gradient(135deg, #ff7675 0%, #e17055 100%);
    color: white;
}

.modal-body .alert-danger h5 {
    color: white;
    margin-bottom: 1rem;
}

.modal-body .btn-outline-primary {
    border-color: white;
    color: white;
    background: transparent;
}

.modal-body .btn-outline-primary:hover {
    background: white;
    color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-cards-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .advanced-search-card {
        grid-row: span 1;
    }
    
    .digesto-hero h1 {
        font-size: 2rem;
    }
    
    .digesto-hero p {
        font-size: 1rem;
    }
    
    .search-card {
        padding: 1rem;
    }
    
    .form-section {
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.6rem 1.5rem;
        font-size: 0.9rem;
    }
    
    .table {
        font-size: 0.9rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
    }
}

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

/* Tablet styles */
@media (max-width: 768px) {
    .search-cards-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .digesto-hero h1 {
        font-size: 2rem;
    }
    
    .digesto-hero p {
        font-size: 1rem;
    }
    
    .search-card {
        padding: 1.25rem;
    }
    
    .form-section {
        margin-bottom: 1.5rem;
    }
}

/* Mobile styles */
@media (max-width: 576px) {
    .digesto-container {
        padding: 0 0.75rem;
    }
    
    .digesto-hero {
        padding: 1.5rem 0;
        margin-bottom: 1.5rem;
    }
    
    .digesto-hero h1 {
        font-size: 1.75rem;
        margin-bottom: 0.25rem;
    }
    
    .digesto-hero p {
        font-size: 0.9rem;
        padding: 0 1rem;
    }
    
    .search-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .search-card h3 {
        font-size: 1.1rem;
        margin-bottom: 1rem;
    }
    
    .form-section {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    .form-section-title {
        font-size: 0.8rem;
        padding: 0.4rem 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    /* MEJORAS CRÍTICAS PARA INPUTS EN MÓVIL */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--dark-color);
        margin-bottom: 0.4rem;
        display: block;
    }
    
    .form-control {
        width: 100% !important;
        padding: 0.875rem 0.75rem !important;
        font-size: 1rem !important; /* Evita zoom en iOS */
        line-height: 1.4 !important;
        border: 2px solid #dee2e6 !important;
        border-radius: 8px !important;
        background-color: #fff !important;
        color: var(--dark-color) !important;
        transition: all 0.2s ease !important;
        box-sizing: border-box !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        min-height: 48px !important; /* Mejor para touch */
    }
    
    .form-control:focus {
        border-color: var(--primary-color) !important;
        box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15) !important;
        outline: none !important;
        background-color: #fff !important;
    }
    
    .form-control::placeholder {
        color: #8e9297 !important;
        font-size: 0.9rem !important;
        opacity: 1 !important;
    }
    
    /* Selects específicos para móvil */
    select.form-control {
        cursor: pointer !important;
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23374151' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") !important;
        background-position: right 0.75rem center !important;
        background-repeat: no-repeat !important;
        background-size: 1.25em 1.25em !important;
        padding-right: 3rem !important;
        font-size: 1rem !important;
    }
    
    /* Inputs de tipo number y date */
    input[type="number"].form-control,
    input[type="date"].form-control {
        font-size: 1rem !important;
        padding: 0.875rem 0.75rem !important;
    }
    
    /* Botones mejorados para móvil */
    .btn {
        padding: 0.875rem 1.5rem !important;
        font-size: 1rem !important;
        min-height: 48px !important;
        font-weight: 600 !important;
        border-radius: 8px !important;
        letter-spacing: 0.3px !important;
    }
    
    .btn-block {
        width: 100% !important;
        margin-top: 1.25rem !important;
    }
    
    /* Navegación de tabs mejorada */
    .nav-tabs .nav-link {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Tabla responsive */
    .table {
        font-size: 0.85rem;
    }
    
    .table thead th,
    .table tbody td {
        padding: 0.75rem 0.5rem;
    }
}

/* Móviles muy pequeños */
@media (max-width: 480px) {
    .digesto-container {
        padding: 0 0.5rem;
    }
    
    .search-card {
        padding: 0.875rem;
        border-radius: 10px;
    }
    
    .search-card h3 {
        font-size: 1rem;
        margin-bottom: 0.875rem;
    }
    
    .form-section {
        padding: 0.625rem;
        margin-bottom: 0.875rem;
    }
    
    .form-section-title {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
    }
    
    .form-control {
        padding: 0.75rem 0.625rem !important;
        font-size: 1rem !important; /* Mantener 1rem para evitar zoom */
    }
    
    select.form-control {
        padding-right: 2.75rem !important;
        background-size: 1.1em 1.1em !important;
    }
    
    .btn {
        padding: 0.75rem 1.25rem !important;
        font-size: 0.95rem !important;
    }
    
    .digesto-hero h1 {
        font-size: 1.5rem;
    }
    
    .digesto-hero p {
        font-size: 0.85rem;
        padding: 0 0.5rem;
    }
}

/* Landscape móvil */
@media (max-width: 896px) and (orientation: landscape) and (max-height: 500px) {
    .digesto-hero {
        padding: 1rem 0;
        margin-bottom: 1rem;
    }
    
    .digesto-hero h1 {
        font-size: 1.5rem;
    }
    
    .search-card {
        padding: 0.75rem;
    }
    
    .form-section {
        padding: 0.5rem;
        margin-bottom: 0.75rem;
    }
}

/* Animation utilities */
.fade-in {
    opacity: 0;
    animation: fadeIn 0.5s ease-in-out forwards;
}

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

.slide-up {
    transform: translateY(20px);
    opacity: 0;
    animation: slideUp 0.6s ease-out forwards;
}

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

/* Focus states for accessibility */
.form-control:focus,
.btn:focus,
.nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .digesto-hero,
    .btn,
    .nav-tabs {
        display: none !important;
    }
    
    .search-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .table {
        font-size: 0.8rem;
    }
}
