/* ========================================
   MiniZ Flash Pro - Secure ESP Flasher
   Modern Dark Theme with Cloudflare Security
   ======================================== */

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --success-color: #10b981;
    --success-hover: #059669;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #e2e8f0;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --input-bg: #0f172a;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.4);
    --cloudflare-orange: #f6821f;
    --gradient-primary: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

/* ========== Security Overlay ========== */
.security-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #0f172a 0%, #1a1a2e 50%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.5s ease;
}

.security-modal {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.security-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--cloudflare-orange), #3b82f6, var(--cloudflare-orange));
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

.security-header {
    margin-bottom: 30px;
}

.shield-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

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

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.security-header h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #f6821f, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.security-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.turnstile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    margin: 25px 0;
}

.turnstile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: var(--text-muted);
}

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

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

.security-status {
    padding: 12px 20px;
    border-radius: 10px;
    margin: 15px 0;
    font-weight: 500;
    transition: all 0.3s ease;
}

.security-status.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success-color);
    color: #6ee7b7;
}

.security-status.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger-color);
    color: #fca5a5;
}

.security-status.warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning-color);
    color: #fbbf24;
}

.btn-bypass {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 24px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-bypass:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

.security-info {
    margin-top: 25px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.security-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 8px 0;
}

/* ========== Security Badge ========== */
.security-badge {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: #6ee7b7;
    animation: fadeIn 1s ease;
}

.badge-icon {
    animation: pulse 2s infinite;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* ========== Header ========== */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 40px 20px;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    position: relative;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899, #3b82f6);
    background-size: 300% 100%;
    animation: gradient-move 3s ease infinite;
}

@keyframes gradient-move {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

/* ========== Warning Box ========== */
.warning-box {
    background: rgba(245, 158, 11, 0.1);
    border: 2px solid var(--warning-color);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 25px;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ========== Cards ========== */
.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card h2 {
    margin-bottom: 20px;
    font-size: 1.4rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    padding: 14px 24px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}

.btn-secondary:hover:not(:disabled) {
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.btn-success {
    background: var(--gradient-success);
    width: 100%;
    font-size: 1.2rem;
    padding: 18px 32px;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

.btn-icon {
    font-size: 1.3em;
}

/* ========== Connection Section ========== */
.connect-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.status-badge {
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.status-badge.connected {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 2px solid var(--success-color);
    animation: pulse-success 2s infinite;
}

@keyframes pulse-success {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}

.status-badge.disconnected {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 2px solid var(--danger-color);
}

.device-info {
    margin-top: 20px;
    padding: 16px;
    background: var(--input-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
}

/* ========== Firmware Tabs ========== */
.firmware-mode-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 25px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 4px;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 10px;
}

.tab-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: white;
    background: var(--primary-color);
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.firmware-tab {
    display: none;
    animation: fadeIn 0.3s ease;
}

.firmware-tab.active {
    display: block;
}

.tab-description {
    margin-bottom: 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ========== Firmware Grid ========== */
.firmware-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.firmware-card {
    padding: 20px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));
    border: 2px solid rgba(59, 130, 246, 0.2);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.firmware-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.firmware-card:hover::before {
    left: 100%;
}

.firmware-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px rgba(59, 130, 246, 0.3);
}

.firmware-card.selected {
    border-color: var(--success-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(59, 130, 246, 0.15));
    box-shadow: 0 0 25px rgba(16, 185, 129, 0.3);
}

.firmware-card.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: var(--success-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
}

.firmware-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.firmware-card h3 {
    margin: 8px 0;
    color: var(--text-color);
    font-size: 1.1rem;
}

.firmware-card p {
    margin: 5px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.firmware-size {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.license-badge {
    display: block;
    margin-top: 10px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.free-firmware {
    border-color: rgba(16, 185, 129, 0.3);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(59, 130, 246, 0.08));
}

.free-badge {
    display: block;
    margin-top: 10px;
    padding: 6px 12px;
    background: var(--gradient-success);
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

/* ========== License Section ========== */
.license-section {
    margin-top: 25px;
    padding: 25px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));
    border: 2px solid var(--primary-color);
    border-radius: 16px;
    animation: slideDown 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.license-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #3b82f6);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-15px); }
    to { opacity: 1; transform: translateY(0); }
}

.license-input-box h3 {
    margin-bottom: 10px;
    color: #93c5fd;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.license-desc {
    margin-bottom: 18px;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.license-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.license-input {
    flex: 1;
    min-width: 200px;
    padding: 14px 18px;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 1rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: all 0.3s ease;
}

.license-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.license-input::placeholder {
    color: rgba(148, 163, 184, 0.4);
    text-transform: uppercase;
}

.license-status {
    padding: 14px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    animation: slideDown 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 10px;
}

.license-status.success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success-color);
    color: #6ee7b7;
}

.license-status.error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger-color);
    color: #fca5a5;
}

.license-status.info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--primary-color);
    color: #93c5fd;
}

/* ========== Hash Verification ========== */
.hash-verification {
    margin-top: 20px;
    padding: 20px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.hash-verification h4 {
    margin-bottom: 15px;
    color: var(--text-color);
    font-size: 1rem;
}

.hash-info {
    font-family: 'Monaco', 'Menlo', monospace;
}

.hash-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.hash-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    min-width: 80px;
}

.hash-value {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #93c5fd;
    word-break: break-all;
    flex: 1;
}

.hash-status {
    font-size: 0.85rem;
}

.hash-status.valid {
    color: var(--success-color);
}

.hash-status.invalid {
    color: var(--danger-color);
}

/* ========== File Upload ========== */
.file-select-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.file-input {
    display: none;
}

.file-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 30px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 2px dashed rgba(139, 92, 246, 0.5);
    color: var(--text-color);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.file-label:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3), rgba(139, 92, 246, 0.3));
    border-color: #8b5cf6;
    transform: translateY(-2px);
}

.file-info {
    padding: 15px;
    background: var(--input-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
}

/* ========== Options Grid ========== */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-group label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-field,
.select-field {
    padding: 12px 14px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.input-field:focus,
.select-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.checkbox-group {
    display: flex;
    align-items: center;
    padding: 14px;
    background: var(--input-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* ========== Progress Section ========== */
.progress-section {
    margin: 25px 0;
}

.progress-bar-container {
    width: 100%;
    height: 30px;
    background: var(--input-bg);
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #34d399 50%, #10b981 100%);
    background-size: 200% 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 15px;
    animation: progress-shine 2s ease infinite;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

@keyframes progress-shine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

#progressText {
    font-weight: 700;
    color: var(--success-color);
    font-size: 1.1rem;
}

/* ========== Console ========== */
.console {
    margin-top: 25px;
    background: var(--input-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.console-header {
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.console-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.session-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Monaco', 'Menlo', monospace;
}

.clear-console-btn {
    padding: 5px 12px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #f87171;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-console-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.console-output {
    padding: 18px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.85rem;
    max-height: 300px;
    overflow-y: auto;
    line-height: 1.7;
}

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

.console-output::-webkit-scrollbar-track {
    background: var(--input-bg);
}

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

.log-line {
    margin-bottom: 4px;
    color: var(--text-muted);
}

.log-line.success { color: #4ade80; }
.log-line.error { color: #f87171; }
.log-line.warning { color: #fbbf24; }
.log-line.info { color: #60a5fa; }

/* ========== Footer ========== */
footer {
    text-align: center;
    margin-top: 40px;
    padding: 25px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer p {
    margin: 5px 0;
}

.footer-security {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.footer-security span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .card {
        padding: 20px;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .connect-section {
        flex-direction: column;
        align-items: stretch;
    }

    .btn {
        width: 100%;
    }

    .license-input-group {
        flex-direction: column;
    }

    .firmware-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    header {
        padding: 25px 15px;
    }

    h1 {
        font-size: 1.6rem;
    }

    .firmware-grid {
        grid-template-columns: 1fr;
    }
    
    .security-badge {
        position: static;
        justify-content: center;
        margin-bottom: 15px;
    }
    
    .footer-security {
        flex-direction: column;
        gap: 10px;
    }
    
    .security-modal {
        padding: 25px;
    }
}
