:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #22c55e;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: #334155;
    --warning-bg: #422006;
    --warning-border: #f59e0b;
    --success-bg: #052e16;
    --success-border: #22c55e;
}

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

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

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo img {
    width: 100px;
}

.logo h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Info Section */
.info-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.info-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

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

/* Releases Section */
.releases-section {
    margin-bottom: 2rem;
}

.releases-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.browser-warning {
    display: none;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.browser-warning p {
    color: var(--warning-border);
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 3rem;
}

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

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

.releases-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.release-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.release-card:hover {
    border-color: var(--primary-color);
}

.release-card.latest {
    border-color: var(--secondary-color);
    position: relative;
}

.release-card.latest::before {
    content: 'Остання версія';
    position: absolute;
    top: -10px;
    left: 1rem;
    background: var(--secondary-color);
    color: var(--background);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
}

.release-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.release-info h3 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.release-info h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

.release-info h3 a:hover {
    color: var(--primary-color);
}

.release-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.release-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.release-body {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    max-height: 100px;
    overflow: hidden;
    position: relative;
}

.release-body.expanded {
    max-height: none;
}

.release-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, var(--surface));
}

.release-body.expanded::after {
    display: none;
}

.release-assets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.asset-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--surface-hover);
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.asset-link:hover {
    background: var(--primary-color);
    color: var(--text-primary);
}

/* ESP Web Tools Button Styling */
esp-web-install-button {
    --esp-tools-button-color: var(--primary-color);
}

esp-web-install-button button,
.install-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

esp-web-install-button button:hover,
.install-btn:hover {
    background: var(--primary-hover);
}

.install-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
}

/* Instructions Section */
.instructions-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.instructions-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.instructions-section ol {
    margin-left: 1.5rem;
    color: var(--text-secondary);
}

.instructions-section li {
    margin-bottom: 0.5rem;
}

.note {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface-hover);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.note strong {
    color: var(--text-primary);
}

/* Footer */
footer {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

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

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

.copyright {
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Error state */
.error-message {
    background: #450a0a;
    border: 1px solid #dc2626;
    border-radius: 8px;
    padding: 1rem;
    color: #fca5a5;
    text-align: center;
}

.error-message a {
    color: #f87171;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .release-header {
        flex-direction: column;
    }
    
    .release-actions {
        width: 100%;
    }
    
    .install-btn {
        width: 100%;
    }
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.25rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-body p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.modal-body p strong {
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

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

.btn-primary:disabled {
    background: var(--border);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border);
}

/* Progress */
.flash-progress {
    margin: 1.5rem 0;
}

.progress-bar {
    height: 8px;
    background: var(--surface-hover);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin: 0 !important;
}

.progress-text.success {
    color: var(--secondary-color);
}

.progress-text.error {
    color: #f87171;
}

/* Flash Log */
.flash-log {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.flash-log.active {
    display: block;
}

.flash-log p {
    margin: 0.25rem 0 !important;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.flash-log p.log-info {
    color: var(--primary-color);
}

.flash-log p.log-success {
    color: var(--secondary-color);
}

.flash-log p.log-error {
    color: #f87171;
}

.flash-log p.log-warning {
    color: var(--warning-border);
}

/* File Select Section */
.file-select-section {
    margin: 1.5rem 0;
}

.step-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.step-label:first-child {
    margin-top: 0;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--secondary-color);
    color: var(--background);
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    flex-direction: column;
    min-width: 140px;
}

.btn-download:hover {
    background: #16a34a;
    color: var(--background);
}

.btn-download .file-size {
    font-size: 0.75rem;
    opacity: 0.8;
}

.btn-download.recommended {
    border: 2px solid var(--primary-color);
    position: relative;
}

.firmware-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.file-input-label {
    display: block;
    cursor: pointer;
}

.file-input-label input[type="file"] {
    display: none;
}

.file-input-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--surface-hover);
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.file-input-text:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.file-input-text.selected {
    border-color: var(--secondary-color);
    border-style: solid;
    color: var(--secondary-color);
}
