/* ============================================
   PUREMAGNETIK UPDATER - TECHNICAL FLAT DESIGN
   ============================================ */

/* === ROOT VARIABLES === */
:root {
    /* Monochromatic palette */
    --bg-primary: #0a0a0a;
    --bg-secondary: #121212;
    --surface: #ffffff;
    --surface-dark: #1a1a1a;
    --surface-elevated: #f8f8f8;

    /* Accent - single technical teal */
    --accent: #13808f;
    --accent-hover: #0f6b78;
    --accent-light: #ffffff;

    /* Text colors */
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --text-inverse: #ffffff;

    /* Status colors */
    --success: #00aa00;
    --warning: #ff9900;
    --error: #dd0000;

    /* Borders */
    --border: #e0e0e0;
    --border-dark: #333333;

    /* Spacing */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;
}

/* === GLOBAL STYLES === */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-weight: 400;
}

/* === MAIN CONTAINER === */
.app_body {
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 40px 20px;
    color: var(--text-inverse);
}

/* === CARD LAYOUT === */
.app_column {
    background: var(--surface);
    color: var(--text-primary);
    padding: 48px;
    border-radius: var(--radius-lg);
    margin: 24px auto;
    max-width: 900px;
    border: 1px solid var(--border);
}

/* === TYPOGRAPHY === */
legend {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 32px;
    text-align: center;
    letter-spacing: -0.02em;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

p {
    color: var(--text-primary);
    line-height: 1.6;
    margin-bottom: 12px;
}

a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* === BUTTONS === */
.btn-es,
#connect,
#blink,
#bootloader,
#download {
    background: var(--accent);
    color: var(--text-inverse);
    border: none;
    padding: 12px 32px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
}

.btn-es:hover,
#connect:hover,
#blink:not(:disabled):hover,
#bootloader:not(:disabled):hover,
#download:not(:disabled):hover {
    background: var(--accent-hover);
}

.btn-es:active,
#connect:active,
#blink:not(:disabled):active,
#bootloader:not(:disabled):active,
#download:not(:disabled):active {
    background: #003d99;
}

.btn-es:disabled,
#blink:disabled,
#bootloader:disabled,
#download:disabled {
    background: #cccccc;
    cursor: not-allowed;
    opacity: 0.5;
}

/* === CHANGELOG BOX === */
.changelog-box {
    background: #f0f9ff;
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    padding: 24px;
    margin: 24px 0;
}

.changelog-box h3 {
    color: var(--accent);
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
}

.changelog-box ul {
    color: var(--text-primary);
    margin-left: 20px;
    margin-bottom: 12px;
}

.changelog-box small {
    display: block;
    margin-top: 8px;
}

/* === WARNING BOX === */
.warning-box {
    background: #fffbf0;
    border: 2px solid var(--warning);
    border-radius: var(--radius-md);
    padding: 24px;
    margin: 24px 0;
}

.warning-box h3 {
    color: #cc7a00;
    margin-top: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
}

.warning-box ul {
    color: var(--text-primary);
    margin-left: 20px;
}

.warning-box strong {
    color: #cc7a00;
    font-weight: 600;
}

/* === LISTS === */
.nested_list {
    text-align: left;
    margin: 20px 0;
}

.nested_list ol {
    counter-reset: item;
    list-style: none;
    padding-left: 0;
}

.nested_list ol > li {
    counter-increment: item;
    margin-bottom: 20px;
    padding-left: 40px;
    position: relative;
}

.nested_list ol > li::before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 2px;
    background: var(--text-primary);
    color: var(--text-inverse);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.nested_list ul {
    margin-left: 20px;
    padding-left: 20px;
}

.nested_list li p {
    margin: 8px 0;
}

/* === IMAGES === */
.nested_list img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 16px 0;
    border: 1px solid var(--border);
}

/* === STATUS DISPLAY === */
#status {
    display: inline-block;
    padding: 10px 20px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    color: var(--text-primary);
    margin: 16px 0;
    min-height: 42px;
    line-height: 20px;
    font-size: 0.9rem;
}

#status:empty {
    display: none;
}

/* === PROGRESS BAR === */
progress {
    width: 100%;
    height: 24px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-elevated);
    margin: 20px 0;
}

progress::-webkit-progress-bar {
    background: var(--surface-elevated);
}

progress::-webkit-progress-value {
    background: var(--accent);
}

progress::-moz-progress-bar {
    background: var(--accent);
}

/* === LOG DISPLAY === */
.log,
#downloadLog {
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 20px 0;
    min-height: 100px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
    max-height: 400px;
    overflow-y: auto;
    line-height: 1.5;
}

.log:empty,
#downloadLog:empty {
    display: none;
}

.info {
    text-align: left;
    color: var(--accent);
    padding: 6px 0;
    font-weight: 500;
}

.warning {
    text-align: left;
    color: var(--warning);
    padding: 6px 0;
    font-weight: 500;
}

.error {
    text-align: left;
    color: var(--error);
    padding: 6px 0;
    font-weight: 600;
}

/* === TABLES === */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 20px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

table, th, td {
    border: 1px solid var(--border);
}

th {
    background: var(--surface-dark);
    color: var(--text-inverse);
    padding: 12px;
    font-weight: 600;
    text-align: left;
}

td {
    padding: 12px;
    background: var(--surface);
}

/* === CODE BLOCKS === */
code.language-cpp {
    color: var(--text-primary);
    background: var(--surface-elevated);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.9em;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
}

#readme {
    text-align: left;
    padding: 20px 0;
}

/* === FORM ELEMENTS === */
.form-control,
.custom-file-label {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 10px 14px;
    font-size: 0.95rem;
    background: var(--surface);
}

.form-control:focus,
.custom-file-label:focus {
    border-color: var(--accent);
    outline: none;
}

/* === PRODUCT SELECTOR === */
.product-selector-section {
    margin: 40px 0;
    padding: 20px 0;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin: 0 auto;
    max-width: 700px;
}

.product-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
}

.product-card:hover {
    border-color: var(--accent);
}

.product-card-selected {
    border-color: var(--accent);
    border-width: 3px;
    background: var(--surface);
}

.product-card-selected::after {
    content: "SELECTED";
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--accent);
    color: var(--text-inverse);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.product-image-container {
    width: 100%;
    max-width: 220px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    overflow: hidden;
    border-radius: var(--radius-md);
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.product-info {
    width: 100%;
}

.product-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 12px 0 8px 0;
    letter-spacing: -0.02em;
}

.product-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 8px 0;
    font-weight: 400;
}

.product-version {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 12px 0 0 0;
    padding: 6px 14px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: inline-block;
}

.product-card-selected .product-version {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .app_body {
        padding: 20px 10px;
    }

    .app_column {
        padding: 24px;
        margin: 12px;
    }

    legend {
        font-size: 1.5rem;
    }

    .btn-es,
    #connect,
    #blink,
    #bootloader,
    #download {
        padding: 12px 24px;
        font-size: 0.9rem;
        width: 100%;
        margin: 8px 0;
    }

    .nested_list ol > li {
        padding-left: 36px;
    }

    .nested_list ol > li::before {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
    }

    .product-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 0 10px;
    }

    .product-card {
        padding: 20px;
    }

    .product-name {
        font-size: 1.25rem;
    }

    .product-image-container {
        max-width: 180px;
        height: 150px;
    }
}

/* === UTILITY CLASSES === */
.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-4 {
    margin-bottom: 2rem;
}
