/* Fondo general */
body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #cce0ff 0%, #eaf6ff 100%);
    min-height: 100vh;
}

/* Header */
header {
    background: #003366;
    color: white;
    padding: 18px 20px 12px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

header h1 {
        margin: 0;
        color: white;
        text-align: center;
        font-size: 2.1em;
        letter-spacing: 1px;
        font-weight: 700;
        flex-grow: 1;
        text-shadow: 0 2px 8px #00224444;
}

#fecha_hoy {
        font-size: 15px;
        color: #e0e0e0;
        text-align: right;
        margin-top: 4px;
}

/* Navegación */
nav {
    background: #0059b3;
    padding: 10px 0;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

nav .tab {
    color: white;
    margin: 0 16px;
    text-decoration: none;
    font-weight: bold;
    text-align: center;
    padding: 8px 18px;
    border-radius: 6px 6px 0 0;
    transition: background 0.2s, color 0.2s;
    font-size: 1.1em;
}

nav .tab:hover, nav .tab.active {
        background-color: #003366;
        color: #ffc04d;
}

/* Contenedor principal */
.container {
        width: 95%;
        max-width: 1200px;
        margin: 24px auto;
        background-color: #ffffffee;
        padding: 28px 24px 24px 24px;
        border-radius: 16px;
        box-shadow: 0 4px 24px rgba(0,0,0,0.10);
        display: flex;
        flex-direction: row;
        gap: 24px;
        flex-wrap: wrap;
}

@media (max-width: 900px) {
    .container {
        flex-direction: column;
        padding: 16px 4vw;
        gap: 12px;
    }
}

/* Botón guardar */
.plc-btn-guardar {
    background: linear-gradient(90deg, #ffb347 0%, #ffcc80 100%);
    color: #003366;
    font-weight: bold;
    padding: 12px 28px;
    border: none;
    border-radius: 8px;
    margin-bottom: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px #ffc04d33;
    font-size: 1.1em;
    transition: all 0.3s;
    outline: none;
}

.plc-btn-guardar.active {
    background: linear-gradient(90deg, #43a047 0%, #66bb6a 100%);
    color: white;
    box-shadow: 0 2px 12px #43a04733;
}

/* Secciones */
section {
    margin-bottom: 20px;
}

h2 {
    color: #003366;
    border-bottom: 2px solid #003366;
    padding-bottom: 5px;
}

/* Entradas y salidas */
.entradas-digitales label,
.entradas-analogicas label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.entradas-analogicas input[type=range] {
    width: 200px;
}

.salidas p {
    margin: 5px 0;
    font-weight: bold;
}


/* Sidebar de PLCs */
.sidebar {
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 0 12px 0;
    background-color: #f7faff;
    border-radius: 10px;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px #00336611;
    margin-bottom: 18px;
}

.sidebar button {
    flex: 1 1 120px;
    padding: 12px 18px;
    border: none;
    border-radius: 7px;
    background: #e0e0e0;
    cursor: pointer;
    font-weight: bold;
    font-size: 1em;
    transition: all 0.3s;
    text-align: center;
    box-shadow: 0 1px 4px #00336611;
    outline: none;
}

.sidebar button:hover {
    background: linear-gradient(90deg, #ffc04d 0%, #ffe0b2 100%);
    color: #003366;
}

.sidebar button.active {
    background: linear-gradient(90deg, #ff9800 0%, #ffb74d 100%);
    color: white;
    box-shadow: 0 2px 8px #ff980033;
}

/* Feedback visual */
.feedback {
    margin-top: 10px;
    padding: 12px;
    border-radius: 8px;
    background: linear-gradient(90deg, #e0f7fa 0%, #b2ebf2 100%);
    color: #00796b;
    font-weight: bold;
    box-shadow: 0 2px 8px #00796b22;
    font-size: 1.05em;
    text-align: center;
    animation: fadeIn 0.5s;
}

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

/* Responsive */
@media (max-width: 700px) {
    .container {
        width: 99%;
        padding: 4px;
        flex-direction: column;
        gap: 8px;
    }
    .sidebar {
        flex-direction: column;
        gap: 8px;
    }
    .plc-card {
        padding: 12px 6px;
    }
}

/* --- HMI index specific (panel de PLCs) --- */
body {
    background: #f4f4f4;
    color: #181818;
}

nav.hmi-nav {
    background: #fff;
    border-bottom: 2px solid #222;
    display: flex;
    justify-content: center;
    gap: 0;
}

nav.hmi-nav .tab {
    color: #181818;
    background: none;
    border: none;
    font-weight: 600;
    font-size: 1.08em;
    padding: 12px 36px 10px 36px;
    border-right: 1.5px solid #222;
    border-radius: 0;
    transition: background 0.2s, color 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

nav.hmi-nav .tab:last-child { border-right: none; }
nav.hmi-nav .tab.active,
nav.hmi-nav .tab:hover { background: #222; color: #fff; }

.hmi-container {
    max-width: 900px;
    margin: 36px auto 0 auto;
    background: #fff;
    border: 2.5px solid #222;
    border-radius: 18px;
    box-shadow: 0 4px 24px #0002;
    padding: 32px 32px 24px 32px;
}

.plc-list {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    border-bottom: 2px solid #222;
    padding-bottom: 18px;
}

.plc-list li {
    background: #f4f4f4;
    border-radius: 8px;
    border: 2px solid #222;
    padding: 12px 28px;
    cursor: pointer;
    font-weight: 600;
    color: #181818;
    font-size: 1.08em;
    transition: background 0.2s, color 0.2s, border 0.2s;
    text-transform: uppercase;
}

.plc-list li.selected {
    background: #222;
    color: #fff;
    border: 2.5px solid #222;
}

.plc-vars {
    margin-top: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px 40px;
    border-radius: 16px;
    background: #f9f9f9;
    padding: 38px 32px 38px 32px;
    border: 2.5px solid #222;
}

.plc-var-label,
.plc-btn-label {
    color: #181818;
    font-size: 1em;
    font-weight: 600;
    background: #eaeaea;
    border-radius: 18px;
    padding: 8px 18px;
    margin: 2px 0;
    display: inline-block;
    border: 1.5px solid #222;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-transform: capitalize;
}

.plc-var-label:hover,
.plc-btn-label:hover { background: #d6d6d6; }

.plc-var-value input[type="text"],
.plc-var-value input[type="number"],
.plc-var-value input[type="checkbox"] {
    font-size: 1em;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1.5px solid #222;
    background: #fff;
    color: #181818;
}

.plc-var-value input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.save-btn {
    margin-top: 18px;
    background: #222;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 12px 32px;
    font-size: 1.08em;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    border: 2px solid #222;
    letter-spacing: 1px;
}

.save-btn:active { background: #444; }

.save-feedback {
    margin-top: 12px;
    min-height: 22px;
    font-size: 1em;
    color: #1976d2;
}

.plc-salidas-title, .plc-section-title {
    margin-top: 24px;
    font-size: 1.1em;
    color: #181818;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.status-on {
    color: #4CAF50;
    font-weight: 700;
}

.status-off {
    color: #999;
}

.numeric-value {
    color: #1976d2;
    font-weight: 700;
    font-size: 1.1em;
}

.highlight-velocidad {
    color: #FF6B00;
    font-size: 1.2em;
    background: #FFF3E0;
    padding: 4px 8px;
    border-radius: 4px;
}

.live-indicator {
    background: #1a1a1a;
    color: #FF5252;
    padding: 12px;
    margin-top: 20px;
    border-radius: 6px;
    text-align: center;
    font-weight: 700;
    font-size: 1em;
    border: 2px solid #333;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Tabla de variables PLC */
.plc-vars-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.95em;
}

.plc-vars-table thead {
    background: #252525;
    border-bottom: 2px solid #444;
    position: sticky;
    top: 0;
}

.plc-vars-table th {
    padding: 12px 10px;
    text-align: center;
    font-weight: 700;
    color: #FFB74D;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plc-vars-table tbody tr {
    border-bottom: 1px solid #333;
    transition: background 0.2s ease;
}

.plc-vars-table tbody tr:hover {
    background: #252525;
}

.plc-vars-table td {
    padding: 10px 8px;
    color: #fff;
    text-align: center;
}

.var-name-cell {
    font-weight: 600;
    color: #aaa;
    min-width: 120px;
    text-align: left;
    padding-left: 16px;
}

.var-value-cell {
    font-weight: 700;
    min-width: 80px;
}

.var-input {
    background: #333;
    border: 1px solid #555;
    color: #fff;
    padding: 6px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    width: 75px;
    text-align: center;
    transition: all 0.2s ease;
}

.var-input:hover {
    background: #404040;
    border-color: #FFB74D;
}

.var-input:focus {
    outline: none;
    background: #404040;
    border-color: #64B5F6;
    box-shadow: 0 0 8px rgba(100, 181, 246, 0.4);
}

@media (max-width: 700px) {
    .hmi-container { padding: 8px 2vw; }
    .plc-vars { grid-template-columns: 1fr; padding: 28px 8vw; }
    .plc-list { flex-direction: column; gap: 8px; }
    .plc-vars-table { font-size: 0.85em; }
    .plc-vars-table th,
    .plc-vars-table td { padding: 8px 10px; }
}

/* Header Controls */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.intervalo-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 0.95em;
}

.intervalo-control label {
    color: #e0e0e0;
    white-space: nowrap;
    margin: 0;
}

.intervalo-control input {
    width: 90px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.95em;
}

#btnAplicarIntervalo {
    background: #ffc04d;
    color: #003366;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

#btnAplicarIntervalo:hover {
    background: #ffb84d;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    text-align: center;
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #003366;
    font-size: 1.3em;
}

.modal-content p {
    color: #333;
    margin: 10px 0;
    line-height: 1.5;
}

#modalIntervalValue {
    font-weight: bold;
    color: #ff9800;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 25px;
    justify-content: center;
}

.btn-confirm, .btn-cancel {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.2s;
}

.btn-confirm {
    background: #4CAF50;
    color: white;
}

.btn-confirm:hover {
    background: #45a049;
}

.btn-cancel {
    background: #f44336;
    color: white;
}

.btn-cancel:hover {
    background: #da190b;
}


