/* ============================================================
   MasterDnsVPN Config Maker — Persian RTL Stylesheet
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a14;
    --bg-card: rgba(17, 17, 30, 0.85);
    --bg-card-hover: rgba(25, 25, 45, 0.95);
    --bg-input: rgba(30, 30, 55, 0.7);
    --bg-input-focus: rgba(40, 40, 70, 0.9);
    --border-subtle: rgba(99, 102, 241, 0.15);
    --border-active: rgba(99, 102, 241, 0.5);
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --accent-2: #a78bfa;
    --accent-3: #c084fc;
    --green: #34d399;
    --green-glow: rgba(52, 211, 153, 0.25);
    --yellow: #fbbf24;
    --yellow-glow: rgba(251, 191, 36, 0.2);
    --red: #f87171;
    --red-glow: rgba(248, 113, 113, 0.2);
    --cyan: #22d3ee;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --text-muted: #64748b;
    --text-bright: #f1f5f9;
    --radius: 14px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 60px rgba(0, 0, 0, 0.6);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Vazirmatn', system-ui, -apple-system, sans-serif;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    line-height: 1.7;
    overflow-x: hidden;
}

/* --- Animated Background --- */
.bg-animation {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    animation: orbFloat 20s infinite ease-in-out;
}

.bg-orb-1 {
    width: 600px;
    height: 600px;
    background: var(--accent);
    top: -200px;
    right: -100px;
    animation-duration: 25s;
}

.bg-orb-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-3);
    bottom: -150px;
    left: -100px;
    animation-duration: 30s;
    animation-delay: -5s;
}

.bg-orb-3 {
    width: 400px;
    height: 400px;
    background: var(--cyan);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-duration: 22s;
    animation-delay: -10s;
    opacity: 0.08;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.05); }
    50% { transform: translate(-20px, 30px) scale(0.95); }
    75% { transform: translate(40px, 20px) scale(1.03); }
}

/* --- Header --- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 20, 0.8);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.logo-text h1 {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-github, .btn-telegram {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-github {
    color: var(--text-dim);
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.08);
}

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

.btn-telegram {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.08);
    border-color: rgba(56, 189, 248, 0.15);
}

.btn-telegram:hover {
    background: rgba(56, 189, 248, 0.15);
}

.btn-github-cm {
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
}

.btn-github-cm:hover {
    background: rgba(99, 102, 241, 0.16);
    border-color: var(--accent);
    color: white;
}

/* Version badge next to logo */
.ver-badge {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--green);
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.25);
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

/* Version compatibility banner */
.ver-banner {
    position: relative;
    z-index: 89;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 24px;
    background: rgba(52, 211, 153, 0.05);
    border-bottom: 1px solid rgba(52, 211, 153, 0.12);
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.ver-banner strong {
    color: var(--green);
    font-weight: 600;
    direction: ltr;
    display: inline-block;
}

.ver-banner a {
    color: var(--accent-light);
    text-decoration: none;
    transition: var(--transition);
}

.ver-banner a:hover { color: white; text-decoration: underline; }

.ver-banner-dot {
    width: 7px;
    height: 7px;
    background: var(--green);
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px var(--green);
    animation: pulse 2s infinite;
}

.ver-sep { color: var(--text-muted); opacity: 0.5; }

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
    50% { opacity: 0.6; box-shadow: 0 0 4px var(--green); }
}

/* --- Tab Switcher --- */
.tab-container {
    position: sticky;
    top: 73px;
    z-index: 90;
    background: rgba(10, 10, 20, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
}

.tab-switcher {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    gap: 8px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 50px;
    background: rgba(255,255,255,0.04);
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.2);
    color: var(--text);
}

.tab-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(167, 139, 250, 0.1));
    border-color: rgba(99, 102, 241, 0.35);
    color: var(--accent-light);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.1);
}

/* --- Main Content --- */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px 120px;
}

.config-panel {
    display: none;
}

.config-panel.active {
    display: block;
    animation: fadeSlideIn 0.4s ease;
}

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

/* --- Section Card --- */
.config-section {
    margin-bottom: 20px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    transition: var(--transition);
    backdrop-filter: blur(12px);
}

.config-section:hover {
    border-color: var(--border-active);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.06);
}

.section-header {
    padding: 18px 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.section-header:hover {
    background: rgba(99, 102, 241, 0.04);
}

.section-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.section-icon.icon-security { background: rgba(99, 102, 241, 0.12); }
.section-icon.icon-proxy { background: rgba(52, 211, 153, 0.12); }
.section-icon.icon-dns { background: rgba(251, 191, 36, 0.12); }
.section-icon.icon-resolver { background: rgba(34, 211, 238, 0.12); }
.section-icon.icon-compression { background: rgba(248, 113, 113, 0.12); }
.section-icon.icon-mtu { background: rgba(167, 139, 250, 0.12); }
.section-icon.icon-workers { background: rgba(251, 146, 60, 0.12); }
.section-icon.icon-ping { background: rgba(45, 212, 191, 0.12); }
.section-icon.icon-arq { background: rgba(192, 132, 252, 0.12); }
.section-icon.icon-logging { background: rgba(148, 163, 184, 0.12); }
.section-icon.icon-udp { background: rgba(56, 189, 248, 0.12); }
.section-icon.icon-session { background: rgba(244, 114, 182, 0.12); }
.section-icon.icon-forward { background: rgba(74, 222, 128, 0.12); }
.section-icon.icon-policy { background: rgba(129, 140, 248, 0.12); }
.section-icon.icon-deferred { background: rgba(253, 186, 116, 0.12); }

.section-info {
    flex: 1;
    min-width: 0;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 2px;
}

.section-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.section-chevron {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.config-section.open .section-chevron {
    transform: rotate(180deg);
    background: rgba(99, 102, 241, 0.12);
}

.section-chevron svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.config-section.open .section-body {
    max-height: 5000px;
}

.section-body-inner {
    padding: 4px 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* --- Field Row --- */
.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.field {
    background: var(--bg-input);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    transition: var(--transition);
    position: relative;
}

.field:hover {
    border-color: rgba(99, 102, 241, 0.2);
    background: var(--bg-input-focus);
}

.field.full-width {
    grid-column: 1 / -1;
}

.field-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.field-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-key {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    direction: ltr;
    letter-spacing: 0.3px;
}

.field-info-btn {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.08);
    color: var(--accent-light);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.field-info-btn:hover {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--accent);
    transform: scale(1.1);
}

.field-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.6;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field select,
.field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-xs);
    background: rgba(0, 0, 0, 0.3);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.88rem;
    transition: var(--transition);
    direction: ltr;
    text-align: left;
}

.field textarea {
    min-height: 70px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(0, 0, 0, 0.45);
}

.field select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236366f1' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
    padding-left: 30px;
}

/* Boolean toggle */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle {
    width: 48px;
    height: 26px;
    background: rgba(255,255,255,0.08);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.toggle.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-color: var(--accent);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.toggle.active::after {
    right: calc(100% - 21px);
}

.toggle-label {
    font-size: 0.82rem;
    color: var(--text-dim);
}

/* Performance Badge */
.perf-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.perf-badge.perf-speed {
    color: var(--green);
    background: var(--green-glow);
}

.perf-badge.perf-stability {
    color: var(--cyan);
    background: rgba(34, 211, 238, 0.12);
}

.perf-badge.perf-security {
    color: var(--accent-2);
    background: rgba(167, 139, 250, 0.12);
}

.perf-badge.perf-cpu {
    color: var(--yellow);
    background: var(--yellow-glow);
}

.perf-badge.perf-bandwidth {
    color: var(--red);
    background: var(--red-glow);
}

/* Clamp info */
.field-clamp {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 4px;
    direction: ltr;
    text-align: left;
    font-family: 'Courier New', monospace;
}

/* --- Export Bar --- */
.export-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 200;
    animation: slideUp 0.5s ease 0.3s both;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(30px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: white;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 30px rgba(99, 102, 241, 0.35);
    transition: var(--transition);
}

.export-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 6px 40px rgba(99, 102, 241, 0.5);
}

.export-btn:active {
    transform: scale(0.98);
}

.copy-btn, .reset-btn {
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    background: rgba(17, 17, 30, 0.9);
    backdrop-filter: blur(12px);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background: rgba(52, 211, 153, 0.15);
    border-color: var(--green);
    color: var(--green);
}

.reset-btn:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: var(--red);
    color: var(--red);
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    border-radius: 50px;
    background: rgba(17, 17, 30, 0.95);
    border: 1px solid var(--border-active);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 300;
    backdrop-filter: blur(12px);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
    padding: 24px;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: 100%;
    max-width: 580px;
    max-height: 80vh;
    background: var(--bg-card);
    border: 1px solid var(--border-active);
    border-radius: var(--radius);
    padding: 28px;
    overflow-y: auto;
    transform: scale(0.92);
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: var(--red);
    color: var(--red);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    position: relative;
}

.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.modal h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-bright);
}

.modal-body {
    font-size: 0.88rem;
    color: var(--text-dim);
    line-height: 1.9;
}

.modal-body strong {
    color: var(--text);
    font-weight: 600;
}

.modal-body code {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
    direction: ltr;
    display: inline;
    font-family: 'Courier New', monospace;
}

.modal-body .modal-tip {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(52, 211, 153, 0.08);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--green);
}

.modal-body .modal-warn {
    margin-top: 10px;
    padding: 12px 14px;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--yellow);
}

.modal-body .modal-perf {
    margin-top: 14px;
    padding: 12px 14px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--accent-light);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    html { font-size: 14px; }

    .header-inner { padding: 12px 16px; }

    .header-actions { gap: 6px; }

    .btn-github span, .btn-telegram span { display: none; }

    .tab-switcher { padding: 10px 16px; }

    .main-content { padding: 16px 16px 120px; }

    .field-row { grid-template-columns: 1fr; }

    .section-header { padding: 14px 16px; }

    .section-body-inner { padding: 4px 16px 16px; }

    .export-btn { padding: 12px 20px; font-size: 0.88rem; }

    .modal { padding: 20px; max-height: 85vh; }
}

@media (max-width: 480px) {
    .tab-btn { padding: 8px 16px; font-size: 0.82rem; }
    .tab-btn svg { display: none; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.5); }
