/* Vazir Font Configuration */
@font-face {
    font-family: 'Vazir';
    src: url('../fonts/Vazir.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazir';
    src: url('../fonts/Vazir-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazir';
    src: url('../fonts/Vazir-Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazir';
    src: url('../fonts/Vazir-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Vazir';
    src: url('../fonts/Vazir-Thin.ttf') format('truetype');
    font-weight: 100;
    font-style: normal;
    font-display: swap;
}

/* Color Variables */
:root {
    --primary: #6366F1;
    --secondary: #8B5CF6;
    --background: #F8FAFC;
    --sidebar-bg: #1F2937;
    --success: #10B981;
    --text: #374151;
    --white: #FFFFFF;
    --light-gray: #F3F4F6;
    --border: #E5E7EB;
    --muted: #6B7280;
}

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

body {
    font-family: 'Ravi', 'Vazir', 'Vazirmatn', 'Tahoma', 'Arial', sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    direction: rtl;
    text-align: right;
}

/* Flash Messages */
.flash-messages {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    width: 400px;
    max-width: 90vw;
}

/* Landing Page */
.landing-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-page > .container {
    flex: 1;
}

/* Sticky Navigation */
.navbar.sticky-top {
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(10px);
    background-color: rgba(248, 250, 252, 0.95) !important;
}

/* Navigation container */
.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
}

/* RTL Navigation Brand */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand svg,
.navbar-brand i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

/* Navigation buttons always horizontal */
.navbar-nav-buttons {
    display: flex !important;
    flex-direction: row !important;
    gap: 0.5rem;
    align-items: center;
}

.navbar-nav-buttons .btn {
    white-space: nowrap;
    font-size: 0.9rem;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .navbar-nav-buttons .btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (max-width: 480px) {
    .navbar-nav-buttons .btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.7rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
}

/* Smooth scrolling for anchor links */
html {
    scroll-behavior: smooth;
}

/* Adjust hero section for sticky nav */
.hero-section {
    padding-top: 2rem;
}

.hero-section {
    background: url('../img/home.jpg') center center/cover no-repeat;
    color: white;
    position: relative;
    overflow: hidden;
}

.hero-section h1,
.hero-section .display-4,
.hero-section .lead,
.hero-section p {
    color: white !important;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") repeat;
}

.hero-section .container {
    position: relative;
    z-index: 1;
}

.feature-item {
    display: flex;
    align-items: center;
    font-weight: 500;
    gap: 0.5rem;
}

.feature-item svg,
.feature-item i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

.video-preview-card {
    position: relative;
    transform: perspective(1000px) rotateY(-15deg) rotateX(10deg);
    transition: transform 0.3s ease;
}

.video-preview-card:hover {
    transform: perspective(1000px) rotateY(-10deg) rotateX(5deg);
}

.features-section {
    background: white;
}

.feature-card .card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card .card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}

.feature-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 12px;
}

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    background: var(--background);
}

.auth-form-container {
    max-width: 450px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.auth-image-section {
    background: url('../img/home.jpg') center center/cover no-repeat;
    position: relative;
}

.auth-image-section h3,
.auth-image-section p,
.auth-image-section .lead {
    color: white !important;
}

/* Removed pattern overlay for cleaner appearance */
.auth-image-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3); /* Simple dark overlay for better text readability */
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    background: var(--background);
    position: relative;
}

.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: white;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    box-shadow: -2px 0 15px rgba(0,0,0,0.1);
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.25rem;
}

.sidebar-brand svg {
    margin-right: 0.75rem !important;
    margin-left: 0 !important;
    width: 24px;
    height: 24px;
}

.brand-text {
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.sidebar.collapsed .brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 0 1rem;
    align-items: center;
    justify-content: center;
    z-index: 1060;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 1rem;
}

.mobile-menu-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

.mobile-brand {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
    gap: 0.5rem;
}

.mobile-brand svg {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
    width: 24px;
    height: 24px;
}

.mobile-user-info {
    font-size: 0.9rem;
    opacity: 0.9;
}

.mobile-credits {
    font-weight: 500;
}

/* Loading animations */
.spinner {
    animation: spin 1s linear infinite;
}

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

/* Responsive sidebar behavior */
@media (min-width: 992px) {
    .sidebar-toggle {
        display: none;
    }
    
    .mobile-header {
        display: none;
    }
    
    .sidebar {
        position: fixed;
        transform: translateX(0);
        right: 0;
    }
    
    .main-content {
        margin-right: 280px;
        margin-left: 0;
        padding: 2rem;
    }
    
    .main-content.expanded {
        margin-right: 70px;
        margin-left: 0;
    }
}

@media (max-width: 991px) {
    .sidebar-toggle {
        display: block;
    }
    
    .mobile-header {
        display: flex !important;
        width: 100%;
        justify-content: space-between;
        align-items: center;
    }
    
    .sidebar {
        position: fixed !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s ease;
        z-index: 1050;
        width: 280px;
        top: 0;
        height: 100vh;
        right: 0 !important;
        left: auto !important;
    }
    
    .sidebar.show {
        transform: translateX(0) !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 2rem;
        padding-top: 80px; /* Space for mobile header */
        width: 100% !important;
    }
    
    /* Overlay for mobile */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 70px;
}

/* This old responsive behavior is now replaced by the newer mobile navigation below */

.sidebar-nav {
    list-style: none;
    padding: 1rem 0;
}

.nav-item {
    margin: 0.25rem 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* RTL Fix: Icons must have margin on the left side - MAXIMUM SPECIFICITY */
.nav-link svg,
.nav-link i,
.sidebar-nav .nav-link svg,
.sidebar-nav .nav-link i,
.sidebar .nav-link svg,
.sidebar .nav-link i,
#sidebar .nav-link svg,
#sidebar .nav-link i,
.dashboard-layout .sidebar .sidebar-nav .nav-link svg,
.dashboard-layout .sidebar .sidebar-nav .nav-link i {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Ensure inline SVG icons have proper spacing */
.sidebar .nav-link > svg:first-child,
.sidebar-nav .nav-link > svg:first-child,
#sidebar .nav-link > svg:first-child,
#sidebar .sidebar-nav .nav-link > svg:first-child {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

/* Force RTL icon margins with ABSOLUTE highest specificity */
body .dashboard-layout #sidebar .sidebar-nav .nav-item .nav-link svg,
body .dashboard-layout #sidebar .sidebar-nav .nav-item .nav-link i {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

/* Additional override for any feather icons */
.sidebar .feather,
.sidebar-nav .feather,
#sidebar .feather {
    margin-right: 0 !important;
    margin-left: 0.75rem !important;
}

.sidebar.collapsed .nav-link span {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .nav-link svg {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.nav-item.active .nav-link {
    background: var(--primary);
    color: white;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.75rem !important;
    margin-right: 0 !important;
}

.user-details .username {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
}

.user-details .credits {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
}

.sidebar.collapsed .user-details {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.logout-btn {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-right: 280px;
    margin-left: 0;
    padding: 2rem;
    transition: margin-right 0.3s ease;
}

.main-content.expanded {
    margin-right: 70px;
    margin-left: 0;
}

.content-section {
    display: none;
}

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

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* RTL Icon Fixes - More Comprehensive */
/* Default for all icons - margin on left for RTL */
i[data-feather], 
svg.feather,
.feather {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
    vertical-align: middle;
}

/* Icons that come AFTER text in RTL need margin on left */
.nav-link i[data-feather],
.nav-link svg.feather,
.sidebar-brand i[data-feather],
.sidebar-brand svg.feather,
.mobile-brand i[data-feather],
.mobile-brand svg.feather {
    margin-left: 0.75rem !important;
    margin-right: 0 !important;
}

/* Icons in buttons */
.btn i[data-feather],
.btn svg.feather {
    margin-left: 0.25rem !important;
    margin-right: 0 !important;
}

/* Icons that should be standalone (no margins) */
.stat-icon i[data-feather],
.stat-icon svg.feather,
.user-avatar i[data-feather],
.user-avatar svg.feather,
.logout-btn i[data-feather],
.logout-btn svg.feather {
    margin: 0 !important;
}

/* Special case for arrow icons in tables */
td i[data-feather="arrow-right"] {
    margin: 0 0.25rem !important;
}

/* Jobs Table Layout */
#jobs-table {
    table-layout: fixed; /* Force fixed column widths */
    width: 100%;
}

#jobs-table th:first-child,
#jobs-table td:first-child {
    width: 35% !important; /* Strictly 35% width for video column */
    max-width: 35% !important;
    overflow: hidden;
}

/* Add light borders between all columns */
#jobs-table th,
#jobs-table td {
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

/* Add left border to last column (left edge in RTL) */
#jobs-table th:last-child,
#jobs-table td:last-child {
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

/* Add top border to header cells */
#jobs-table thead th {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

/* Add borders to table edges */
#jobs-table {
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    border-left: 1px solid rgba(0, 0, 0, 0.08);
}

/* Mobile responsive table */
@media (max-width: 768px) {
    #jobs-table {
        table-layout: auto; /* Allow flexible layout on mobile */
    }
    
    #jobs-table thead {
        display: none; /* Hide headers on mobile */
    }
    
    #jobs-table tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: 8px;
        padding: 0.75rem;
    }
    
    #jobs-table td {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        text-align: right;
        padding: 0.5rem 0;
        border-bottom: none;
        position: relative;
        padding-right: 40%;
    }
    
    #jobs-table td:before {
        content: attr(data-label);
        position: absolute;
        right: 0;
        width: 35%;
        font-weight: bold;
        color: var(--muted);
    }
    
    #jobs-table th:first-child,
    #jobs-table td:first-child {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .video-name-cell {
        overflow-x: auto;
        max-width: 100%; /* Full width on mobile - no restriction */
        display: block;
        direction: ltr; /* Force left-to-right for English filenames */
        text-align: left; /* Align text to the left to show from beginning */
    }
}

/* Table Video Name Column */
.video-name-cell {
    overflow-x: auto;
    white-space: nowrap;
    display: block;
    width: 100%;
    direction: ltr; /* Force left-to-right for English filenames */
    text-align: left; /* Align text to the left to show from beginning */
}

.video-name-cell::-webkit-scrollbar {
    height: 4px;
}

.video-name-cell::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.video-name-cell::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.video-name-cell::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Stats Cards */
.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    background: var(--light-gray);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 1rem !important;
    margin-right: 0 !important;
}

.stat-content .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.stat-content .stat-label {
    font-size: 0.875rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: var(--background);
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.02);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-content {
    pointer-events: none;
    user-select: none;
}

.upload-area:hover .upload-content {
    color: var(--primary);
}

.upload-area input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Operation Types */
.operation-types {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.operation-card {
    position: relative;
}

.operation-card input[type="radio"] {
    position: absolute;
    opacity: 0;
}

.operation-label {
    display: block;
    padding: 1.5rem;
    background: white;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.operation-label:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.1);
}

.operation-card input[type="radio"]:checked + .operation-label {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.02);
}

.operation-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.operation-description {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.operation-cost {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
}

/* Cost Preview */
.cost-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.cost-item:last-child {
    border-bottom: none;
}

.cost-total {
    background: var(--light-gray);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

/* Credit Balance */
.credit-balance-display {
    text-align: center;
    padding: 2rem;
}

.balance-amount {
    margin-bottom: 2rem;
}

.balance-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    display: block;
}

.balance-label {
    font-size: 1.125rem;
    color: var(--muted);
}

/* Content Wrapper for Recent Translations */
.content-wrapper {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.content-wrapper:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* Pricing Table */
.pricing-table ul li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.pricing-table ul li:last-child {
    border-bottom: none;
}

.package-item {
    padding: 1rem;
    background: var(--light-gray);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

/* Account Stats */
.stat-item {
    text-align: center;
    padding: 1rem;
}

.stat-item .stat-label {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.stat-item .stat-value {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 1240px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .operation-types {
        grid-template-columns: 1fr;
    }
    
    .balance-number {
        font-size: 2rem;
    }
}

/* Enhanced contrast for better accessibility */
.text-primary {
    color: var(--primary) !important;
}

.bg-primary,
.bg-indigo,
.bg-purple,
.bg-blue {
    background-color: var(--primary) !important;
    color: white !important;
}

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

.btn-primary:hover {
    background-color: #5A67D8;
    border-color: #5A67D8;
    color: white !important;
}

.btn-outline-light {
    border-color: white;
    color: white !important;
}

.btn-outline-light:hover {
    background-color: white;
    border-color: white;
    color: var(--primary) !important;
}

.hero-section .btn-outline-secondary {
    border-color: white;
    color: white !important;
}

.hero-section .btn-outline-secondary:hover {
    background-color: white;
    border-color: white;
    color: var(--primary) !important;
}

/* Sidebar with dark background - ensure white text */
.sidebar {
    background: var(--sidebar-bg);
    color: white;
}

.sidebar h1,
.sidebar h2, 
.sidebar h3,
.sidebar h4,
.sidebar h5,
.sidebar h6,
.sidebar p,
.sidebar span,
.sidebar div {
    color: white !important;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.7) !important;
}

.sidebar .nav-link:hover,
.sidebar .nav-item.active .nav-link {
    color: white !important;
}

/* Progress bars and badges with primary colors */
.progress-bar,
.badge.bg-primary {
    background: linear-gradient(90deg, var(--primary), var(--secondary)) !important;
    color: white !important;
}

/* Cards and elements with primary/secondary backgrounds */
.card.bg-primary,
.card.bg-secondary,
.alert.alert-primary {
    color: white !important;
}

.card.bg-primary h1,
.card.bg-primary h2,
.card.bg-primary h3,
.card.bg-primary h4,
.card.bg-primary h5,
.card.bg-primary h6,
.card.bg-primary p,
.card.bg-secondary h1,
.card.bg-secondary h2,
.card.bg-secondary h3,
.card.bg-secondary h4,
.card.bg-secondary h5,
.card.bg-secondary h6,
.card.bg-secondary p {
    color: white !important;
}

/* Layout Fixes for Beautiful Persian Page */
/* Fix overlapping navigation on desktop */
@media (min-width: 1241px) {
    .sidebar {
        width: 280px;
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        z-index: 1000;
    }
    
    .main-content {
        margin-right: 280px !important;
        margin-left: 0 !important;
        padding: 2rem;
        width: calc(100% - 280px);
    }
    
    .main-content.expanded {
        margin-right: 70px !important;
        margin-left: 0 !important;
        width: calc(100% - 70px);
    }
    
    .content-section {
        max-width: 100%;
    }
}

/* Additional mobile fixes */
@media (max-width: 1240px) {
    .mobile-header {
        height: 60px !important;
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1060 !important;
        display: flex !important;
        visibility: visible !important;
    }
    
    .mobile-menu-toggle {
        display: block !important;
        visibility: visible !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 1rem;
        padding-top: 75px !important; /* Space for mobile header */
        width: 100% !important;
    }
    
    .sidebar {
        width: 280px !important;
        max-width: 85vw; /* Prevent trimming on small screens */
        transform: translateX(100%) !important;
    }
    
    .sidebar.show {
        transform: translateX(0) !important;
    }
    
    .mobile-brand {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }
    
    .mobile-credits {
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    /* Hide collapsed state on mobile */
    .sidebar.collapsed {
        transform: translateX(100%) !important;
        width: 280px !important;
    }
}

/* Fix dashboard title under header */
.page-header {
    margin-bottom: 2rem;
    padding-top: 0.5rem;
}

/* Beautiful cards with proper shadows */
.card {
    border: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* Fix table scrolling */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem;
}

/* Beautiful buttons */
.btn {
    font-weight: 500;
    transition: all 0.2s ease;
}

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

/* Fix spacing issues */
.row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}

.col-lg-3,
.col-md-6 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Mobile stat cards */
@media (max-width: 576px) {
    .stat-card {
        margin-bottom: 0.5rem;
    }
    
    .operation-types {
        gap: 0.5rem;
    }
    
    .upload-area {
        padding: 2rem 1rem;
    }
}

/* Critical mobile fixes to prevent sidebar corruption */
@media (max-width: 991px) {
    /* Force hide sidebar completely off screen */
    body {
        overflow-x: hidden;
    }
    
    .dashboard-layout {
        overflow-x: hidden;
        position: relative;
    }
    
    /* Ensure sidebar is completely off-screen when hidden */
    .sidebar:not(.show) {
        transform: translateX(100%) !important;
        visibility: hidden !important;
    }
    
    .sidebar.show {
        transform: translateX(0) !important;
        visibility: visible !important;
    }
    
    /* Ensure main content takes full width */
    .main-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding-top: 75px !important;
    }
    
    /* Force mobile header to be visible */
    .mobile-header {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Ensure menu button is visible */
    .mobile-menu-toggle {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .hero-section .display-4 {
        font-size: 2rem;
    }
    
    .auth-form-container {
        padding: 1rem;
    }
    
    .video-preview-card {
        transform: none;
        margin-top: 2rem;  /* Add margin-top for mobile */
    }
    
    .features-section .row {
        margin: 0;
    }
    
    .features-section .col-lg-4 {
        padding: 0.5rem;
    }
    
    /* Add margin to free trial button on mobile */
    .hero-content .btn-primary {
        margin-bottom: 1rem;
    }
}

/* Utilities */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #5A67D8;
    border-color: #5A67D8;
}

.card {
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

.badge {
    border-radius: 6px;
    font-weight: 500;
}

.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background: var(--light-gray);
    border: none;
    font-weight: 600;
}

.table td {
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-section.active {
    animation: fadeIn 0.3s ease;
}

/* Progress Animation */
.progress-bar {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== RTL SPACING FIXES ========== */

/* RTL fixes for Bootstrap buttons and spacing */
.btn svg,
.btn i {
    margin-left: 0.25rem !important;
    margin-right: 0 !important;
}

/* RTL spacing fixes for flex items with icons */
.d-flex svg,
.d-flex i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

.d-flex svg:first-child,
.d-flex i:first-child {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}

/* Progress and status elements */
.alert svg,
.alert i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

.alert svg:first-child,
.alert i:first-child {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}

/* Card body icons */
.card-body svg,
.card-body i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

.card-body svg:first-child,
.card-body i:first-child {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}

/* List items with icons */
.list-group-item svg,
.list-group-item i,
.list-unstyled li svg,
.list-unstyled li i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

.list-group-item svg:first-child,
.list-group-item i:first-child,
.list-unstyled li svg:first-child,
.list-unstyled li i:first-child {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}

/* Table row icons */
td svg,
td i,
th svg,
th i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

td svg:first-child,
td i:first-child,
th svg:first-child,
th i:first-child {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}

/* Bootstrap utilities override for RTL */
.me-1 { margin-left: 0.25rem !important; margin-right: 0 !important; }
.me-2 { margin-left: 0.5rem !important; margin-right: 0 !important; }
.me-3 { margin-left: 1rem !important; margin-right: 0 !important; }
.me-4 { margin-left: 1.5rem !important; margin-right: 0 !important; }
.me-5 { margin-left: 3rem !important; margin-right: 0 !important; }

.ms-1 { margin-right: 0.25rem !important; margin-left: 0 !important; }
.ms-2 { margin-right: 0.5rem !important; margin-left: 0 !important; }
.ms-3 { margin-right: 1rem !important; margin-left: 0 !important; }
.ms-4 { margin-right: 1.5rem !important; margin-left: 0 !important; }
.ms-5 { margin-right: 3rem !important; margin-left: 0 !important; }

/* Additional RTL fixes for specific elements */
.navbar-brand svg,
.navbar-brand i {
    margin-left: 0.5rem !important;
    margin-right: 0 !important;
}

/* Feature items spacing */
.feature-item svg:first-child,
.feature-item i:first-child {
    margin-left: 0 !important;
    margin-right: 0.5rem !important;
}
