/* 
 * استایل‌های مدرن وب‌اپلیکیشن کدر و دیکدر لینک فارسی
 * طراحی اختصاصی واکنش‌گرا و سازگار با دسکتاپ و موبایل (Mobile-First)
 */

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

:root {
    /* تم تاریک (پیش‌فرض) */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.75);
    --bg-input: #0f172a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-focus: #6366f1;
    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --glass-border: 1px solid rgba(255, 255, 255, 0.12);
    --success-bg: rgba(16, 185, 129, 0.15);
    --success-text: #34d399;
    --success-border: rgba(16, 185, 129, 0.3);
}

body.light-mode {
    /* تم روشن */
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-input: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: rgba(0, 0, 0, 0.1);
    --border-focus: #4f46e5;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --glass-border: 1px solid rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    direction: rtl;
    text-align: right;
    transition: background-color 0.3s ease, color 0.3s ease;
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.12) 0px, transparent 50%);
    background-attachment: fixed;
}

.container {
    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    flex: 1;
}

/* هدر و ناوبری */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: var(--glass-border);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.logo-title h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-title p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.icon-btn {
    background: var(--bg-secondary);
    border: var(--glass-border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
}

.header-nav-btn {
    background: var(--bg-secondary);
    border: var(--glass-border);
    color: var(--text-secondary);
    text-decoration: none;
    height: 40px;
    padding: 0 0.85rem;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.86rem;
    font-weight: 600;
    transition: all 0.2s;
}

.header-nav-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.header-nav-btn .btn-text {
    display: inline-block;
}

@media (max-width: 480px) {
    .header-nav-btn .btn-text {
        display: none;
    }
    .header-nav-btn {
        padding: 0;
        width: 40px;
        justify-content: center;
    }
}

/* تب‌بار (Navigation Tabs) */
.tabs-nav {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 0.35rem;
    margin-bottom: 1.8rem;
    border: var(--glass-border);
    gap: 0.25rem;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    min-width: 120px;
    background: transparent;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-primary);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

/* کارت‌های محتوا */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    border: var(--glass-border);
    padding: 1.8rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 1.4rem;
    line-height: 1.6;
}

/* ورودی‌ها و فرم‌ها */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}

.input-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.text-input {
    width: 100%;
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: 14px;
    padding: 0.9rem 1rem 0.9rem 4.5rem;
    font-size: 1rem;
    color: var(--text-primary);
    transition: all 0.2s;
    outline: none;
}

.text-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.text-input.ltr {
    direction: ltr;
    text-align: left;
    font-family: Consolas, Monaco, monospace;
}

.textarea-input {
    min-height: 120px;
    resize: vertical;
    line-height: 1.7;
    padding-left: 1rem;
}

.input-actions-inline {
    position: absolute;
    left: 8px;
    display: flex;
    gap: 4px;
}

.input-action-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.78rem;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.input-action-btn:hover {
    color: var(--text-primary);
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* انتخاب حالت (Mode Selector) */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.4rem;
}

.mode-btn {
    background: var(--bg-input);
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem 0.6rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.mode-btn .mode-title {
    font-size: 0.88rem;
    font-weight: 700;
}

.mode-btn .mode-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.mode-btn:hover {
    border-color: var(--accent-primary);
}

.mode-btn.active {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-primary);
}

.mode-btn.active .mode-desc {
    color: var(--text-secondary);
}

/* دکمه اصلی عملیات */
.btn-primary {
    width: 100%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 1rem;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.25s ease;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.55);
}

.btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* کارت نتیجه (Result Card) */
.result-card {
    margin-top: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1.5px solid var(--border-focus);
    padding: 1.4rem;
    animation: slideUp 0.3s ease;
}

.result-card.hidden {
    display: none;
}

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

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.9rem;
}

.result-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--success-text);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-border);
}

.badge-encode {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.badge-decode {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.result-box {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.1rem;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
    max-height: 240px;
    overflow-y: auto;
    word-break: break-word;
    user-select: all;
    margin-bottom: 1rem;
}

.result-box.ltr {
    direction: ltr;
    text-align: left;
    font-family: Consolas, monospace;
}

.result-link-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #38bdf8;
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 600;
    word-break: break-all;
}

.result-link-display:hover {
    text-decoration: underline;
}

/* آمار و متادیتا */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    border-radius: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-item {
    display: flex;
    gap: 0.3rem;
}

.stat-val {
    color: var(--text-primary);
    font-weight: 700;
}

.result-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn-action {
    flex: 1;
    min-width: 110px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.2s;
}

.btn-action:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.btn-action.btn-open {
    background: #0284c7;
    color: white;
    border: none;
}

.btn-action.btn-open:hover {
    background: #0369a1;
}

/* تاریخچه */
.history-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 0.8rem;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--accent-primary);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-content {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.8rem;
}

.history-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.history-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    min-width: 65px;
}

.history-value {
    color: var(--text-secondary);
    font-weight: 500;
}

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

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

.btn-sm {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.78rem;
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

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

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.8rem;
}

/* مستندات و راهنمای موبایل */
.guide-card {
    line-height: 1.8;
}

.guide-section {
    margin-bottom: 1.5rem;
}

.guide-section h3 {
    font-size: 1.05rem;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.code-box {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.9rem;
    font-family: Consolas, monospace;
    font-size: 0.85rem;
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    color: #e2e8f0;
    margin-top: 0.5rem;
}

/* توست و اسپینر */
#toastContainer {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success .toast-icon { color: #34d399; }
.toast-error .toast-icon { color: #f87171; }
.toast-info .toast-icon { color: #60a5fa; }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* فوتر */
footer {
    text-align: center;
    padding: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: var(--glass-border);
    margin-top: 2rem;
}

/* واکنش‌گرایی برای موبایل (Mobile Responsive) */
@media (max-width: 640px) {
    .container {
        padding: 1rem 0.8rem;
    }

    .card {
        padding: 1.2rem;
        border-radius: 16px;
    }

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

    .tabs-nav {
        padding: 0.25rem;
    }

    .tab-btn {
        min-width: 80px;
        font-size: 0.85rem;
        padding: 0.6rem 0.5rem;
    }

    .logo-title h1 {
        font-size: 1.15rem;
    }

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