* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: white;
    font-size: 2.5rem;
    font-weight: 300;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

main {
    display: grid;
    gap: 30px;
    grid-template-columns: 1fr;
}

.status-section,
.controls-section,
.qr-section,
.logs-section,
.test-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.status-card {
    text-align: center;
}

.status-card h2 {
    margin-bottom: 20px;
    color: #555;
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.status-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ccc;
    animation: pulse 2s infinite;
    transition: background-color 0.5s ease;
}

.status-dot.online {
    background: #4CAF50;
}

.status-dot.offline {
    background: #f44336;
}

.status-dot.connecting {
    background: #FF9800;
}

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

.status-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    text-align: left;
    transition: all 0.3s ease;
}

.status-info p {
    margin-bottom: 8px;
}

.controls-section h2,
.qr-section h2,
.logs-section h2,
.test-section h2 {
    margin-bottom: 20px;
    color: #555;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

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

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

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

.btn-primary {
    background: #2196F3;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-warning {
    background: #ffc107;
    color: #212529;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

.qr-container {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-wrap: wrap;
}

#qrCode {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    min-height: 300px;
    min-width: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #ddd;
}

#qrCode img {
    max-width: 100%;
    height: auto;
}

.qr-instructions {
    flex: 1;
    min-width: 250px;
    background: #e3f2fd;
    padding: 20px;
    border-radius: 8px;
    line-height: 1.6;
    color: #0277bd;
}

.logs-container {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
}

.logs-controls {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.logs-content {
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    background: #fff;
    white-space: pre-wrap;
    transition: opacity 0.3s ease;
}

.test-controls {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 15px;
    align-items: center;
}

.form-input {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #2196F3;
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

/* Modal Styles */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 15px;
    padding: 0;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    padding: 25px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    transition: color 0.3s ease;
}

.close:hover {
    color: white;
}

.modal-body {
    padding: 30px;
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.qr-display {
    flex: 0 0 300px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 2px dashed #ddd;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-display img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.qr-instructions {
    flex: 1;
    min-width: 250px;
}

.qr-instructions p {
    margin-bottom: 15px;
    color: #555;
}

.qr-instructions ol {
    margin: 15px 0;
    padding-left: 20px;
}

.qr-instructions ol li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: #666;
}

.note {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 20px !important;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .test-controls {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .modal-body {
        flex-direction: column;
        gap: 20px;
    }

    .qr-display {
        flex: none;
        width: 100%;
    }

    .modal-footer {
        flex-direction: column;
    }
}