/* Component Variables */
:root {
    --primary-color: #0047BA;
    --primary-light: #e0f2fe;
    --primary-dark: #003087;
    --error-color: #ef4444;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --text-primary: #374151;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --background-light: #f8fafc;
    --background-dark: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
}

/* Common Components */
.search-container {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    background: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.search-input-wrapper {
    position: relative;
    flex: 1;
    min-width: 300px;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: 0.9rem;
}

.search-input {
    width: 100%;
    padding-right: 2.5rem;
    padding: 0.75rem 2.5rem 0.75rem 2.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #0047BA;
    box-shadow: 0 0 0 3px rgba(0, 71, 186, 0.1);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clear-search-btn:hover {
    color: #ef4444;
    background-color: #fef2f2;
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-select {
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    background: #ffffff;
    color: #374151;
    font-family: inherit;
}

.filter-select:focus {
    outline: none;
    border-color: #0047BA;
    box-shadow: 0 0 0 3px rgba(0, 71, 186, 0.1);
}

/* Reset básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333333;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
    position: relative;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(25, 118, 210, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(25, 118, 210, 0.02) 0%, transparent 50%);
    z-index: -1;
}

.header {
    background: #0047BA;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 0.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 71, 186, 0.3);
}

.header-content {
    max-width: 99%;
    margin: 0 auto;
    padding: 0 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.header-top {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.logo-container {
    flex-shrink: 0;
}

.logo {
    height: 40px;
    width: auto;
    filter: brightness(0) invert(1);
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #ffffff;
}

.main-content {
    max-width: 99%;
    margin: 1rem auto;
    padding: 0 0.25rem;
}

.form-container {
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(25, 118, 210, 0.1);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.08),
        0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
}

.form-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #1976d2, #42a5f5);
    border-radius: 16px 16px 0 0;
}

.knowledge-form {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    position: relative;
}

.form-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.form-row .form-group {
    flex: 1;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.form-group label i {
    color: #0047BA;
    width: 16px;
    font-size: 0.9rem;
}

.form-input,
.form-textarea,
.form-select {
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    color: #374151;
    font-family: inherit;
    box-shadow: none;
}

.form-input[required],
.form-textarea[required],
.form-select[required] {
    border-color: #0047BA !important;
    box-shadow: none !important;
}

.form-input:invalid,
.form-textarea:invalid,
.form-select:invalid {
    border-color: #0047BA !important;
    box-shadow: none !important;
    outline: none !important;
}

.form-input:valid,
.form-textarea:valid,
.form-select:valid {
    border-color: #0047BA;
    box-shadow: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: #9ca3af;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: #0047BA;
    background: #ffffff;
    box-shadow: 
        0 0 0 3px rgba(0, 71, 186, 0.1),
        0 4px 12px rgba(0, 71, 186, 0.15);
    transform: translateY(-1px);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-textarea::-webkit-scrollbar {
    width: 8px;
}

.form-textarea::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.form-textarea::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.form-textarea::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.form-select {
    cursor: pointer;
    appearance: none;
    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 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 1rem center;
    background-repeat: no-repeat;
    background-size: 1rem;
    padding-right: 3rem;
}

.form-select option {
    background: #ffffff;
    color: #374151;
}

.form-actions {
    margin-top: 1rem;
}

.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #0047BA 0%, #003a9b 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 71, 186, 0.2);
}

.submit-btn:hover {
    background: linear-gradient(135deg, #003a9b 0%, #002d7a 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px -3px rgba(0, 71, 186, 0.3);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn i {
    font-size: 1rem;
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.submit-btn:hover:not(:disabled) {
    background: #003d9f;
    transform: translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(0, 71, 186, 0.3),
        0 3px 10px rgba(0, 0, 0, 0.1);
}

.submit-btn:hover:not(:disabled)::before {
    left: 100%;
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    background: #9ca3af;
}

.submit-btn.submitting {
    animation: pulse 2s infinite;
    background: #003d9f;
}

.loading-spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.message {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    border: 1px solid;
}

.message.success {
    background: #f0f9ff;
    color: #0369a1;
    border-color: #7dd3fc;
}

.message.error {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* Estilos para mensajes de advertencia */
.warning-message {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    color: #856404;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: fadeIn 0.3s ease-out;
}

.warning-message i {
    font-size: 1.25rem;
    margin-top: 0.15rem;
}

.warning-message strong {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.warning-message p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Responsive design */
@media (max-width: 768px) {
    .header-content {
        padding: 0 0.5rem;
    }
    
    .header h1 {
        font-size: 1.2rem;
    }
    
    .main-content {
        padding: 0 0.25rem;
        margin: 0.75rem auto;
    }
    
    .form-container {
        padding: 1rem;
        border-radius: 12px;
    }
    
    .knowledge-form {
        gap: 0.75rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    /* Grid responsive styles */
    .grid-container {
        padding: 1rem;
        margin-top: 1rem;
    }
    
    .grid-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        text-align: center;
    }
    
    .refresh-btn {
        width: 100%;
        justify-content: center;
    }
    
    .knowledge-table {
        font-size: 0.75rem;
    }
    
    .knowledge-table th,
    .knowledge-table td {
        padding: 0.5rem 0.25rem;
    }
    
    /* Hide less important columns on mobile */
    .knowledge-table th:nth-child(5),
    .knowledge-table td:nth-child(5),
    .knowledge-table th:nth-child(6),
    .knowledge-table td:nth-child(6) {
        display: none;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .search-input-wrapper {
        min-width: auto;
    }
    
    .filter-container {
        justify-content: center;
    }
    
    .results-info {
        justify-content: space-between;
    }
    
    .pagination-container {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    
    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .page-numbers {
        margin: 0;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .modal-field textarea {
        min-height: 100px;
    }
    
    .refresh-btn {
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .refresh-btn span {
        display: none;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        padding: 0 0.5rem;
    }
    
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .main-nav {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .nav-link {
        justify-content: flex-start;
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
        border-radius: 4px;
        color: white !important;
    }
    
    .header-content h1 {
        font-size: 1.25rem;
        margin: 0.5rem 0 0 0;
    }
    
    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
}

/* Animation for form submission */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Accessibility */
.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;
}

/* Focus styles for better keyboard navigation */
button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
    outline: 3px solid #0047BA;
    outline-offset: 2px;
    z-index: 1;
}

/* Data Grid Styles */
.grid-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin-top: 2rem;
    width: 100%;
}

.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 71, 186, 0.1);
}

.grid-header h2 {
    margin: 0;
    color: #0047BA;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--background-light);
    border-color: var(--primary-color);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-icon:hover {
    color: var(--text-primary);
}

/* Submit button inherits btn-primary styles */
.submit-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.submit-btn:hover {
    background: var(--primary-dark);
}

.refresh-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.refresh-btn:hover {
    background: var(--primary-dark);
}

.refresh-btn:hover {
    background: #003d9f;
    transform: translateY(-1px);
}

.refresh-icon {
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.refresh-btn:hover .refresh-icon {
    transform: rotate(180deg);
}

.grid-wrapper {
    width: 100%;
    overflow-x: auto;
}

.grid-loading,
.grid-error {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #6b7280;
    font-size: 0.95rem;
}

.grid-error {
    color: #ef4444;
}

.data-grid {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* Table Styles */
.knowledge-table, .data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(0,71,186,0.07);
    overflow: hidden;
    font-size: 1rem;
    line-height: 1.5;
    font-family: 'Barlow', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.knowledge-table tbody tr:nth-child(even) {
    background: #f4f8fd;
}
.knowledge-table tbody tr:nth-child(odd) {
    background: #ffffff;
}
.knowledge-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 0.85rem 0.75rem;
    font-size: 0.97rem;
    color: #23395d;
    vertical-align: middle;
    transition: background 0.2s;
}
.knowledge-table td:last-child {
    text-align: center;
}
.knowledge-table td {
    word-break: break-word;
}


.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-primary);
}

.data-table th {
    background: var(--background-light);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.data-table tr:hover {
    background: var(--background-light);
    cursor: pointer;
}

.data-table .sortable {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.data-table .sortable i {
    margin-left: 0.5rem;
    color: var(--text-secondary);
}

/* Ajustes de columnas de la tabla */
.knowledge-table th[data-sort="title"],
.knowledge-table td:nth-child(1) {
    width: 15%;
    text-align: left;
    padding-left: 1rem;
}

.knowledge-table th[data-sort="description"],
.knowledge-table td:nth-child(2) {
    width: 35%;
    text-align: left;
    padding-left: 1rem;
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.knowledge-table th[data-sort="country"],
.knowledge-table td:nth-child(3) {
    width: 10%;
}

.knowledge-table th[data-sort="user"],
.knowledge-table td:nth-child(4) {
    width: 20%;
}

.knowledge-table th[data-sort="url_video"],
.knowledge-table td:nth-child(5) {
    width: 10%;
}

.knowledge-table th[data-sort="up_date"],
.knowledge-table td:nth-child(6) {
    width: 10%;
}

/* Ajustes específicos para la grilla especializada */
.grid-especialista .knowledge-table th[data-sort="specialty"],
.grid-especialista .knowledge-table td:nth-child(1) {
    width: 12%;
    text-align: left;
    padding-left: 1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.grid-especialista .knowledge-table th[data-sort="title"],
.grid-especialista .knowledge-table td:nth-child(2) {
    width: 18%;
    text-align: left;
    padding-left: 1rem;
}

.grid-especialista .knowledge-table th[data-sort="description"],
.grid-especialista .knowledge-table td:nth-child(3) {
    width: 25%;
    text-align: left;
    padding-left: 1rem;
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grid-especialista .knowledge-table th[data-sort="country"],
.grid-especialista .knowledge-table td:nth-child(4) {
    width: 10%;
}

.grid-especialista .knowledge-table th[data-sort="user"],
.grid-especialista .knowledge-table td:nth-child(5) {
    width: 15%;
}

.grid-especialista .knowledge-table th[data-sort="url"],
.grid-especialista .knowledge-table td:nth-child(6) {
    width: 10%;
}

.grid-especialista .knowledge-table th[data-sort="up_date"],
.grid-especialista .knowledge-table td:nth-child(7) {
    width: 10%;
}

/* Estilos adicionales para la grilla especializada */
.grid-especialista .knowledge-table td:nth-child(1) {
    font-weight: 600;
    color: var(--primary-color);
    padding: 0.5rem;
    text-align: left;
}

/* Responsive para la grilla especializada */
@media (max-width: 1200px) {
    .grid-especialista .knowledge-table th[data-sort="specialty"],
    .grid-especialista .knowledge-table td:nth-child(1) {
        width: 15%;
    }
    
    .grid-especialista .knowledge-table th[data-sort="title"],
    .grid-especialista .knowledge-table td:nth-child(2) {
        width: 20%;
    }
    
    .grid-especialista .knowledge-table th[data-sort="description"],
    .grid-especialista .knowledge-table td:nth-child(3) {
        width: 30%;
    }
}

@media (max-width: 900px) {
    .grid-especialista .knowledge-table th[data-sort="specialty"],
    .grid-especialista .knowledge-table td:nth-child(1) {
        width: 18%;
    }
    
    .grid-especialista .knowledge-table th[data-sort="title"],
    .grid-especialista .knowledge-table td:nth-child(2) {
        width: 25%;
    }
    
    .grid-especialista .knowledge-table th[data-sort="description"],
    .grid-especialista .knowledge-table td:nth-child(3) {
        width: 35%;
    }
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background: #e3edfa !important;
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 4px 12px rgba(0, 71, 186, 0.12);
    transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}

/* Column width distribution for logs table */
.table-layout-logs th:nth-child(1), /* ID */
.table-layout-logs td:nth-child(1) {
    width: 8%;
    min-width: 60px;
}

.table-layout-logs th:nth-child(2), /* País */
.table-layout-logs td:nth-child(2) {
    width: 8%;
    min-width: 70px;
}

.table-layout-logs th:nth-child(3), /* Usuario */
.table-layout-logs td:nth-child(3) {
    width: 12%;
    min-width: 100px;
}

.table-layout-logs th:nth-child(4), /* Tipo */
.table-layout-logs td:nth-child(4) {
    width: 8%;
    min-width: 80px;
}

.table-layout-logs th:nth-child(5), /* Mensaje */
.table-layout-logs td:nth-child(5) {
    width: 50%;
    min-width: 300px;
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-layout-logs th:nth-child(6), /* Fecha */
.table-layout-logs td:nth-child(6) {
    width: 14%;
    min-width: 110px;
}

/* Responsive table styles */
@media (max-width: 900px) {
    .knowledge-table th,
    .knowledge-table td {
        font-size: 0.93rem;
        padding: 0.5rem 0.4rem;
    }
    .knowledge-table td:nth-child(1) {
        max-width: 130px;
    }
    .knowledge-table td:nth-child(4) {
        max-width: 40px;
    }
    .knowledge-table td:nth-child(2),
    .knowledge-table td:nth-child(3) {
        max-width: 120px;
    }
}
@media (max-width: 600px) {
    .table-responsive {
        overflow-x: auto;
        margin: 0 -0.5rem;
        padding: 0 0.5rem;
    }
    .knowledge-table th,
    .knowledge-table td {
        font-size: 0.88rem;
        padding: 0.4rem 0.3rem;
    }
    .knowledge-table td:nth-child(1) {
        max-width: 80px;
    }
    .knowledge-table td:nth-child(4) {
        max-width: 25px;
    }
    .knowledge-table td:nth-child(2),
    .knowledge-table td:nth-child(3) {
        max-width: 70px;
    }
    /* --- MENÚ PRINCIPAL EN MÓVIL --- */
    .main-nav {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        padding: 0.5rem 0;
        width: 100%;
        background: transparent;
    }
    .main-nav .nav-link {
        width: 100%;
        margin: 0;
        border-radius: 8px;
        font-size: 1.04rem;
        padding: 0.7rem 1rem;
        text-align: left;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        white-space: normal;
        overflow: visible;
    }
    .main-nav .nav-link i {
        margin-right: 0.7rem;
        font-size: 1.2rem;
    }
}

/* Column width distribution for knowledge table */
#knowledgeTable th:nth-child(1), /* Título */
#knowledgeTable td:nth-child(1) {
    width: 38%;
    min-width: 200px;
}

#knowledgeTable th:nth-child(2), /* Descripción */
#knowledgeTable td:nth-child(2) {
    width: 35%;
}

#knowledgeTable th:nth-child(3), /* País */
#knowledgeTable td:nth-child(3) {
    width: 10%;
}

#knowledgeTable th:nth-child(4), /* Usuario */
#knowledgeTable td:nth-child(4) {
    width: 6%;
    min-width: 35px;
    max-width: 60px;
}

#knowledgeTable th:nth-child(5), /* URL Video */
#knowledgeTable td:nth-child(5) {
    width: 10%;
}

#knowledgeTable th:nth-child(6), /* Fecha */
#knowledgeTable td:nth-child(6) {
    width: 5%;
}

.knowledge-table th,
.table-layout-logs th {
    background: linear-gradient(90deg, #f8fafc 0%, #e6ecf5 100%);
    color: #2d3a4a;
    font-weight: 700;
    font-size: 1.08rem;
    padding: 6px 10px;
    border-bottom: 2px solid #e2e8f0;
    text-align: left;
    position: relative;
    z-index: 2;
    min-width: 40px;
    transition: background 0.3s;
    height: 32px;
}

.knowledge-table tr:last-child td,
.table-layout-logs tr:last-child td {
    border-bottom: none;
}

.knowledge-table th:first-child {
    border-top-left-radius: 12px;
}
.knowledge-table th:last-child {
    border-top-right-radius: 12px;
}
.knowledge-table tr:last-child td:first-child {
    border-bottom-left-radius: 12px;
}
.knowledge-table tr:last-child td:last-child {
    border-bottom-right-radius: 12px;
}

/* Column specific styles */
.knowledge-table th:nth-child(1) {
    text-align: left;
    min-width: 200px;
    max-width: 440px;
    font-weight: 700;
}
.knowledge-table td:nth-child(1) {
    text-align: left;
    min-width: 200px;
    max-width: 440px;
    font-weight: 400;
} 

.knowledge-table th:nth-child(2),
.knowledge-table td:nth-child(2) {
    min-width: 150px;
    max-width: 200px;
}

.knowledge-table th:nth-child(3),
.knowledge-table td:nth-child(3) {
    min-width: 200px;
    max-width: 300px;
}

.knowledge-table th:nth-child(4) {
    width: 45px;
    min-width: 35px;
    max-width: 60px;
    text-align: left;
    font-weight: 600;
}
.knowledge-table td:nth-child(4) {
    width: 45px;
    min-width: 35px;
    max-width: 60px;
    text-align: left;
    font-weight: 400;
}

.knowledge-table th:nth-child(5),
.knowledge-table td:nth-child(5) {
    min-width: 180px;
}

.knowledge-table th:nth-child(6),
.knowledge-table td:nth-child(6) {
    min-width: 120px;
}

.knowledge-table th:nth-child(7),
.knowledge-table td:nth-child(7) {
    width: 120px;
}

/* Text truncation for long content */
.knowledge-table td:nth-child(2),
.knowledge-table td:nth-child(3) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
    font-size: 0.98rem;
}

/* Main Navigation */
.main-nav {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    padding: 0.25rem 0;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    /* Usar overflow-x: auto es suficiente para el desplazamiento táctil moderno */
}

/* Hide scrollbar for Chrome, Safari and Opera */
.main-nav::-webkit-scrollbar {
    display: none;
}

.main-nav .nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
    background-color: rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.main-nav .nav-link:hover,
.main-nav .nav-link:focus {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.main-nav .nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

/* Dot icon replacement */
.main-nav .nav-link i.fas {
    display: none; /* Hide Font Awesome icons */
}

.main-nav .nav-link::before {
    content: '•';
    display: inline-block;
    margin-right: 6px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.15s ease;
    line-height: 1;
}

.main-nav .nav-link:hover::before,
.main-nav .nav-link:focus::before {
    color: white;
    transform: scale(1.2);
}

.main-nav .nav-link.active::before {
    color: white;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .main-nav {
        gap: 0.5rem;
        padding: 0.25rem 0.5rem;
    }
    
    .main-nav .nav-link {
        padding: 0.35rem 0.7rem;
        font-size: 0.8rem;
    }
    
    .main-nav .nav-link::before {
        margin-right: 5px;
        font-size: 0.8rem;
    }
}

.knowledge-table td:nth-child(6) a {
    color: #0047BA;
    text-decoration: none;
    font-weight: 500;
}

.knowledge-table td:nth-child(6) a:hover {
    text-decoration: underline;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    z-index: 1000;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
    background-color: #f9fafb;
    width: 100%;
    box-sizing: border-box;
}

.modal-header h3 {
    margin: 0;
    color: #0047BA;
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background-color: #f3f4f6;
    color: #374151;
}

/* Loading and Error States */
.loading-indicator,
.error-message,
.no-data-message {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    margin: 1rem 0;
    border-radius: 8px;
    background-color: #f8f9fa;
    text-align: center;
}

.loading-indicator {
    flex-direction: column;
    gap: 1rem;
}

.loading-indicator .spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0047BA;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background-color: #fef2f2;
    color: #b91c1c;
    border-left: 4px solid #dc2626;
}

.error-message i {
    margin-right: 0.5rem;
}

.no-data-message {
    flex-direction: column;
    color: #6b7280;
}

.no-data-message i {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Modal Content */
.modal-body {
    width: 100%;
    padding: 1.5rem 2.5rem;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;           /* Espacio entre campos */
}

/* Message Content */
.message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    padding: 0.75rem;
    background-color: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    max-height: 300px;
    overflow-y: auto;
    box-sizing: border-box; /* Incluye padding en el ancho/alto */
}

.modal-field {
    width: 100%;
    margin-bottom: 0;  /* Eliminamos el margen inferior ya que usamos gap */
    position: relative;
}

.modal-field:last-child {
    margin-bottom: 0;
}

.modal-field label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.modal-value {
    background: #f8fafc;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    color: #374151;
    min-height: 1.5rem;
}

/* Estilos para los campos de entrada del modal */
.modal-input, .modal-textarea {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
    padding: 0.75rem;
    font-size: 0.9rem;
    color: #374151;
    resize: none;
    font-family: 'Barlow', sans-serif;
    transition: all 0.2s ease;
}

.modal-input[readonly], .modal-textarea[readonly] {
    background: #f4f6f8;
    color: #4b5563;
    cursor: default;
    border: 1px solid #e5e7eb;
}

.modal-input:focus, .modal-textarea:focus {
    outline: none;
    border-color: #0047BA;
    box-shadow: 0 0 0 3px rgba(0, 71, 186, 0.1);
}

.modal-textarea {
    min-height: 120px;
    max-height: 200px;
    line-height: 1.5;
}

.modal-label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-label i {
    color: #0047BA;
    width: 16px;
    font-size: 0.9rem;
}

.modal-textarea {
    width: 100%;
    min-height: 120px;
    max-height: 200px;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-family: 'Barlow', sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #374151;
    background: #f8fafc;
    resize: vertical;
    overflow-y: auto;
}

.modal-textarea:focus {
    outline: none;
    border-color: #0047BA;
    box-shadow: 0 0 0 3px rgba(0, 71, 186, 0.1);
}

.modal-field a {
    color: #0047BA;
    text-decoration: underline;
    word-break: break-all;
}

.modal-field a:hover {
    color: #003a9b;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    z-index: 1000;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.search-container {
    min-width: auto;
}

.pagination-container {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.pagination-controls {
    order: 2;
}

.pagination-info {
    order: 1;
}

.page-size-container {
    order: 3;
}

/* Estilos mejorados para el paginador */
.pagination-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1.2rem 0 0.7rem 0;
    width: 100%;
    background: linear-gradient(90deg, #f8fafc 80%, #e2e8f0 100%);
    border-radius: 0 0 14px 14px;
    box-shadow: 0 2px 8px rgba(0,71,186,0.03);
}

.pagination-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination-info {
    font-size: 0.875rem;
    color: #4b5563;
    text-align: center;
}

.pagination-info span {
    font-weight: 600;
    color: #1f2937;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background-color: white;
    color: #4b5563;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-btn:not(:disabled):hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
    color: #1f2937;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f9fafb;
}

.page-btn.active {
    background-color: #0047BA;
    border-color: #0047BA;
    color: white;
    font-weight: 500;
}

.page-btn.active:hover {
    background-color: #003d9d;
    border-color: #003d9d;
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
    margin: 0 0.25rem;
}

.page-number {
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background-color: white;
    color: #4b5563;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.page-number:hover:not(.active):not(.ellipsis) {
    background-color: #f3f4f6;
    border-color: #9ca3af;
    color: #1f2937;
}

.page-number.active {
    background-color: #0047BA;
    border-color: #0047BA;
    color: white;
    font-weight: 500;
    cursor: default;
}

.page-number.ellipsis {
    border: none;
    background: transparent;
    cursor: default;
    min-width: auto;
    padding: 0 0.5rem;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.5rem;
}

.page-size-label {
    font-size: 0.875rem;
    color: #4b5563;
    white-space: nowrap;
}

.page-size-select {
    padding: 0.375rem 1.75rem 0.375rem 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    background-color: white;
    color: #1f2937;
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1em;
    padding-right: 2rem;
}

.page-size-select:focus {
    outline: none;
    border-color: #0047BA;
    box-shadow: 0 0 0 3px rgba(0, 71, 186, 0.1);
}

.page-size-select:hover {
    border-color: #9ca3af;
}

/* Estilos responsivos */
@media (max-width: 640px) {
    .pagination-controls {
        flex-direction: column;
        gap: 1rem;
    }
    
    .pagination-buttons {
        order: 2;
        width: 100%;
        justify-content: center;
    }
    
    .pagination-info {
        order: 1;
        width: 100%;
        text-align: center;
    }
    
    .page-size-selector {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }
}

/* Efectos de transición suaves */
.page-btn,
.page-number,
.page-size-select {
    transition: all 0.15s ease-in-out;
}

/* Mejoras de accesibilidad */
.page-btn:focus-visible,
.page-number:focus-visible,
.page-size-select:focus-visible {
    outline: 2px solid #0047BA;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 71, 186, 0.2);
}

.page-btn:focus:not(:focus-visible),
.page-number:focus:not(:focus-visible),
.page-size-select:focus:not(:focus-visible) {
    outline: none;
}

/* Estilos del mensaje de éxito */
.success-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    width: 90%;
    max-width: 500px;
}

.success-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    text-align: center;
    position: relative;
    animation: slideIn 0.3s ease-out forwards;
}

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

.success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: #f0fdf4;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-icon i {
    font-size: 2.5rem;
    color: #22c55e;
    animation: scaleIn 0.3s ease-out 0.2s both;
}

@keyframes scaleIn {
    from {
        transform: scale(0);
    }
    to {
        transform: scale(1);
    }
}

.success-text h2 {
    color: #0f172a;
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.success-text p {
    color: #64748b;
    font-size: 1rem;
    margin-bottom: 2rem;
}

.success-actions {
    margin-top: 1.5rem;
}

.view-entries-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background-color: #0047BA;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 71, 186, 0.1);
}

.view-entries-btn:hover {
    background-color: #003a94;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 71, 186, 0.2);
}

.view-entries-btn i {
    font-size: 1.1rem;
}

/* Overlay para el fondo cuando aparece el mensaje */
.success-message::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: -1;
    animation: fadeIn 0.3s ease-out forwards;
}

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