/**
 * style.css
 *
 * Dark theme styling for the M1 Web Updater.
 *
 * @license See COPYING.txt for license details.
 */

/* ── Reset & Base ── */

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

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --success: #3fb950;
    --warning: #d29922;
    --error: #f85149;
    --radius: 8px;
    --radius-sm: 4px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Layout ── */

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
}

header {
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 4px;
}

header h1 .accent {
    color: var(--accent);
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ── Cards / Sections ── */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card h2 .icon {
    font-size: 1.2rem;
}

/* ── Buttons ── */

button {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-danger {
    background: transparent;
    color: var(--error);
    border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(248, 81, 73, 0.1);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
    background: #46c258;
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.8rem;
}

/* ── Connection Section ── */

.connection-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.status-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-connected {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.status-disconnected {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
}

/* ── Device Info ── */

.device-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
}

.device-info-grid dt {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.device-info-grid dd {
    font-weight: 500;
    font-size: 0.95rem;
}

.bank-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.bank-info div {
    margin-bottom: 4px;
}

/* ── Release List ── */

.release-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.release-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

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

.release-item:hover {
    background: var(--bg-tertiary);
}

.release-item.latest {
    border-left: 3px solid var(--success);
}

.release-item input[type="radio"] {
    accent-color: var(--accent);
    flex-shrink: 0;
}

.release-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.release-name {
    font-weight: 500;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.release-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.badge {
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-pre {
    background: rgba(210, 153, 34, 0.2);
    color: var(--warning);
}

.badge-sd {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

/* ── Local File ── */

.local-file-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.local-file-row .file-name {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ── Proxy Notice ── */

.proxy-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.proxy-notice-icon {
    flex-shrink: 0;
    line-height: 1.5;
}

.proxy-notice a {
    color: var(--accent);
    text-decoration: none;
}

.proxy-notice a:hover {
    text-decoration: underline;
}

/* ── Flash Section ── */

.flash-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.flash-option {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.flash-option > label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.flash-option input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.flash-option-note {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.flash-suboption {
    margin-left: 22px;
}

.flash-suboption label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.flash-suboption input[type="checkbox"] {
    accent-color: var(--accent);
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.flash-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Progress Bar ── */

.progress-container {
    margin-top: 16px;
}

.progress-track {
    width: 100%;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 12px;
    transition: width 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    min-width: 40px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ── Log Output ── */

.log-container {
    margin-top: 16px;
}

.log-output {
    background: #010409;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}

.log-info { color: var(--text-secondary); }
.log-warn { color: var(--warning); }
.log-error { color: var(--error); }
.log-success { color: var(--success); }

/* ── Browser Warning ── */

.browser-warning {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.browser-warning h3 {
    color: var(--error);
    margin-bottom: 4px;
}

.browser-warning p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ── Utilities ── */

.hidden {
    display: none !important;
}

.loading, .empty, .error {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

/* ── Footer ── */

footer {
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

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

/* ── Mobile Tips ── */

.mobile-tips {
    margin-top: 14px;
    padding: 14px 16px;
    background: rgba(88, 166, 255, 0.08);
    border: 1px solid rgba(88, 166, 255, 0.25);
    border-radius: var(--radius-sm);
}

.mobile-tips h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.mobile-tips ol {
    padding-left: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.mobile-tips ol li {
    margin-bottom: 4px;
}

.usb-permission-status {
    font-size: 0.8rem;
    margin-left: 8px;
}

/* ── Responsive ── */

@media (max-width: 600px) {
    .container {
        padding: 16px 12px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .device-info-grid {
        grid-template-columns: 1fr;
    }

    .connection-row {
        flex-direction: column;
        align-items: flex-start;
    }
}
