/* ============================================================
   Components — Fluent UI Component Library (Azure Portal Style)
   ============================================================ */

/* ============================================================
   Buttons — Fluent Button
   ============================================================ */
.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    align-items: center;
}

@media (max-width: 768px) {
    .btn-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Seamless Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 24px;
    height: 48px;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: var(--font-size-md);
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
    outline: none;
    user-select: none;
}

.btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(224, 40, 47, 0.2);
}

/* Primary — Static Black */
.btn-primary {
    background: var(--brand-secondary);
    color: var(--white) !important;
}

.btn-primary:hover {
    background: var(--brand-secondary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Secondary / Outline — Gray scale */
.btn-secondary {
    background: var(--white);
    border-color: var(--gray-200);
    color: var(--brand-secondary);
}

.btn-secondary:hover {
    background: var(--gray-25);
    border-color: var(--gray-300);
}

/* Accent — Red */
.btn-accent {
    background: var(--brand-primary);
    color: var(--white) !important;
}

.btn-accent:hover {
    background: var(--brand-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

/* Subtle */
.btn-subtle {
    background: transparent;
    border-color: transparent;
    color: var(--gray-500);
}

.btn-subtle:hover {
    background: var(--gray-50);
    color: var(--brand-secondary);
}

/* Variants */
.btn-sm {
    height: 36px;
    padding: 0 16px;
    font-size: var(--font-size-sm);
}

.btn-lg {
    height: 56px;
    padding: 0 32px;
    font-size: var(--font-size-lg);
    font-weight: 700;
}

/* ============================================================
   Form Elements — Fluent TextField / Dropdown
   ============================================================ */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Fluent label */
.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}

.form-label .required {
    color: var(--color-error);
    margin-left: 2px;
}

/* Seamless Form Elements */
.form-input,
.form-select {
    width: 100%;
    max-width: 520px;
    padding: 0 16px;
    height: 48px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: var(--font-size-md);
    background-color: var(--gray-50);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:hover,
.form-select:hover {
    background-color: var(--gray-75);
    border-color: var(--gray-200);
}

.form-input:focus,
.form-select:focus {
    background-color: var(--white);
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px rgba(224, 40, 47, 0.05);
}

/* Theme overrides */
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select {
    background-color: var(--bg-input);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

[data-theme="light"] .form-input,
[data-theme="light"] .form-select {
    background-color: #ffffff;
    border-color: var(--border-strong);
}

/* Textarea */
.form-input[rows],
textarea.form-input {
    height: auto;
    min-height: 60px;
    padding: 6px 8px;
    resize: vertical;
}

/* Helper text */
.form-hint {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 2px;
}

/* Info block */
.form-help-text {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    background: var(--bg-body);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-secondary);
    margin-top: 4px;
}

[data-theme="dark"] .form-help-text {
    background: var(--bg-card-hover);
}

/* ── Inline label-input row (Azure label:value style) ──────── */
.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-row .form-label {
    min-width: 160px;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ============================================================
   Wizard Step Indicator — Azure Portal breadcrumb pill style
   ============================================================ */
.step-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 0;
    position: relative;
    overflow-x: auto;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
}

/* Individual step as a tab */
.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    min-width: 100px;
    cursor: default;
}

.step-number {
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1.5px solid var(--border-strong);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    transition: all var(--transition-mid);
}

.step-label {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-weight: 400;
    text-align: center;
    padding: 8px 0;
    white-space: nowrap;
}

.step.active .step-number {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #ffffff;
    box-shadow: none;
    transform: none;
}

.step.active .step-label {
    color: var(--color-primary);
    font-weight: 600;
}

.step.completed .step-number {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #ffffff;
}

.step.completed .step-label {
    color: var(--text-secondary);
}

.step-connector {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    /* step-number는 24px 원 → 중앙은 12px.
       step는 column 방향: number(24px) + label관련 패딩(위 12px)
       따라서 connector는 step-number 중앙에 맞오 margin-top: 12px (= 24px / 2) */
    margin-top: 12px;
    align-self: flex-start;
    min-width: 20px;
    max-width: 80px;
}

.step.active+.step-connector,
.step.completed+.step-connector {
    background: var(--color-primary);
}

@media (max-width: 768px) {
    .step-label {
        display: none;
    }

    .step-connector {
        min-width: 12px;
    }
}

/* ============================================================
   Toggle Switch — Fluent Toggle
   ============================================================ */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--gray-200);
    transition: all var(--transition-mid);
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    top: 2px;
    background-color: white;
    transition: transform var(--transition-mid);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:checked+.slider {
    background-color: var(--brand-primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 10px;
}

.slider.round:before {
    border-radius: 50%;
}

/* ── Switch label row ─────────────────────────────────────── */
.switch-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.switch-text {
    font-weight: 400;
    color: var(--text-primary);
    font-size: var(--font-size-md);
}

/* ============================================================
   Data Tables — Fluent DetailsList
   ============================================================ */
.resource-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-md);
}

.resource-table th,
.resource-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.resource-table th {
    background-color: var(--bg-body);
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    user-select: none;
    position: relative;
}

.resizer {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: transparent;
    cursor: col-resize;
    user-select: none;
    z-index: 10;
    transition: background-color 0.2s;
}

.resizer:hover {
    background-color: var(--color-primary);
    opacity: 0.5;
}

.resizer.resizing {
    background-color: var(--color-primary);
    opacity: 1;
    width: 2px;
}

th.resizing {
    border-right: 2px solid var(--color-primary) !important;
}

.resource-table tr:hover td {
    background-color: var(--bg-card-hover);
}

/* ── Badges — Fluent Tag / Badge ─────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 2px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 20px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 8px;
    border-radius: 2px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 20px;
}


.badge-info,
.status-ok {
    background: rgba(0, 120, 212, 0.12);
    color: var(--color-secondary);
}

.badge-success,
.status-ok {
    background: rgba(16, 124, 16, 0.1);
    color: var(--color-success);
}

.badge-warning,
.status-warn {
    background: rgba(216, 59, 1, 0.1);
    color: var(--color-warning);
}

.badge-error,
.status-error {
    background: rgba(164, 38, 44, 0.1);
    color: var(--color-error);
}

.badge-neutral {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ============================================================
   Notification / Toast — Fluent MessageBar
   ============================================================ */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    min-width: 280px;
    max-width: 400px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--color-primary);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    font-size: var(--font-size-md);
    animation: slideIn 0.12s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

/* ============================================================
   Selection List — Fluent Picker
   ============================================================ */
.selection-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.selection-item {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background var(--transition-fast);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    font-size: var(--font-size-md);
}

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

.selection-item:hover {
    background: var(--bg-card-hover);
    transform: none;
    border-color: var(--border-color);
}

.selection-item.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 600;
    border-color: var(--border-color);
}

/* ── Step badge (numbered circle) ─────────────────────────── */
.step-badge {
    background: var(--color-primary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-xs);
    flex-shrink: 0;
}

/* ============================================================
   Info Callout / Alert Box (Fluent MessageBar variants)
   ============================================================ */
.callout {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    border: 1px solid;
    margin-bottom: 12px;
}

.callout-info {
    background: rgba(0, 120, 212, 0.06);
    border-color: rgba(0, 120, 212, 0.25);
    color: #004d8d;
}

.callout-success {
    background: rgba(16, 124, 16, 0.06);
    border-color: rgba(16, 124, 16, 0.25);
    color: #0a5c0a;
}

.callout-warning {
    background: rgba(216, 59, 1, 0.06);
    border-color: rgba(216, 59, 1, 0.25);
    color: #8a2500;
}

.callout-error {
    background: rgba(164, 38, 44, 0.06);
    border-color: rgba(164, 38, 44, 0.25);
    color: #8a1117;
}

[data-theme="dark"] .callout-info {
    color: #70aaff;
}

[data-theme="dark"] .callout-success {
    color: #54c554;
}

[data-theme="dark"] .callout-warning {
    color: #f0a070;
}

[data-theme="dark"] .callout-error {
    color: #f87171;
}

/* ============================================================
   Spinner Ring (Fluent Spinner)
   ============================================================ */
.spinner-ring {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    flex-shrink: 0;
}

/* ============================================================
   Tooltip (minimal)
   ============================================================ */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: #1b1a19;
    color: #f3f2f1;
    font-size: var(--font-size-xs);
    padding: 4px 8px;
    border-radius: 2px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: var(--shadow-md);
}

/* ============================================================
   Pill / Tag (inline label)
   ============================================================ */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    height: 22px;
    border-radius: 2px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* ============================================================
   Issue 1 Fix: Modal Overlay (Device Code / General)
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.12s ease;
}

.modal-overlay[style*="none"] {
    display: none !important;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 28px 32px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

.modal-content h3 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-content p {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* Device code big display */
.device-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 6px;
    color: var(--color-primary);
    background: var(--color-primary-light);
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-sm);
    padding: 16px 24px;
    cursor: pointer;
    user-select: all;
    transition: background var(--transition-fast);
}

.device-code-display:hover {
    background: rgba(220, 36, 31, 0.14);
}

.device-code-display::after {
    content: ' 📋';
    font-size: 16px;
    letter-spacing: 0;
    opacity: 0.6;
}

.modal-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.modal-footer p {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    margin: 0;
}

.modal-footer .btn-group-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

/* ============================================================
   Issue 4 Fix: Step Indicator — Centered, padded
   ============================================================ */
.step-indicator {
    justify-content: center;
    /* 중앙 정렬 */
    padding: 12px 24px 0;
    /* 좌우 여백 추가 */
    overflow-x: auto;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

/* ============================================================
   Issue 3 Fix: Result page — Code preview full-width
   ============================================================ */
.result-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 16px;
    align-items: start;
}

@media (max-width: 1200px) {
    .result-layout {
        grid-template-columns: 1fr;
    }
}

.code-preview-wrapper {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
}

.code-preview-wrapper .code-preview {
    flex: 1;
    min-height: 500px;
    font-size: 13px;
    line-height: 1.65;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 75vh;
    white-space: pre;
}

.file-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0;
    overflow-x: auto;
}

.file-tab-btn {
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: rgba(255, 255, 255, 0.5);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.file-tab-btn:hover {
    color: rgba(255, 255, 255, 0.8);
}

.file-tab-btn.active {
    color: #ffffff;
    border-bottom-color: var(--color-primary);
}

/* Side panel on result page */
.result-side-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: calc(var(--topbar-height) + 16px);
}