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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: #2c3e50;
    color: white;
    padding: 20px 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.header p {
    font-size: 14px;
    opacity: 0.8;
}

/* Language Switcher */
.language-switcher {
    display: flex;
    gap: 5px;
}

.lang-btn {
    padding: 8px 12px;
    border: 2px solid rgba(255,255,255,0.3);
    background: transparent;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s;
    margin: 0;
}

.lang-btn:hover {
    border-color: rgba(255,255,255,0.6);
    background: rgba(255,255,255,0.1);
}

.lang-btn.active {
    background: white;
    color: #2c3e50;
    border-color: white;
}

.content {
    padding: 30px;
}

.section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.section-title {
    font-size: 18px;
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
}

/* Firmware Source Box */
.firmware-source-box {
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

.firmware-source-title {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 12px;
    font-size: 14px;
}

.firmware-selects {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.firmware-select {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
    background: white;
}

.firmware-select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-small {
    padding: 8px 16px !important;
    font-size: 13px !important;
    min-width: auto !important;
    margin: 0 !important;
}

/* Or Divider */
.or-divider {
    display: flex;
    align-items: center;
    margin: 15px 0;
    color: #888;
    font-size: 13px;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}

.or-divider span {
    padding: 0 15px;
}

/* Debug Section */
.debug-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    padding: 10px 15px;
    background: #e9ecef;
    border-radius: 5px;
    margin-bottom: 15px;
    color: #666;
    font-size: 14px;
}

.debug-toggle:hover {
    background: #dee2e6;
}

.debug-toggle .arrow {
    transition: transform 0.3s;
}

.debug-toggle.open .arrow {
    transform: rotate(90deg);
}

.debug-content {
    display: none;
    animation: slideDown 0.3s ease-out;
}

.debug-content.show {
    display: block;
}

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

.debug-section {
    border-left-color: #6c757d;
    background: #f1f3f5;
}

/* Checkbox Styling */
.checkbox-group {
    margin-bottom: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Slider Styling */
.slider-group {
    margin-bottom: 20px;
}

.slider-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
}

.slider-value {
    font-weight: 600;
    color: #667eea;
    min-width: 40px;
    text-align: right;
}

.slider-group input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: background 0.2s;
}

.slider-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #5568d3;
}

.slider-group input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    padding: 0 2px;
}

.control-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

input[type="number"],
select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #667eea;
}

.timing-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 10px;
    padding: 15px;
    background: white;
    border-radius: 5px;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: block;
    padding: 12px 20px;
    background: white;
    border: 2px dashed #667eea;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
    color: #667eea;
    font-weight: 500;
}

.file-input-label:hover {
    background: #f0f4ff;
    border-color: #764ba2;
}

.file-name {
    margin-top: 10px;
    padding: 8px;
    background: white;
    border-radius: 5px;
    font-size: 12px;
    color: #555;
}

button {
    padding: 12px 30px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

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

.btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.3);
}

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

.btn-warning:hover:not(:disabled) {
    background: #e0a800;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 193, 7, 0.3);
}

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

.btn-info:hover:not(:disabled) {
    background: #138496;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(23, 162, 184, 0.3);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.progress-container {
    margin-top: 20px;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e9ecef;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.log-container {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 5px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.log-entry { margin-bottom: 5px; }
.log-info { color: #d4d4d4; }
.log-success { color: #6a9955; }
.log-error { color: #f48771; }
.log-warning { color: #dcdcaa; }
.log-debug { color: #808080; }

.status-badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 10px;
}

.status-disconnected { background: #dc3545; color: white; }
.status-connected { background: #28a745; color: white; }
.status-flashing { background: #ffc107; color: #000; }

.chip-info {
    font-size: 14px;
    color: #667eea;
    font-weight: 600;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.info-box {
    background: #e7f3ff;
    border-left: 4px solid #2196F3;
    padding: 12px;
    border-radius: 5px;
    margin-top: 10px;
    font-size: 13px;
    color: #1976D2;
}

.hardware-info {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 12px;
    border-radius: 5px;
    margin-top: 10px;
    font-size: 13px;
    color: #856404;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: #2c3e50;
    font-weight: 600;
}

.log-buttons {
    display: flex;
    gap: 5px;
}

.log-buttons button {
    padding: 5px 10px;
    font-size: 12px;
    min-width: auto;
    margin: 0;
    background: #6c757d;
    color: white;
}

.log-buttons button:hover {
    background: #5a6268;
}

.status-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 5px;
    margin-bottom: 15px;
}

.status-info .chip-details {
    flex: 1;
}

.chip-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

.chip-specs {
    font-size: 12px;
    color: #666;
    margin-top: 3px;
}

/* UID Display */
.uid-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f0f4ff;
    border-radius: 5px;
    margin-top: 8px;
    border: 1px solid #d0d8f0;
}

.uid-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
}

.uid-value {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #2c3e50;
    letter-spacing: 0.5px;
    user-select: all;
}

.uid-copy-btn {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
    line-height: 1;
    color: #666;
    transition: all 0.2s;
}

.uid-copy-btn:hover {
    background: #e8ecf4;
    border-color: #667eea;
    color: #667eea;
}

/* Admin Link */
.admin-link {
    margin-top: 20px;
    text-align: center;
    padding: 10px;
    border-top: 1px solid #eee;
}

.admin-link a {
    color: #888;
    text-decoration: none;
    font-size: 13px;
}

.admin-link a:hover {
    color: #667eea;
}

/* Firmware Hint Box */
.firmware-hint {
    margin-top: 10px;
    padding: 8px 12px;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 4px;
    font-size: 12px;
    color: #856404;
}

/* Firmware Select Wide */
.firmware-select-wide {
    flex: 2 !important;
    min-width: 250px !important;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .timing-controls {
        grid-template-columns: 1fr;
    }
    
    .firmware-selects {
        flex-direction: column;
    }
    
    .firmware-select {
        width: 100%;
    }
    
    .button-group {
        justify-content: center;
    }
    
    button {
        flex: 1;
        min-width: 120px;
    }
}