* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #0f172a;
    color: #e2e8f0;
    min-height: 100vh;
}

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

h1 {
    text-align: center;
    color: #10b981;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 28px;
}

.subtitle {
    text-align: center;
    color: #94a3b8;
    margin-bottom: 40px;
    font-size: 14px;
}

/* Section Styles */
.section-title {
    color: #10b981;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #1e293b;
}

.card {
    background-color: #1e293b;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid #334155;
}

.card h3 {
    margin-top: 0;
    color: #10b981;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.card-header-inline {
    display: grid;
    grid-template-columns: 220px 1fr;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.card-header-inline h3 {
    margin: 0;
    margin-bottom: 0;
    width: 220px;
    flex-shrink: 0;
}

.card-header-inline h4 {
    margin: 0;
    margin-bottom: 0;
    width: 220px;
    flex-shrink: 0;
}

.card-header-inline select {
    padding: 8px 12px;
    font-size: 14px;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    outline: none;
    transition: border-color 0.2s;
    min-width: 200px;
}

.card-header-inline .form-group-file {
    padding: 8px 12px;
}

.card-header-inline select:focus {
    border-color: #10b981;
}

.card-header-inline select option {
    background-color: #0f172a;
    color: #e2e8f0;
}

.card h4 {
    margin-top: 0;
    color: #10b981;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.card p {
    color: #94a3b8;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Form controls */
.form-group {
    margin-bottom: 20px;
}

.form-group-inline {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.form-group-file {
    flex: 1;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 15px;
}

.form-group-file:focus-within {
    border-color: #10b981;
}

.form-group-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group-actions .checkbox-group {
    margin-bottom: 0;
}

.button-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.button-row .btn-flash,
.button-row .btn-recover {
    height: 44px;
}

.form-group-file input[type="file"] {
    width: 100%;
    padding: 10px 0;
    font-size: 0;
    background-color: transparent;
    border: none;
    border-radius: 0;
    color: #e2e8f0;
    outline: none;
}

.form-group-file input[type="file"]::-webkit-file-upload-button {
    padding: 8px 16px;
    background-color: #10b981;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.form-group-file input[type="file"]::-webkit-file-upload-button:hover {
    background-color: #34d399;
}

.form-group-file input[type="file"]::file-selector-button {
    padding: 8px 16px;
    background-color: #10b981;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.form-group-file input[type="file"]::file-selector-button:hover {
    background-color: #34d399;
}

.form-group-file input[type="text"],
.form-group-file input[type="number"] {
    width: 100%;
    padding: 8px 0;
    font-size: 14px;
    background-color: transparent;
    border: none;
    border-radius: 0;
    color: #e2e8f0;
    outline: none;
}

.form-group-file input[type="text"]::placeholder,
.form-group-file input[type="number"]::placeholder {
    color: #64748b;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: #cbd5e1;
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group select,
.form-group input[type="file"] {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    outline: none;
    transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input[type="file"]:focus {
    border-color: #10b981;
}

.form-group select option {
    background-color: #0f172a;
    color: #e2e8f0;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #10b981;
}

.checkbox-group label {
    font-size: 14px;
    color: #cbd5e1;
    cursor: pointer;
}

/* File info display */
.file-info {
    margin-top: 10px;
}

.file-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
}

.file-info-item:last-child {
    border-bottom: none;
}

.file-info-label {
    color: #94a3b8;
    font-weight: 500;
}

.file-info-value {
    color: #10b981;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    word-break: break-all;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.debug-controls-row {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.debug-controls-row .collapsible {
    margin-bottom: 0;
    flex: 1;
    min-width: 300px;
}

button {
    padding: 10px 28px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-flash {
    background-color: #10b981;
    color: #0f172a;
}

.btn-flash:hover:not(:disabled) {
    background-color: #34d399;
    transform: translateY(-2px);
}

.btn-recover {
    background-color: #ef4444;
    color: white;
}

.btn-recover:hover:not(:disabled) {
    background-color: #f87171;
    transform: translateY(-2px);
}

.btn-recover.hidden {
    display: none;
}

.btn-rtt {
    background-color: #3b82f6;
    color: white;
}

.btn-rtt:hover:not(:disabled) {
    background-color: #60a5fa;
    transform: translateY(-2px);
}

.btn-reset-soft {
    background-color: #f97316;
    color: white;
}

.btn-reset-soft:hover:not(:disabled) {
    background-color: #fb923c;
    transform: translateY(-2px);
}

.btn-reset-hard {
    background-color: #64748b;
    color: white;
}

.btn-reset-hard:hover:not(:disabled) {
    background-color: #94a3b8;
    transform: translateY(-2px);
}

.btn-utility {
    background-color: #64748b;
    color: white;
    padding: 8px 16px;
    font-size: 14px;
}

.btn-utility:hover:not(:disabled) {
    background-color: #94a3b8;
    transform: translateY(-2px);
}

/* RTT Terminal */
.terminal-container {
    background-color: #0f172a;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    border: 1px solid #334155;
    height: 500px;
    overflow-y: auto;
}

.terminal-inner {
    background-color: transparent;
    border-radius: 0;
    padding: 0;
    margin-top: 0;
    border: none;
}

.terminal-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #334155;
}

.btn-terminal-clear,
.btn-terminal-save {
    padding: 6px 12px;
    font-size: 12px;
    background-color: #1e293b;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-terminal-clear:hover,
.btn-terminal-save:hover {
    background-color: #334155;
}

.terminal-buffer-info {
    margin-left: auto;
    font-size: 11px;
    color: #94a3b8;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.terminal-output {
    background-color: #020617;
    border-radius: 4px;
    padding: 10px;
    min-height: 400px;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.terminal-output::-webkit-scrollbar {
    width: 8px;
}

.terminal-output::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 4px;
}

.terminal-output::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.terminal-output::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

.terminal-line {
    white-space: pre-wrap;
    word-break: break-all;
}

.terminal-output {
    color: #e2e8f0;
}

.terminal-input {
    color: #10b981;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.terminal-prompt {
    color: #10b981;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    font-weight: bold;
}

.terminal-input {
    flex: 1;
    padding: 6px 10px;
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    background-color: #020617;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #e2e8f0;
    outline: none;
}

.terminal-input:focus {
    border-color: #10b981;
}

.terminal-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#rttTerminalContainer {
    overflow: visible !important;
}

/* RTT Input fields */
.form-group input[type="text"],
.form-group input[type="number"] {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
    border-color: #10b981;
}

/* Step progress */
.step-progress {
    margin-top: 20px;
    display: none;
}

.step-progress.visible {
    display: block;
}

.step-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 14px;
    color: #64748b;
    transition: color 0.3s;
}

.step-item:last-child {
    border-bottom: none;
}

.step-item.active {
    color: #10b981;
}

.step-item.completed {
    color: #10b981;
}

.step-item.error {
    color: #ef4444;
}

.step-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
    background-color: #334155;
    color: #64748b;
    transition: all 0.3s;
}

.step-item.active .step-indicator {
    background-color: #10b981;
    color: #0f172a;
    animation: pulse 1.5s infinite;
}

.step-item.completed .step-indicator {
    background-color: #10b981;
    color: #0f172a;
}

.step-item.error .step-indicator {
    background-color: #ef4444;
    color: #0f172a;
}

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

.step-content {
    flex: 1;
}

.step-name {
    display: block;
}

.step-progress-bar {
    width: 100%;
    height: 4px;
    background-color: #0f172a;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
    display: none;
}

.step-item.active .step-progress-bar {
    display: block;
}

.step-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #34d399);
    width: 0%;
}

.step-progress-text {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 2px;
    display: none;
}

.step-item.active .step-progress-text {
    display: block;
}

/* Step preview (before execution) */
.step-preview {
    margin-top: 0;
}

.step-preview h4 {
    margin-top: 0;
    color: #10b981;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.step-preview input[type="file"] {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    outline: none;
    transition: border-color 0.2s;
    cursor: pointer;
}

.step-preview input[type="file"]:focus {
    border-color: #10b981;
}

.step-preview input[type="file"]::-webkit-file-upload-button {
    padding: 8px 16px;
    background-color: #10b981;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.step-preview input[type="file"]::-webkit-file-upload-button:hover {
    background-color: #34d399;
}

.step-preview input[type="file"]::file-selector-button {
    padding: 8px 16px;
    background-color: #10b981;
    color: #0f172a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.step-preview input[type="file"]::file-selector-button:hover {
    background-color: #34d399;
}

.step-preview-list {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: #94a3b8;
}

.step-preview-item {
    background-color: #0f172a;
    padding: 4px 12px;
    border-radius: 12px;
    white-space: nowrap;
    border: 1px solid #334155;
}

.step-preview-arrow {
    color: #64748b;
}

/* Warning box */
.warning-box {
    background-color: rgba(245, 158, 11, 0.1);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.warning-box p {
    color: #f59e0b;
    margin: 0;
    font-size: 13px;
}

/* Status Bar */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: #1e293b;
    border-top: 1px solid #334155;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.status-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #94a3b8;
    font-size: 14px;
}

.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-disconnected { background-color: #ef4444; }
.status-connected { background-color: #10b981; }
.status-busy {
    background-color: #f59e0b;
    animation: pulse 1s ease-in-out infinite;
}

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

/* Log */
.log-container {
    background-color: #1e293b;
    border-radius: 12px;
    padding: 20px;
    margin-top: 0;
    margin-bottom: 0;
    min-height: 300px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #334155;
}

.log-container .checkbox-group {
    margin-bottom: 15px;
}

#log {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-info { color: #10b981; }
.log-success { color: #10b981; }
.log-error { color: #ef4444; }
.log-warning { color: #f59e0b; }

/* Footer */
footer {
    text-align: center;
    padding: 0 20px 60px 20px;
    color: #64748b;
    font-size: 12px;
}

footer p {
    margin: 10px 0;
}

footer a {
    color: #10b981;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Disclaimer Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background-color: #1e293b;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid #334155;
}

.modal-content h2 {
    color: #ef4444;
    margin-top: 0;
    font-size: 22px;
    text-align: center;
}

.modal-content p {
    color: #e2e8f0;
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 15px;
}

.modal-content ul {
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.8;
    margin-bottom: 20px;
    padding-left: 20px;
}

.modal-content .btn-agree {
    display: block;
    width: 100%;
    padding: 14px 28px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background-color: #ef4444;
    color: white;
    font-weight: 500;
    transition: all 0.2s ease;
}

.modal-content .btn-agree:hover {
    background-color: #f87171;
}

.main-content.disabled {
    pointer-events: none;
    opacity: 0.3;
}

/* Collapsible */
.collapsible {
    margin-bottom: 20px;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 8px;
    overflow: hidden;
}

.collapsible-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: #0f172a;
    color: #e2e8f0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    text-align: left;
    border: none;
}

.collapsible-header:hover {
    background-color: #1e293b;
}

.collapsible-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.collapsible-header.collapsed .collapsible-icon {
    transform: rotate(-90deg);
}

.collapsible-content {
    padding: 16px;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    max-height: 500px;
    opacity: 1;
    overflow: hidden;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px 15px 80px 15px;
    }

    h1 {
        font-size: 24px;
    }

    .section-title {
        font-size: 20px;
    }

    .card {
        padding: 20px;
    }

    .button-group {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .status-bar {
        padding: 10px 15px;
    }

    .status-bar-right {
        font-size: 12px;
    }

    .terminal-output {
        min-height: 150px;
        max-height: 300px;
    }

    .log-container {
        min-height: 250px;
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 20px;
    }

    .subtitle {
        font-size: 12px;
    }

    .card {
        padding: 16px;
    }

    .step-preview-list {
        flex-direction: column;
        align-items: flex-start;
    }

    .step-preview-arrow {
        display: none;
    }
}
