/* ===== RESET ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ===== BASE ===== */
body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f6f8;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: auto;
}

/* ===== CARD ===== */
.card {
    background: #fff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* ===== HEADER ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 26px;
    color: #222;
}

h2 {
    margin-bottom: 10px;
    color: #444;
}

h3 {
    margin-bottom: 8px;
}

/* ===== BUTTONS ===== */
.btn,
.btn-primary,
.btn-success,
.btn-danger,
.btn-warning {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    transition: 0.2s;
}

.btn {
    background: #6c757d;
    color: #fff;
}

.btn:hover {
    background: #5a6268;
}

.btn-primary {
    background: #007bff;
    color: #fff;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-success {
    background: #28a745;
    color: #fff;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-logout {
    background: #dc3545;
    color: #fff;
    padding: 10px 15px;
    border-radius: 6px;
    text-decoration: none;
}

.btn-logout:hover {
    background: #c82333;
}

/* ===== INPUTS ===== */
.input,
.input-small {
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 14px;
}

.input:focus,
.input-small:focus {
    outline: none;
    border-color: #007bff;
}

.input-small {
    width: 30%;
}

/* ===== FORM GROUP ===== */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

/* ===== LOGIN ===== */
.card h1 {
    text-align: center;
    margin-bottom: 15px;
}

.error {
    color: red;
    text-align: center;
    margin-bottom: 10px;
    background: #f8d7da;
    padding: 10px;
    border-radius: 6px;
}

.hint {
    text-align: center;
    font-size: 13px;
    color: #777;
    margin-top: 15px;
}

/* ===== DASHBOARD MENU ===== */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.menu-item {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: 0.2s;
    border: 2px solid transparent;
}

.menu-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: #007bff;
}

.menu-item h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.menu-item p {
    font-size: 13px;
    color: #666;
}

.menu-item.disabled {
    opacity: 0.5;
    pointer-events: none;
    background: #f8f9fa;
}

/* ===== RECIPE SETTINGS ===== */
.recipe-list {
    margin-top: 15px;
}

.recipe-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px solid #dee2e6;
}

.recipe-item:hover {
    background: #e9ecef;
}

/* ===== PARAMETER SETTING ===== */
.param-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.param-sets {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.param-sets input {
    flex: 1;
}

/* ===== SELECT RECIPE ===== */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 15px;
}

.recipe-card {
    background: #fdfdfd;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
}

.recipe-card h3 {
    margin-bottom: 10px;
    color: #333;
}

.recipe-card p {
    color: #666;
    margin-bottom: 10px;
}

/* ===== TABLES ===== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

table th,
table td {
    padding: 12px;
    border: 1px solid #dee2e6;
    text-align: left;
}

table th {
    background: #007bff;
    color: white;
    font-weight: bold;
}

table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

table tbody tr:hover {
    background: #e9ecef;
}

tr.success {
    background: #d4edda !important;
}

tr.error {
    background: #f8d7da !important;
}

code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* ===== TCP STATUS ===== */
.status-indicator {
    margin-bottom: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
}

.status {
    padding: 5px 12px;
    border-radius: 12px;
    font-weight: bold;
    display: inline-block;
    margin-left: 10px;
}

.status.connected {
    background: #28a745;
    color: white;
}

.status.disconnected {
    background: #dc3545;
    color: white;
}

/* ===== TESTING SCREEN STYLES ===== */
.register-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.register-card {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s;
}

.register-card.highlight {
    border-color: #ffc107;
    background: #fff3cd;
}

.register-card.triggered {
    border-color: #28a745;
    background: #d4edda;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.register-label {
    font-weight: bold;
    color: #495057;
    margin-bottom: 10px;
    font-size: 14px;
}

.register-value {
    font-size: 32px;
    font-weight: bold;
    color: #007bff;
    margin: 10px 0;
    font-family: 'Courier New', monospace;
}

.register-time {
    font-size: 12px;
    color: #6c757d;
}

.log-panel {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.log-success {
    color: #28a745;
    padding: 5px 0;
}

.log-error {
    color: #dc3545;
    padding: 5px 0;
    font-weight: bold;
}

/* ===== CONTROL PANEL ===== */
.control-panel {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.write-panel {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

/* ===== STATISTICS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-card h3 {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.stat-value {
    font-size: 36px;
    font-weight: bold;
    color: #007bff;
}

.stat-value.active {
    color: #28a745;
}

/* ===== TABLE CONTAINER ===== */
.table-container {
    max-height: 400px;
    overflow-y: auto;
    margin: 20px 0;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

.trigger-active {
    background: #d4edda !important;
    font-weight: bold;
    color: #155724;
}

/* ===== ALERTS ===== */
.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #28a745;
    color: #155724;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

/* ===== CANVAS ===== */
canvas {
    margin: 20px 0;
    max-width: 100%;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .param-sets {
        flex-direction: column;
    }

    .input-small {
        width: 100%;
    }
    
    .menu-grid {
        grid-template-columns: 1fr;
    }
    
    .register-grid {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .write-panel {
        flex-direction: column;
    }
    
    .header {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .card {
        padding: 15px;
    }
    
    h1 {
        font-size: 22px;
    }
    
    .register-value {
        font-size: 24px;
    }
    
    .stat-value {
        font-size: 28px;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.p-10 {
    padding: 10px;
}

.p-20 {
    padding: 20px;
}

/* ===== LOADING SPINNER ===== */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== DISABLED STATE ===== */
button:disabled,
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== SCROLLBAR STYLING ===== */
.log-panel::-webkit-scrollbar,
.table-container::-webkit-scrollbar {
    width: 8px;
}

.log-panel::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.log-panel::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.log-panel::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}