/* =============================================
   Arduino Web Flasher - Stylesheet
   Dark theme with cyan/blue accents
   ============================================= */

/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2234;
    --bg-card-hover: #1e2840;
    --bg-input: #0f1623;
    --border-color: #2a3654;
    --border-active: #00b4d8;
    --text-primary: #e0e6ed;
    --text-secondary: #8892a4;
    --text-muted: #5a6478;
    --accent: #00b4d8;
    --accent-glow: rgba(0, 180, 216, 0.3);
    --success: #00e88f;
    --success-glow: rgba(0, 232, 143, 0.3);
    --warning: #ffb347;
    --error: #ff4466;
    --error-glow: rgba(255, 68, 102, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Background effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(0, 180, 216, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(0, 232, 143, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

/* === Browser Warning === */
.browser-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.warning-content {
    text-align: center;
    max-width: 500px;
}

.warning-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.warning-content h2 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--warning);
}

.warning-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.browser-list {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.browser-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.browser-item:hover {
    border-color: var(--accent);
    background: var(--bg-card-hover);
}

.browser-icon {
    font-size: 32px;
}

/* === Header === */
.header {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    background: rgba(10, 14, 23, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    color: var(--accent);
    display: flex;
    align-items: center;
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(0, 180, 216, 0.1);
    border: 1px solid rgba(0, 180, 216, 0.2);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
}

.badge-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

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

/* === Main === */
.main {
    flex: 1;
    padding: 40px 0;
}

/* === Stepper === */
.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 40px;
    gap: 0;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
}

.step.active .step-number {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
    box-shadow: 0 0 20px var(--accent-glow);
}

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

.step.completed .step-number::after {
    content: '✓';
    font-size: 16px;
}

.step.completed .step-number {
    font-size: 0;
}

.step-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    transition: var(--transition);
}

.step.active .step-label,
.step.completed .step-label {
    color: var(--text-primary);
}

.step-line {
    width: 60px;
    height: 2px;
    background: var(--border-color);
    margin: 0 8px;
    margin-bottom: 24px;
    transition: var(--transition);
}

.step-line.active {
    background: var(--accent);
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.card-header {
    padding: 28px 28px 16px;
}

.card-header h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.card-body {
    padding: 0 28px 28px;
}

.card-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: var(--radius);
    width: 100%;
    justify-content: center;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-primary {
    background: var(--accent);
    color: #000;
    font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
    background: #00c8ef;
    box-shadow: 0 0 24px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: #000;
    font-weight: 600;
}

.btn-success:hover:not(:disabled) {
    background: #00ffa0;
    box-shadow: 0 0 24px var(--success-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.btn-accent {
    background: rgba(0, 180, 216, 0.15);
    color: var(--accent);
    border: 1px solid rgba(0, 180, 216, 0.3);
}

.btn-accent:hover:not(:disabled) {
    background: rgba(0, 180, 216, 0.25);
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.select-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892a4' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.select-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* === Status Box === */
.status-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-top: 16px;
    margin-bottom: 16px;
}

.status-icon {
    font-size: 20px;
    color: var(--text-muted);
}

.status-icon.connected {
    color: var(--success);
    animation: pulse 2s ease-in-out infinite;
}

.status-icon.error {
    color: var(--error);
}

.status-info {
    display: flex;
    flex-direction: column;
}

.status-label {
    font-size: 14px;
    font-weight: 500;
}

.status-detail {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* === Help Text === */
.help-text {
    padding: 16px;
    background: rgba(0, 180, 216, 0.05);
    border: 1px solid rgba(0, 180, 216, 0.1);
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

.help-text p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.help-text ul {
    list-style: none;
    padding: 0;
}

.help-text li {
    font-size: 12px;
    color: var(--text-muted);
    padding: 3px 0;
    padding-left: 16px;
    position: relative;
}

.help-text li::before {
    content: '›';
    position: absolute;
    left: 4px;
    color: var(--accent);
}

/* === Step Content === */
.step-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.step-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === Firmware Grid === */
.firmware-grid {
    display: grid;
    gap: 16px;
}

.firmware-card {
    padding: 20px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.firmware-card:hover {
    border-color: var(--text-muted);
    background: rgba(15, 22, 35, 0.8);
}

.firmware-card.selected {
    border-color: var(--accent);
    background: rgba(0, 180, 216, 0.05);
    box-shadow: 0 0 20px var(--accent-glow);
}

.firmware-card.selected::after {
    content: '✓';
    position: absolute;
    top: 12px;
    right: 16px;
    width: 24px;
    height: 24px;
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.firmware-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
}

.firmware-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.firmware-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.firmware-tag {
    font-size: 11px;
    padding: 3px 10px;
    background: rgba(0, 180, 216, 0.1);
    border: 1px solid rgba(0, 180, 216, 0.15);
    border-radius: 12px;
    color: var(--accent);
    font-weight: 500;
}

.firmware-tag.board-tag {
    background: rgba(0, 232, 143, 0.1);
    border-color: rgba(0, 232, 143, 0.15);
    color: var(--success);
}

/* === Loading Spinner === */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Flash Summary === */
.flash-summary {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 24px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.summary-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.summary-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.summary-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* === Progress === */
.flash-progress {
    margin-bottom: 24px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
}

#progress-status {
    color: var(--text-secondary);
}

#progress-percent {
    color: var(--accent);
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 4px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
    animation: shimmer 1.5s ease-in-out infinite;
}

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

.progress-detail {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    font-family: 'JetBrains Mono', monospace;
}

/* === Flash Result === */
.flash-result {
    text-align: center;
    padding: 32px;
    margin-bottom: 20px;
}

.result-icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.result-text {
    font-size: 18px;
    font-weight: 600;
}

.flash-result.success .result-text {
    color: var(--success);
}

.flash-result.error .result-text {
    color: var(--error);
}

/* === Console === */
.console-card {
    background: #0d1117;
    border-color: #21262d;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px !important;
}

.console-header h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.console-output {
    padding: 16px 20px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.8;
}

.console-output::-webkit-scrollbar {
    width: 6px;
}

.console-output::-webkit-scrollbar-track {
    background: transparent;
}

.console-output::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.console-line {
    display: flex;
    gap: 10px;
    padding: 2px 0;
}

.console-time {
    color: var(--text-muted);
    flex-shrink: 0;
}

.console-line.info span:last-child {
    color: var(--text-secondary);
}

.console-line.success span:last-child {
    color: var(--success);
}

.console-line.error span:last-child {
    color: var(--error);
}

.console-line.warning span:last-child {
    color: var(--warning);
}

.console-line.data span:last-child {
    color: var(--accent);
}

/* === Footer === */
.footer {
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    background: rgba(10, 14, 23, 0.6);
}

.footer p {
    font-size: 13px;
    color: var(--text-muted);
}

.footer-note {
    font-size: 11px !important;
    margin-top: 4px;
}

/* === Responsive === */
@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }

    .header-content {
        flex-direction: column;
        gap: 12px;
    }

    .header-badge {
        display: none;
    }

    .logo-text h1 {
        font-size: 17px;
    }

    .stepper {
        margin-bottom: 28px;
    }

    .step-label {
        font-size: 10px;
    }

    .step-line {
        width: 30px;
    }

    .card-header {
        padding: 20px 20px 12px;
    }

    .card-body {
        padding: 0 20px 20px;
    }

    .card-footer {
        padding: 14px 20px;
        flex-direction: column;
        gap: 10px;
    }

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

    .firmware-meta {
        gap: 8px;
    }

    .flash-summary {
        padding: 14px;
    }
}
