* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: Vazir, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, #2563eb 0%, transparent 30%),
        linear-gradient(135deg, #0f172a, #111827);
    color: #e5e7eb;
}

.page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 20px;
}

/* Header */
.header {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-bottom: 28px;
    padding: 24px;
    border-radius: 24px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
}

.header > div {
    text-align: center;
}

.header h1 {
    margin: 0;
    color: white;
    font-size: 34px;
}

.header p {
    margin-top: 8px;
    margin-bottom: 0;
    color: #94a3b8;
}

/* Layout */
.grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
}

.panel {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

/* Controls */
.controls {
    padding: 24px;
}

.controls h2 {
    margin-top: 0;
    margin-bottom: 20px;
    color: white;
}

label {
    display: block;
    margin-top: 18px;
    margin-bottom: 8px;
    color: #cbd5e1;
    font-weight: bold;
}

select {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid #334155;
    background: #020617;
    color: white;
    font-size: 14px;
}

select:focus {
    outline: none;
    border-color: #3b82f6;
}

button {
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    font-size: 15px;
    font-weight: bold;
}

.run-btn {
    margin-top: 24px;
    background: linear-gradient(135deg, #2563eb, #06b6d4);
    color: white;
}

.run-btn:hover {
    opacity: 0.95;
}

.stop-btn {
    margin-top: 10px;
    background: #1f2937;
    color: #e5e7eb;
    border: 1px solid #334155;
}

.status-card {
    margin-top: 20px;
    padding: 16px;
    border-radius: 14px;
    background: rgba(2, 6, 23, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-card strong {
    color: #22c55e;
}

/* Method radio buttons */
.method-radio-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
}

.method-option {
    position: relative;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: space-between;
    direction: ltr;
    padding: 14px 16px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 14px;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.85);
    color: #cbd5e1;
    font-weight: 600;
    transition: all 0.2s ease;
}

.method-option:hover {
    border-color: rgba(96, 165, 250, 0.9);
    background: rgba(30, 41, 59, 0.95);
    transform: translateY(-1px);
}

.method-option input {
    appearance: none;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border: 2px solid #64748b;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.method-option input:checked {
    border-color: #60a5fa;
    background: radial-gradient(circle, #60a5fa 0 40%, transparent 45%);
}

.method-option:has(input:checked) {
    border-color: #60a5fa;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.28), rgba(15, 23, 42, 0.95));
    color: #ffffff;
    box-shadow:
        0 0 0 1px rgba(96, 165, 250, 0.35),
        0 10px 24px rgba(37, 99, 235, 0.18);
}

.method-option span {
    flex: 1;
    text-align: left;
    font-size: 14px;
    letter-spacing: 0.2px;
}

/* Output panel */
.output-panel {
    padding: 24px;
}

.result-header {
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}

.result-header > div:first-child {
    direction: ltr;
    text-align: left;
    min-width: 0;
}

#sectionTitle {
    margin: 0 0 8px;
    color: #38bdf8;
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#title {
    margin: 0 0 8px;
    color: white;
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
}

#meta {
    margin: 0;
    color: #94a3b8;
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
}

.log-counter {
    width: 90px;
    height: 90px;
    border-radius: 18px;
    background: #020617;
    border: 1px solid #334155;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.log-counter span {
    font-size: 30px;
    font-weight: bold;
    color: #38bdf8;
}

.log-counter small {
    color: #94a3b8;
}

/* Problem box */
.problem-box {
    margin-bottom: 20px;
    padding: 20px;
    border-radius: 18px;
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.22);
    direction: rtl;
    text-align: right;
}

.problem-box h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #7dd3fc;
}

.problem-box p {
    margin: 0;
    color: #dbeafe;
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
    line-height: 2;
    white-space: pre-line;
}

/* Terminal */
.terminal {
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid #334155;
}

.terminal-top {
    height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    background: #111827;
    color: #94a3b8;
    direction: ltr;
}

.dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}

.dot:nth-child(1) {
    background: #ef4444;
}

.dot:nth-child(2) {
    background: #f59e0b;
}

.dot:nth-child(3) {
    background: #22c55e;
}

pre {
    margin: 0;
    height: 420px;
    padding: 18px;
    overflow-y: auto;
    background: #020617;
    color: #d1fae5;
    direction: ltr;
    text-align: left;
    white-space: pre-wrap;
    line-height: 1.8;
    font-size: 14px;
}

/* Explanation */
.explanation {
    margin-top: 20px;
    padding: 20px;
    border-radius: 18px;
    background: rgba(2, 6, 23, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    direction: rtl;
    text-align: right;
}

.explanation h3 {
    margin-top: 0;
    color: white;
}

.explanation p {
    margin-bottom: 0;
    color: #cbd5e1;
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
    line-height: 2;
    white-space: pre-line;
}

/* Log keyword colors */
.log-keyword-start {
    color: #4ade80;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 6px;
    background: rgba(34, 197, 94, 0.12);
}

.log-keyword-complete {
    color: #fb7185;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 6px;
    background: rgba(244, 63, 94, 0.14);
}

.log-keyword-error {
    color: #f97316;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 6px;
    background: rgba(249, 115, 22, 0.14);
}

/* Responsive */
@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .header {
        position: static;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .header > div {
        text-align: center;
    }
}