/* ════════════════════════════════════════════════════════════
   SourceCode Website - Light/White Professional Theme
   Full-screen tool layout, fits the viewport
   ════════════════════════════════════════════════════════════ */

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

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1a1d23;
    --text-secondary: #5f6775;
    --text-muted: #9ca3af;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --success-hover: #15803d;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --secondary: #6b7280;
    --log-bg: #1e1f26;
    --log-text: #d4d4d8;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

/* ── App Wrapper: fill viewport ── */
.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ── Top Bar ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 48px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.topbar-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Badges ── */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    letter-spacing: 0.3px;
}

.badge-version {
    background: #f0f0f5;
    color: var(--text-secondary);
}

.badge-offline {
    background: #fef2f2;
    color: #dc2626;
}

.badge-online {
    background: #f0fdf4;
    color: #16a34a;
}

/* ── Main Content: 2 panels side-by-side ── */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* ── Panels ── */
.panel {
    padding: 20px;
    overflow-y: auto;
}

.panel-controls {
    width: 360px;
    min-width: 320px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

.panel-log {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    padding: 16px 20px;
}

.panel-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ── Field Groups ── */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* ── Device Status ── */
.device-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: #f9fafb;
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-idle     { background: #d1d5db; }
.dot-detected { background: #16a34a; box-shadow: 0 0 6px rgba(22,163,74,0.4); }
.dot-error    { background: #dc2626; }
.dot-busy     { background: #f59e0b; animation: pulse 1.2s infinite; }

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

/* ── Info Card ── */
.info-card {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 7px 12px;
    font-size: 12px;
    border-bottom: 1px solid #f0f1f3;
}

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

.info-key {
    color: var(--text-muted);
    font-weight: 500;
}

.info-val {
    color: var(--text);
    font-weight: 600;
    text-align: right;
}

/* ── Inputs ── */
.text-field,
.select-field {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s;
}

.text-field:focus,
.select-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    outline: none;
}

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

.btn-icon {
    width: 16px;
    height: 16px;
}

.btn-full { width: 100%; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover:not(:disabled) { background: var(--success-hover); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-secondary {
    background: #f3f4f6;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: #e5e7eb; }

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.btn-text:hover { background: #f3f4f6; color: var(--text); }

/* ── Actions Group ── */
.actions-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.actions-sub {
    display: flex;
    gap: 8px;
}

.actions-sub .btn { flex: 1; }

/* ── Progress ── */
.progress-group {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.progress-track {
    width: 100%;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--success);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-fill.indeterminate {
    width: 100%;
    background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%);
    animation: slide 1.4s infinite linear;
}

@keyframes slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-label {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Log Panel ── */
.panel-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.log-box {
    flex: 1;
    background: var(--log-bg);
    border-radius: var(--radius);
    padding: 14px 16px;
    overflow-y: auto;
    border: 1px solid #2a2c35;
}

.log-box::-webkit-scrollbar { width: 5px; }
.log-box::-webkit-scrollbar-track { background: var(--log-bg); }
.log-box::-webkit-scrollbar-thumb { background: #3a3d4a; border-radius: 3px; }

#logOutput {
    font-family: 'Consolas', 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--log-text);
}

/* Log colors */
.log-cyan       { color: #22d3ee; }
.log-limegreen  { color: #4ade80; }
.log-red        { color: #f87171; }
.log-orange     { color: #fb923c; }
.log-darkorange { color: #f97316; }
.log-white      { color: #e4e4e7; }
.log-gray       { color: #9ca3af; }
.log-dim        { color: #4b5563; }
.log-magenta    { color: #c084fc; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .panel-controls {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 50vh;
    }

    .panel-log {
        min-height: 40vh;
    }
}
