:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --accent-color: #ec4899;
    --bg-color: #fafafa;
    --text-color: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
}

* {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Modern Navbar Styles */
.navbar-modern {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
    padding: 1.25rem 0;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
    transition: all 0.3s ease;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-modern:hover {
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.12), 0 2px 5px rgba(0, 0, 0, 0.08);
}

/* Brand Styling */
.brand-modern {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary-color) !important;
    text-decoration: none;
    transition: all 0.3s ease;
    padding: 0.5rem 0;
}

.brand-modern:hover {
    color: var(--secondary-color) !important;
    transform: translateY(-2px);
}

.brand-icon {
    color: var(--primary-color);
    transition: all 0.3s ease;
}

.brand-modern:hover .brand-icon {
    color: var(--secondary-color);
    transform: rotate(5deg) scale(1.1);
}

.brand-text {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Navigation Links */
.nav-links-modern {
    gap: 0.5rem;
}

.nav-link-modern {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem !important;
    border-radius: 0.5rem;
    font-weight: 500;
    color: var(--text-color) !important;
    transition: all 0.3s ease;
    position: relative;
    margin: 0 0.25rem;
}

.nav-link-modern::before {
    content: '';
    position: absolute;
    bottom: 0.25rem;
    right: 50%;
    transform: translateX(50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    border-radius: 2px;
}

.nav-link-modern:hover {
    color: var(--primary-color) !important;
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-2px);
}

.nav-link-modern:hover::before {
    width: 80%;
}

.nav-link-modern.active {
    color: var(--primary-color) !important;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    font-weight: 600;
}

.nav-link-modern.active::before {
    width: 80%;
}

.nav-icon {
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.nav-link-modern:hover .nav-icon {
    transform: scale(1.15);
}

/* Navbar Toggler */
.custom-toggler {
    border: 2px solid var(--primary-color);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    transition: all 0.3s ease;
}

.custom-toggler:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.05);
}

.custom-toggler .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2899, 102, 241, 1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* Navbar Buttons */
.btn-nav-outline,
.btn-nav-primary,
.btn-nav-user,
.btn-nav-danger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 2px solid;
    white-space: nowrap;
}

.btn-nav-outline {
    background: transparent;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

.btn-nav-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-nav-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.btn-nav-user {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-color: var(--primary-color);
    color: var(--primary-color);
    position: relative;
}

.btn-nav-user:hover,
.btn-nav-user:focus,
.btn-nav-user.show {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    border-color: var(--primary-color);
}

.btn-nav-user .dropdown-arrow {
    transition: transform 0.3s ease;
    margin-right: 0.25rem;
}

.btn-nav-user.show .dropdown-arrow {
    transform: rotate(180deg);
}

/* Dropdown Menu Styles */
.dropdown-menu-modern {
    background: white;
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    margin-top: 0.5rem;
    min-width: 240px;
    animation: dropdownFadeIn 0.3s ease;
    backdrop-filter: blur(10px);
}

/* RTL Dropdown positioning */
[dir="rtl"] .dropdown-menu-end {
    left: 0 !important;
    right: auto !important;
    transform-origin: top right;
}

[dir="rtl"] .dropdown-menu-modern.dropdown-menu-end {
    left: 0 !important;
    right: auto !important;
}

/* Ensure dropdown doesn't go off screen in RTL */
#userMenu {
    position: relative;
}

[dir="rtl"] #userMenu .dropdown-menu {
    left: 0 !important;
    right: auto !important;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-info-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(139, 92, 246, 0.05) 100%);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

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

.user-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item-modern {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s ease;
    margin: 0.25rem 0;
    text-decoration: none;
}

.dropdown-item-modern:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    color: var(--primary-color);
    transform: translateX(4px);
}

.dropdown-item-modern svg {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.dropdown-item-modern:hover svg {
    transform: scale(1.1);
}

.dropdown-item-danger {
    color: #ef4444;
}

.dropdown-item-danger:hover {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    color: #dc2626;
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: var(--border-color);
    opacity: 0.5;
}

.btn-nav-danger {
    background: transparent;
    border-color: #ef4444;
    color: #ef4444;
}

.btn-nav-danger:hover {
    background: #ef4444;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Responsive Navbar */
@media (max-width: 991px) {
    .navbar-modern {
        padding: 1rem 0;
    }

    .nav-link-modern {
        padding: 0.75rem 1rem !important;
        margin: 0.25rem 0;
    }

    .btn-nav-outline,
    .btn-nav-primary {
        width: 100%;
        justify-content: center;
        margin: 0.25rem 0;
    }

    #authButtons {
        flex-direction: column;
        width: 100%;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
    }

    #userMenu {
        width: 100%;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid var(--border-color);
    }

    #userMenu .btn-nav-user {
        width: 100%;
        justify-content: center;
    }

    .dropdown-menu-modern {
        width: 100%;
        margin-top: 0.5rem;
    }
}

.footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: auto;
}

.container-fluid {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .main-content {
        padding: 1rem 0;
    }
}

.modal-content {
    border-radius: 0.5rem;
    border: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

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

.btn-primary:hover {
    background-color: #4f46e5;
    border-color: #4f46e5;
}

/* Search page improvements */
.search-form-card {
    border-radius: 0.75rem;
    transition: box-shadow 0.3s ease;
}

.search-form-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

/* Search input with buttons inside */
.input-group {
    border-radius: 0.5rem;
    overflow: hidden;
}

.input-group .btn {
    border-radius: 0;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    border-width: 1px;
    transition: all 0.2s ease;
    min-width: 48px;
}

/* RTL: Input on left, buttons on right */
[dir="rtl"] .input-group .form-control {
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    border-left: none;
}

[dir="rtl"] .input-group .btn:first-of-type {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-right: none;
}

[dir="rtl"] .input-group .btn:last-child {
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
    border-left: none;
}

/* LTR: Input on left, buttons on right */
[dir="ltr"] .input-group .form-control {
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;
    border-right: none;
}

[dir="ltr"] .input-group .btn:first-of-type {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-left: none;
}

[dir="ltr"] .input-group .btn:last-child {
    border-top-right-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
    border-right: none;
}

.input-group .form-control {
    border-width: 1px;
}

.input-group .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
    z-index: 2;
}

.input-group .form-control:focus+.btn,
.input-group .form-control:focus~.btn {
    border-color: var(--primary-color);
}

/* Settings button active state */
#searchSettingsBtn.active {
    background-color: #4f46e5;
    border-color: #4f46e5;
}

#searchSettingsBtn.active:hover {
    background-color: #4338ca;
    border-color: #4338ca;
}

/* Consistent button hover effects */
.input-group .btn-primary:hover {
    background-color: #4f46e5;
    border-color: #4f46e5;
    z-index: 3;
}

.btn-group .btn {
    transition: all 0.2s ease;
}

.btn-group .btn:hover {
    transform: translateY(-1px);
}

.btn-group .btn-check:checked+.btn {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.form-select:focus,
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(99, 102, 241, 0.25);
}

.result-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 0.5rem;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

/* Tooltip improvements */
[data-bs-toggle="tooltip"] {
    cursor: help;
}

/* Fusion options animation */
#fusionOptionsRow {
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive improvements */
@media (max-width: 768px) {
    .btn-group.flex-wrap .btn {
        flex: 1 1 50%;
        margin-bottom: 0.5rem;
    }

    #fusionOptionsRow .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

.alert {
    border-radius: 0.5rem;
    border: none;
}

.text-danger {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.card-link {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.card-link:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15) !important;
}

.card-link:hover .card-title {
    color: var(--primary-color);
}

/* Toast Styles */
.toast {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    min-width: 300px;
    max-width: 500px;
}

.toast-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.75rem 1rem;
    font-weight: 600;
}

.toast-body {
    padding: 1rem;
    font-size: 0.95rem;
}

.toast-success {
    background-color: #10b981;
    color: white;
}

.toast-success .toast-header {
    background-color: rgba(16, 185, 129, 0.9);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.toast-error,
.toast-danger {
    background-color: #ef4444;
    color: white;
}

.toast-error .toast-header,
.toast-danger .toast-header {
    background-color: rgba(239, 68, 68, 0.9);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.toast-warning {
    background-color: #f59e0b;
    color: white;
}

.toast-warning .toast-header {
    background-color: rgba(245, 158, 11, 0.9);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.toast-info {
    background-color: #3b82f6;
    color: white;
}

.toast-info .toast-header {
    background-color: rgba(59, 130, 246, 0.9);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.toast-confirm {
    background-color: white;
    border: 2px solid var(--primary-color);
}

.toast-confirm .toast-header {
    background-color: var(--primary-color);
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.toast-confirm .toast-body {
    color: var(--text-color);
}

.toast-confirm .btn {
    margin: 0 0.25rem;
    min-width: 80px;
}

.toast-icon {
    width: 20px;
    height: 20px;
    margin-left: 0.5rem;
    display: inline-block;
    vertical-align: middle;
}

/* کانتینر کد حرفه‌ای */
.code-block-container {
    position: relative;
    margin: 16px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    font-family: 'Courier New', monospace;
    background-color: #f8f9fa;
    direction: ltr;
    font-size: 0.95rem;
    line-height: 1.5;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background-color: #f1f3f5;
    border-bottom: 1px solid #e0e0e0;
    font-size: 0.85rem;
    font-weight: 500;
    color: #333;
    border-radius: 8px 8px 0 0;
    min-height: 30px;
}

.code-language {
    color: #007acc;
    font-weight: 600;
    font-size: 0.85rem;
}

.copy-code-btn {
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.8rem;
    color: #555;
    height: 24px;
    width: 24px;
    min-width: 24px;
}

.copy-code-btn:hover {
    background-color: #f0f0f0;
    border-color: #b0b0b0;
    transform: translateY(-1px);
}

.copy-code-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
}

/* محتوای کد */
.code-block-content {
    margin: 0;
    padding: 12px 16px;
    background-color: #ffffff;
    overflow-x: auto;
    white-space: pre;
    font-size: 0.95rem;
    line-height: 1.5;
    border: none;
    border-radius: 0;
    color: #2d3748;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    letter-spacing: 0.2px;
}

/* استایل کد (برای زبان‌های مختلف) */
.language-js,
.language-javascript {
    color: #e44920;
}

.language-python {
    color: #3572A5;
}

.language-html {
    color: #e34c26;
}

.language-css {
    color: #264de4;
}

.language-json {
    color: #000000;
}

/* پشتیبانی از موبایل */
@media (max-width: 768px) {
    .code-block-container {
        font-size: 0.9rem;
        margin: 12px 0;
    }

    .code-block-header {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .code-block-content {
        padding: 10px 14px;
        font-size: 0.9rem;
    }
}