* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
}

.header {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    color: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.header h1 {
    font-size: 28px;
    font-weight: 600;
    text-align: center;
    margin: 0;
    flex: 1;
}

#userInfo {
    color: white;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 200px;
    text-align: right;
}

/* Responsive para pantallas medianas */
@media (max-width: 900px) {
    .header h1 {
        font-size: 22px;
    }
    
    #userInfo {
        font-size: 13px;
        min-width: 180px;
    }
}

/* Responsive para pantallas pequeñas */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
        text-align: center;
    }
    
    .header h1 {
        font-size: 20px;
        margin-bottom: 10px;
    }
    
    #userInfo {
        font-size: 13px;
        text-align: center;
        min-width: auto;
        order: 2;
    }
}

@media (max-width: 600px) {
    .header h1 {
        font-size: 18px;
    }
    
    #userInfo {
        font-size: 12px;
    }
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Panel de búsqueda */
.search-panel {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}

.search-group {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.search-group input {
    flex: 1;
    min-width: 200px;
    padding: 12px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
}

.search-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

/* Selector de escenarios */
.scenario-selector {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 25px;
    display: none;
}

.scenario-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.scenario-card {
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.scenario-card:hover {
    border-color: #3498db;
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.scenario-card.active {
    border-color: #3498db;
    background: #e8f4f8;
}

.scenario-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.scenario-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.scenario-desc {
    font-size: 14px;
    color: #7f8c8d;
    line-height: 1.5;
}

/* Formularios */
.form-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: none;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e1e8ed;
}

.form-title {
    font-size: 22px;
    font-weight: 600;
    color: #2c3e50;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #34495e;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.section-divider {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin: 30px 0 20px;
    padding: 10px 0;
    border-bottom: 2px solid #e1e8ed;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Estados y alertas */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Nuevos estilos para puertos */
.ports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e8ed;
}

.port-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid;
    transition: all 0.3s;
    min-height: 80px;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.port-free {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.port-free:hover {
    background: #c3e6cb;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.port-used {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.port-used:hover {
    background: #f5c6cb;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.port-number {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 5px;
}

.port-status {
    font-size: 20px;
    margin-bottom: 5px;
}

.port-client {
    font-size: 10px;
    text-align: center;
    font-weight: 600;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Tabla de puertos (mantenida para compatibilidad) */
.ports-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.ports-table th,
.ports-table td {
    padding: 10px;
    text-align: center;
    border: 1px solid #e1e8ed;
}

.ports-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

/* Valores de medición */
.measurement-value {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-top: 10px;
    transition: all 0.3s;
}

.measurement-value.good {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.measurement-value.warning {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffeaa7;
}

.measurement-value.danger {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

/* Botones de acción */
.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e1e8ed;
}

/* Información de NAP */
.nap-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #3498db;
}

.nap-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: 600;
}

.info-value {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

/* Estilos para las imágenes preview */
.image-preview {
    position: relative;
    width: 150px;
    height: 150px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s;
}

.image-preview:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview .remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.image-preview .remove-image:hover {
    background: #c0392b;
    transform: scale(1.1);
}

/* Loader */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
}

.loader-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Responsive */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .scenario-cards {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .nap-info-grid {
        grid-template-columns: 1fr;
    }
    
    .ports-grid {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 10px;
    }
    
    .port-item {
        min-height: 60px;
        padding: 10px;
    }
    
    .port-number {
        font-size: 14px;
    }
    
    .port-status {
        font-size: 16px;
    }
    
    .port-client {
        font-size: 9px;
    }
}

/* Mejoras visuales adicionales */
.form-group input[readonly] {
    background-color: #f8f9fa;
    color: #6c757d;
}

.section-divider span:first-child {
    font-size: 20px;
}

/* Estados de conexión */
.connection-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.connection-status.online {
    background: #d4edda;
    color: #155724;
}

.connection-status.offline {
    background: #f8d7da;
    color: #721c24;
}

/* Drag & Drop Styles */
.drag-drop-area {
   border: 2px dashed #bdc3c7;
   border-radius: 8px;
   padding: 40px 20px;
   text-align: center;
   background: #f8f9fa;
   transition: all 0.3s;
   cursor: pointer;
   position: relative;
}

.drag-drop-area.drag-over {
   border-color: #3498db;
   background: #e8f4f8;
   transform: scale(1.02);
}

.drag-drop-content {
   pointer-events: none;
}

.drag-drop-icon {
   font-size: 48px;
   margin-bottom: 15px;
   opacity: 0.6;
}

.drag-drop-area p {
   margin: 10px 0;
   color: #34495e;
   font-size: 16px;
}

.browse-btn {
   background: #3498db;
   color: white;
   border: none;
   padding: 8px 15px;
   border-radius: 4px;
   cursor: pointer;
   transition: all 0.3s;
   pointer-events: all;
}

.browse-btn:hover {
   background: #2980b9;
}

.drag-drop-area small {
   display: block;
   margin-top: 10px;
   color: #7f8c8d;
   font-size: 12px;
}

/* Files Preview */
.files-preview {
   display: grid;
   grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
   gap: 15px;
   margin-top: 20px;
   padding: 15px;
   background: #f8f9fa;
   border-radius: 8px;
   border: 1px solid #e1e8ed;
}

.file-preview-item {
   background: white;
   border-radius: 8px;
   padding: 10px;
   box-shadow: 0 2px 4px rgba(0,0,0,0.1);
   position: relative;
   transition: all 0.3s;
}

.file-preview-item:hover {
   transform: translateY(-2px);
   box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.file-thumbnail {
   width: 100%;
   height: 100px;
   border-radius: 6px;
   overflow: hidden;
   position: relative;
   background: #ecf0f1;
   display: flex;
   align-items: center;
   justify-content: center;
}

.file-thumbnail img {
   width: 100%;
   height: 100%;
   object-fit: cover;
}

.video-thumbnail {
   background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.video-icon {
   font-size: 32px;
   color: white;
}

.file-overlay {
   position: absolute;
   top: 5px;
   left: 5px;
   background: rgba(0,0,0,0.7);
   color: white;
   padding: 2px 6px;
   border-radius: 3px;
   font-size: 10px;
   font-weight: bold;
}

.file-info {
   margin-top: 8px;
   text-align: center;
}

.file-name {
   font-size: 12px;
   font-weight: 600;
   color: #2c3e50;
   margin-bottom: 3px;
   word-wrap: break-word;
}

.file-size {
   font-size: 11px;
   color: #7f8c8d;
}

.remove-file-btn {
   position: absolute;
   top: -5px;
   right: -5px;
   background: #e74c3c;
   color: white;
   border: none;
   border-radius: 50%;
   width: 20px;
   height: 20px;
   font-size: 12px;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   transition: all 0.3s;
}

.remove-file-btn:hover {
   background: #c0392b;
   transform: scale(1.1);
}

/* Media Gallery Styles */
.media-gallery {
   margin: 20px 0;
   padding: 20px;
   background: #f8f9fa;
   border-radius: 8px;
   border-left: 4px solid #3498db;
}

.media-grid {
   display: grid;
   grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
   gap: 15px;
   margin-top: 15px;
}

.media-item {
   background: white;
   border-radius: 8px;
   overflow: hidden;
   box-shadow: 0 2px 4px rgba(0,0,0,0.1);
   transition: all 0.3s;
   cursor: pointer;
}

.media-item:hover {
   transform: translateY(-2px);
   box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.media-thumbnail {
   width: 100%;
   height: 100px;
   position: relative;
   overflow: hidden;
}

.media-thumbnail img {
   width: 100%;
   height: 100%;
   object-fit: cover;
}

.media-thumbnail video {
   width: 100%;
   height: 100%;
   object-fit: cover;
}

.media-type-badge {
   position: absolute;
   top: 5px;
   right: 5px;
   background: rgba(0,0,0,0.8);
   color: white;
   padding: 2px 6px;
   border-radius: 3px;
   font-size: 10px;
   font-weight: bold;
}

.media-details {
   padding: 10px;
   text-align: center;
}

.media-details strong {
   display: block;
   font-size: 12px;
   color: #2c3e50;
   margin-bottom: 4px;
}

.media-details small {
   font-size: 10px;
   color: #7f8c8d;
   line-height: 1.2;
}

/* Media Modal */
.media-modal {
   position: fixed;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   background: rgba(0,0,0,0.9);
   display: flex;
   justify-content: center;
   align-items: center;
   z-index: 10000;
}

.media-modal-content {
   position: relative;
   max-width: 90%;
   max-height: 90%;
   background: #2c3e50;
   border-radius: 8px;
   overflow: hidden;
}

.media-modal img {
   max-width: 100%;
   max-height: 80vh;
   object-fit: contain;
   display: block;
}

.media-modal video {
   max-width: 100%;
   max-height: 80vh;
   outline: none;
}

.close-media-modal {
   position: absolute;
   top: -15px;
   right: -15px;
   background: #e74c3c;
   color: white;
   border: none;
   border-radius: 50%;
   width: 30px;
   height: 30px;
   cursor: pointer;
   font-size: 16px;
   font-weight: bold;
   display: flex;
   align-items: center;
   justify-content: center;
   transition: all 0.3s;
}

.close-media-modal:hover {
   background: #c0392b;
   transform: scale(1.1);
}

/* Responsive */
@media (max-width: 768px) {
   .files-preview {
       grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
       gap: 10px;
       padding: 10px;
   }
}

/* =============================================================================
   ESTILOS PARA HISTORIAL DE NAP
   ============================================================================= */

.history-timeline {
    max-height: 450px;
    overflow-y: auto;
    padding-right: 10px;
}

.history-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
}

.history-item:before {
    content: '';
    position: absolute;
    left: -8px;
    top: 20px;
    width: 12px;
    height: 12px;
    background: #3498db;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 2px #3498db;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: bold;
}

.history-time {
    color: #2c3e50;
    font-size: 14px;
}

.history-type {
    background: #3498db;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.history-technician {
    color: #7f8c8d;
    font-size: 13px;
    margin-bottom: 10px;
}

.history-details {
    margin-bottom: 10px;
}

.history-detail {
    background: white;
    padding: 6px 10px;
    margin: 4px 0;
    border-radius: 4px;
    border-left: 3px solid #3498db;
    font-size: 13px;
    color: #2c3e50;
}

.history-observation {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 8px 12px;
    border-radius: 4px;
    font-style: italic;
    color: #856404;
    margin-top: 8px;
}

.media-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.media-item {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.media-item:hover {
    transform: scale(1.05);
}

.media-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    text-align: center;
    font-size: 10px;
    padding: 2px;
}

.photo-item img {
    border-radius: 6px;
}

.video-item video {
    border-radius: 6px;
}

.no-history {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
    font-size: 16px;
}

/* Scrollbar personalizado para el historial */
.history-timeline::-webkit-scrollbar {
    width: 6px;
}

.history-timeline::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.history-timeline::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 3px;
}

.history-timeline::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .history-modal-content {
        width: 95% !important;
        max-height: 90% !important;
    }
    
    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .media-gallery {
        justify-content: center;
    }
    
    .media-item {
        width: 80px;
        height: 60px;
    }
    
    .media-item img,
    .media-item video {
        width: 80px !important;
        height: 60px !important;
    }
}

/* Animación de entrada del modal */
.history-modal {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.history-modal-content {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mejorar separación y claridad */
.history-header {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    border-left: 4px solid #3498db;
}

.history-time-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-exact-time {
    font-size: 11px;
    color: #7f8c8d;
    font-weight: normal;
}

.history-type-badge {
    background: #3498db;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

.history-divider {
    background: #e8f4f8;
    padding: 8px 12px;
    margin: 10px 0 5px 0;
    border-radius: 4px;
    font-weight: bold;
    color: #2c3e50;
    font-size: 13px;
}