/* Frontend CSS */
.cfm-frontend-dashboard {
    font-family: 'IRANSans', 'Tahoma', sans-serif;
    direction: rtl;
    background: #f5f5f5;
    min-height: 100vh;
    text-align: right;
}

/* Main container for frontend */
.cfm-frontend-dashboard .wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    direction: rtl;
    text-align: right;
}

.cfm-nav-tabs {
    display: flex;
    background: #fff;
    border-bottom: 2px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    direction: rtl;
    justify-content: flex-start;
}

.cfm-nav-tab {
    padding: 15px 25px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    font-family: 'IRANSans', 'Tahoma', sans-serif;
}

.cfm-nav-tab:hover {
    background: #f0f8ff;
    color: #2196F3;
}

.cfm-nav-tab.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
    background: #f0f8ff;
}

.cfm-tab-content {
    padding: 20px;
    direction: rtl;
    text-align: right;
}

.cfm-tab {
    display: none;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    direction: rtl;
    text-align: right;
}

.cfm-tab.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.cfm-dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
    direction: rtl;
}

.cfm-stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    direction: rtl;
}

.cfm-stat-card:hover {
    transform: translateY(-5px);
}

.cfm-stat-card h3 {
    margin: 0 0 10px 0;
    font-size: 18px;
    opacity: 0.9;
    font-weight: 500;
}

.cfm-stat-value {
    font-size: 36px;
    font-weight: bold;
    margin: 0;
    font-family: 'IRANSans', 'Tahoma', sans-serif;
}

.cfm-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
    direction: rtl;
}

.cfm-chart-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    direction: rtl;
    text-align: right;
}

.cfm-chart-container h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
    font-size: 20px;
    font-weight: 600;
}

.cfm-form {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    direction: rtl;
    text-align: right;
}

.cfm-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 20px;
    direction: rtl;
}

.cfm-form-group {
    display: flex;
    flex-direction: column;
    direction: rtl;
    text-align: right;
}

.cfm-form-group label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
    text-align: right;
    direction: rtl;
}

.cfm-form input,
.cfm-form select,
.cfm-form textarea {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    direction: rtl;
    text-align: right;
    font-family: 'IRANSans', 'Tahoma', sans-serif;
}

.cfm-form input:focus,
.cfm-form select:focus,
.cfm-form textarea:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 5px rgba(33, 150, 243, 0.3);
}

.cfm-items-section {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
    direction: rtl;
    text-align: right;
}

.cfm-items-section h3 {
    margin-top: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.cfm-items-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 120px;
    gap: 10px;
    padding: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    font-weight: bold;
    margin-bottom: 10px;
    direction: rtl;
    text-align: right;
}

.cfm-item-row,
.cfm-purchase-item-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr 120px;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    direction: rtl;
}

.cfm-btn-primary,
.cfm-btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    font-family: 'IRANSans', 'Tahoma', sans-serif;
}

.cfm-btn-primary {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

.cfm-btn-primary:hover {
    background: linear-gradient(135deg, #1976D2, #1565C0);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.cfm-btn-secondary {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

.cfm-btn-secondary:hover {
    background: linear-gradient(135deg, #F57C00, #E65100);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.cfm-remove-item {
    background: #f44336;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.cfm-remove-item:hover {
    background: #d32f2f;
}

.cfm-total-section {
    text-align: center;
    padding: 20px;
    background: #e8f5e8;
    border-radius: 8px;
    margin: 20px 0;
    direction: rtl;
    text-align: center;
}

.cfm-total-section h3 {
    margin: 0;
    color: #2e7d32;
    font-size: 20px;
    font-family: 'IRANSans', 'Tahoma', sans-serif;
}

.cfm-form-actions {
    text-align: center;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    direction: rtl;
}

.cfm-settings-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    direction: rtl;
    justify-content: flex-start;
}

.cfm-settings-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    font-family: 'IRANSans', 'Tahoma', sans-serif;
}

.cfm-settings-tab.active {
    color: #2196F3;
    border-bottom-color: #2196F3;
}

.cfm-reports-filters {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    direction: rtl;
    text-align: right;
}

#reports-table {
    overflow-x: auto;
    direction: rtl;
}

.cfm-reports-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    direction: rtl;
}

.cfm-reports-table th,
.cfm-reports-table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid #e0e0e0;
    font-family: 'IRANSans', 'Tahoma', sans-serif;
}

.cfm-reports-table th {
    background: #f5f5f5;
    font-weight: bold;
    color: #333;
}

.cfm-reports-table tbody tr:hover {
    background: #f0f8ff;
}

/* Improved responsive design */
/* Responsive Design */
@media (max-width: 768px) {
    .cfm-frontend-dashboard .wrap {
        padding: 10px;
    }
    
    .cfm-nav-tabs {
        flex-wrap: wrap;
    }
    
    .cfm-nav-tab {
        flex: 1;
        min-width: 120px;
        text-align: center;
        font-size: 14px;
        padding: 12px 15px;
    }
    
    .cfm-dashboard-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .cfm-charts-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .cfm-form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .cfm-items-header,
    .cfm-item-row,
    .cfm-purchase-item-row {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }
    
    .cfm-settings-tabs {
        flex-wrap: wrap;
    }
    
    .cfm-stat-value {
        font-size: 28px;
    }
    
    .cfm-chart-container h3 {
        font-size: 18px;
    }
}

/* Loading and Success Messages */
.cfm-loading {
    text-align: center;
    padding: 20px;
    direction: rtl;
}

.cfm-loading p {
    margin-top: 10px;
    color: #666;
    font-size: 14px;
}

.cfm-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196F3;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.cfm-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #2196F3;
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

.cfm-message {
    padding: 10px 15px;
    border-radius: 5px;
    margin: 10px 0;
}

.cfm-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.cfm-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Additional RTL improvements */
.cfm-frontend-dashboard * {
    box-sizing: border-box;
}

/* Ensure proper text direction for mixed content */
.cfm-frontend-dashboard .ltr {
    direction: ltr;
    text-align: left;
}

.cfm-frontend-dashboard .rtl {
    direction: rtl;
    text-align: right;
}