@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface-2: #243044;
    --border: #2d3f5a;
    --text: #e8edf4;
    --text-muted: #8b9cb3;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent-act: #10b981;
    --accent-ecp: #f59e0b;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 14px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.7;
    direction: rtl;
}

.bg-pattern {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(16, 185, 129, 0.08), transparent);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

header.page-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.page-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title .icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.sample-section {
    text-align: center;
    margin-bottom: 2rem;
}

.sample-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.sample-image-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    padding: 4px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(16, 185, 129, 0.2));
}

.sample-image-inner {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 240px;
    border-radius: calc(var(--radius) - 4px);
    overflow: hidden;
    background: var(--surface);
}

.sample-image-inner img {
    display: block;
    max-width: 100%;
    max-height: 320px;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0 auto;
}

.sample-image-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
        to right,
        var(--surface) 0%,
        transparent 12%,
        transparent 88%,
        var(--surface) 100%
    );
    z-index: 2;
}

.sample-image-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        var(--surface) 0%,
        transparent 15%,
        transparent 85%,
        var(--surface) 100%
    );
    z-index: 2;
}

.sample-image-glow {
    position: absolute;
    inset: -20px;
    background: radial-gradient(ellipse at center, transparent 40%, var(--surface) 75%);
    pointer-events: none;
    z-index: 3;
}

.sample-placeholder {
    padding: 3rem 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--surface-2);
    min-width: 280px;
}

.form-grid {
    display: grid;
    gap: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.type-option {
    position: relative;
}

.type-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.type-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    margin: 0;
    color: var(--text-muted);
}

.type-option input:checked + label {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
    color: var(--text);
}

.type-option.act input:checked + label {
    border-color: var(--accent-act);
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-act);
}

.type-option.ecp input:checked + label {
    border-color: var(--accent-ecp);
    background: rgba(245, 158, 11, 0.12);
    color: var(--accent-ecp);
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #fff;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-outline:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
}

.result-panel {
    border-right: 4px solid var(--primary);
    animation: fadeIn 0.35s ease;
}

.result-panel.found-act {
    border-right-color: var(--accent-act);
}

.result-panel.found-ecp {
    border-right-color: var(--accent-ecp);
}

.result-panel.not-found {
    border-right-color: var(--danger);
}

.result-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.badge-act {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-act);
}

.badge-ecp {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-ecp);
}

.badge-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.result-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.result-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.result-section h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.result-section .content {
    white-space: pre-wrap;
    color: var(--text);
}

.rich-content {
    white-space: normal;
}

.rich-content a {
    color: var(--primary);
    text-decoration: underline;
    word-break: break-all;
}

.rich-content a:hover {
    filter: brightness(1.15);
}

.solution-box {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 10px;
    padding: 1rem;
}

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

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

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

.footer-link {
    text-align: center;
    margin-top: 2rem;
}

.footer-link a {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
}

.footer-link a:hover {
    color: var(--primary);
}

.admin-link {
    text-align: left;
    margin-bottom: 0.25rem;
}

.admin-link a {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
}

.admin-link a:hover {
    color: var(--primary);
}

/* صفحه اصلی — تم روشن */
body.page-home {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #f0f4f8;
    --border: #dde4ee;
    --text: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

body.page-home .bg-pattern {
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(16, 185, 129, 0.05), transparent);
}

body.page-home .page-header h1 {
    background: linear-gradient(135deg, #1e293b 0%, #475569 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.page-home tr:hover td {
    background: rgba(0, 0, 0, 0.02);
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.code-tag {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    direction: ltr;
    display: inline-block;
}

.code-tag.act {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-act);
}

.code-tag.ecp {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-ecp);
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 500;
}

.tab-btn.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.tab-panel {
    display: none;
}

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

.import-hint {
    background: var(--surface-2);
    border-radius: 10px;
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.8;
}

.import-hint code {
    background: var(--bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.8rem;
    direction: ltr;
    display: inline-block;
}

.login-card {
    max-width: 420px;
    margin: 4rem auto;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.mode-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.mode-option input {
    accent-color: var(--primary);
}

.field-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.mode-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.mode-badge.direct {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
}

.mode-badge.guided {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-ecp);
}

.flow-node {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.flow-node-nested {
    margin-top: 0.75rem;
    border-right: 3px solid var(--primary);
}

.flow-node-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.flow-node-header label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.flow-node-badge {
    font-size: 0.75rem;
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.flow-question-input {
    margin-bottom: 0.75rem;
}

.flow-options {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.flow-option {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
}

.flow-option-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.flow-option-type {
    width: auto;
    min-width: 130px;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
}

.flow-remove-option {
    min-width: 36px;
    padding: 0.45rem 0.65rem;
}

.flow-wizard-question {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--surface-2);
    border-radius: 10px;
    border-right: 3px solid var(--primary);
}

.flow-wizard-options {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.flow-wizard-btn {
    width: 100%;
    padding: 0.9rem 1rem;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: right;
}

body.page-home .flow-wizard-btn {
    background: #fff;
}

.flow-wizard-btn:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}

.flow-wizard-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.flow-wizard-result {
    margin-top: 0.5rem;
}

.flow-chosen-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.65rem;
}

@media (max-width: 600px) {
    .type-selector {
        grid-template-columns: 1fr;
    }

    .admin-header {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-actions {
        flex-direction: column;
    }

    .mode-selector {
        grid-template-columns: 1fr;
    }

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