/* RTL Styles for Track Visits Plugin - Arabic Language Support */

/* Apply RTL direction when Arabic language is active */
.track-visits-rtl {
    direction: rtl;
    text-align: right;
}

/* RTL Dashboard Layout */
.track-visits-rtl .dashboard-layout {
    direction: rtl;
}

/* License Page RTL Styles */
.track-visits-rtl .wrap {
    direction: rtl;
}

.track-visits-rtl .card {
    text-align: right;
}

.track-visits-rtl .form-table th {
    text-align: right;
    padding-right: 0;
    padding-left: 20px;
}

.track-visits-rtl .form-table td {
    text-align: right;
}

.track-visits-rtl .form-table input[type="text"] {
    text-align: right;
}

.track-visits-rtl .button {
    margin-left: 0;
    margin-right: 10px;
}

.track-visits-rtl .button:first-child {
    margin-right: 0;
}

.track-visits-rtl .description {
    text-align: right;
}

/* License Required Page RTL Styles */
.track-visits-rtl .license-required-container {
    direction: rtl;
}

.track-visits-rtl .license-required-card {
    text-align: right;
}

.track-visits-rtl .license-features {
    text-align: right;
}

.track-visits-rtl .license-features ul {
    padding-right: 0;
    padding-left: 20px;
}

.track-visits-rtl .license-features li {
    text-align: right;
    justify-content: flex-end;
}

.track-visits-rtl .license-features li i {
    margin-left: 12px;
    margin-right: 0;
    order: 2;
}

.track-visits-rtl .btn {
    margin-left: 0;
    margin-right: 10px;
}

/* Sidebar RTL Styles for Dashboard */
.track-visits-rtl .sidebar {
    right: 0 !important;
    left: auto !important;
    border-right: none !important;
    border-left: 1px solid var(--border) !important;
}

.track-visits-rtl .sidebar-header {
    direction: rtl;
    text-align: right;
}

.track-visits-rtl .sidebar-header p {
    text-align: right;
    direction: rtl;
}

.track-visits-rtl .sidebar-header h1 {
    direction: rtl;
    text-align: right;
    position: relative;
    padding-right: 40px !important; /* More space for icon */
}

.track-visits-rtl .sidebar-header h1 i {
    position: absolute !important;
    right: 10px !important;  /* A bit closer to edge for header */
    left: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 20px !important;
    text-align: center !important;
}

/* Dead Simple RTL Fix - Just move the icons to the right with proper spacing */
.track-visits-rtl .sidebar-nav a {
    position: relative;
    padding-left: 20px !important;  /* Normal left padding */
    padding-right: 47px !important; /* Adjusted space on right for icon */
}

.track-visits-rtl .sidebar-nav a i {
    position: absolute !important;
    right: 20px !important;
    left: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 20px !important;
    text-align: center !important;
}

/* Back to WordPress button uses same positioning with proper spacing */
.track-visits-rtl .sidebar-nav div a {
    position: relative !important;
    padding-left: 20px !important;  /* Normal left padding */
    padding-right: 47px !important; /* Adjusted space on right for icon */
    direction: rtl !important;
    text-align: right !important;
}

.track-visits-rtl .sidebar-nav div a i {
    position: absolute !important;
    right: 20px !important;
    left: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 20px !important;
    text-align: center !important;
}

.track-visits-rtl .main-content {
    margin-right: var(--sidebar-width) !important;
    margin-left: 0 !important;
}

/* Form Elements RTL */
.track-visits-rtl .filter-group label {
    text-align: right;
}

.track-visits-rtl .filter-input {
    text-align: right;
}

.track-visits-rtl .filter-actions {
    justify-content: flex-start;
}

.track-visits-rtl .filter-actions .btn {
    margin-left: 0;
    margin-right: 10px;
}

.track-visits-rtl .filter-actions .btn:first-child {
    margin-right: 0;
}

/* Table RTL Styles */
.track-visits-rtl table,
.track-visits-rtl .data-table {
    text-align: right;
    direction: rtl;
}

.track-visits-rtl th,
.track-visits-rtl td,
.track-visits-rtl .data-table th,
.track-visits-rtl .data-table td {
    text-align: right !important;
    direction: rtl;
}

/* Specific table header alignment */
.track-visits-rtl .data-table th {
    text-align: right !important;
    padding: 12px 20px 12px 20px;
}

/* Specific table cell alignment */
.track-visits-rtl .data-table td {
    text-align: right !important;
    padding: 12px 20px 12px 20px;
}

/* Table row RTL */
.track-visits-rtl .data-table tr {
    direction: rtl;
}

/* Ensure table content flows RTL */
.track-visits-rtl .data-table tbody,
.track-visits-rtl .data-table thead {
    direction: rtl;
}

/* Country badge RTL alignment */
.track-visits-rtl .country-badge {
    direction: rtl;
    text-align: right;
}

/* Table sorting icons RTL */
.track-visits-rtl .data-table th i {
    margin-left: 0;
    margin-right: 5px;
}

/* Ensure all table text content aligns right */
.track-visits-rtl .data-table th *,
.track-visits-rtl .data-table td * {
    text-align: right;
}

/* Links and buttons in table cells */
.track-visits-rtl .data-table td a,
.track-visits-rtl .data-table td button {
    text-align: right;
}

/* Status badges and indicators in tables */
.track-visits-rtl .data-table .status-badge {
    text-align: right;
    direction: rtl;
}

/* Table number columns (ID, counts) should be RTL but numbers align right anyway */
.track-visits-rtl .data-table td:first-child,
.track-visits-rtl .data-table th:first-child {
    text-align: right !important;
}

/* Ensure table wrapper direction */
.track-visits-rtl .data-card {
    direction: rtl;
}

/* Table responsive wrapper RTL */
.track-visits-rtl .table-responsive {
    direction: rtl;
}

/* Table section RTL */
.track-visits-rtl .table-section {
    direction: rtl;
}

/* Any table containers RTL */
.track-visits-rtl .data-table-container {
    direction: rtl;
}

/* Pagination RTL */
.track-visits-rtl .pagination {
    direction: rtl;
}

.track-visits-rtl .pagination button {
    margin-left: 0;
    margin-right: 4px;
}

.track-visits-rtl .pagination button:last-child {
    margin-right: 0;
}

.track-visits-rtl .pagination-info {
    text-align: right;
}

/* Additional Table Content RTL Fixes */

/* Numeric content in tables (IDs, counts) - keep right aligned */
.track-visits-rtl .data-table td[data-type="number"],
.track-visits-rtl .data-table td.numeric {
    text-align: right !important;
    direction: ltr; /* Keep numbers LTR for readability */
}

/* Date/time content in tables */
.track-visits-rtl .data-table td.date-time,
.track-visits-rtl .data-table td[data-type="datetime"] {
    text-align: right !important;
    direction: ltr; /* Keep dates LTR for readability */
}

/* URL/link content in tables */
.track-visits-rtl .data-table td.url,
.track-visits-rtl .data-table td[data-type="url"] {
    text-align: right !important;
    direction: ltr; /* URLs typically LTR */
}

/* Force table headers to be consistently right-aligned */
.track-visits-rtl .data-table thead th {
    text-align: right !important;
}

/* Force table body cells to be consistently right-aligned */
.track-visits-rtl .data-table tbody td {
    text-align: right !important;
}

/* Dashboard Header RTL */
.track-visits-rtl .header {
    direction: rtl;
}

/* Status and Messages RTL */
.track-visits-rtl .status-badge,
.track-visits-rtl .status-text,
.track-visits-rtl .notice,
.track-visits-rtl .error-message {
    direction: rtl;
}

/* Dashboard Specific RTL Styles */
.track-visits-rtl .filters {
    direction: rtl !important;
}

.track-visits-rtl .filter-group {
    direction: rtl;
}

.track-visits-rtl .filter-input {
    text-align: right; /* Keep this for input fields */
}

/* Date inputs RTL styling */
.track-visits-rtl input[type="date"] {
    text-align: right;
    direction: ltr; /* Keep date format LTR but align right */
    padding-right: 40px;
    padding-left: 12px;
    position: relative; /* Ensure proper positioning context */
}

/* Date input calendar icon position for RTL - Fix positioning */
.track-visits-rtl input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute !important;
    left: auto !important;
    right: 10px !important; /* Position from the right edge */
    top: 50% !important;
    transform: translateY(-50%) !important;
    cursor: pointer;
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

/* Ensure date input container has proper positioning */
.track-visits-rtl .filter-group input[type="date"],
.track-visits-rtl .date-input-wrapper {
    position: relative !important;
}

/* Fix for any date inputs in forms or other containers */
.track-visits-rtl input[type="date"] {
    overflow: hidden !important; /* Prevent icon from escaping */
}

/* Additional specificity for stubborn calendar icons */
.track-visits-rtl .filters input[type="date"]::-webkit-calendar-picker-indicator,
.track-visits-rtl .filter-input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute !important;
    right: 10px !important;
    left: auto !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
}

/* Filter buttons in RTL */
.track-visits-rtl .filters .btn {
    display: inline-flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 6px;
}

/* Clean up filter actions for RTL */
.track-visits-rtl .filter-actions {
    direction: rtl;
}

/* Mobile RTL filter adjustments */
@media (max-width: 768px) {
    .track-visits-rtl .filters {
        direction: rtl;
    }
}

.track-visits-rtl .summary-cards {
    direction: rtl;
}

.track-visits-rtl .summary-card {
    direction: rtl;
}

.track-visits-rtl .summary-card h3,
.track-visits-rtl .summary-card .card-title {
    direction: rtl;
    text-align: right;
}

.track-visits-rtl .summary-card .card-value {
    direction: ltr; /* Keep numbers in LTR but inside RTL container */
    text-align: right;
}

.track-visits-rtl .chart-container {
    direction: rtl;
}

.track-visits-rtl .chart-header {
    direction: rtl;
}

/* Card Titles RTL */
.track-visits-rtl .chart-header h3,
.track-visits-rtl .summary-card h3,
.track-visits-rtl .card-title {
    direction: rtl;
    text-align: right;
}

/* Chart period/subtitle RTL */
.track-visits-rtl .chart-period,
.track-visits-rtl .chart-subtitle {
    direction: rtl;
    text-align: right;
}

.track-visits-rtl .meta-item {
    direction: rtl;
}

.track-visits-rtl .header-actions {
    direction: rtl;
}

.track-visits-rtl .live-controls {
    flex-direction: row-reverse;
}

.track-visits-rtl .control-group {
    justify-content: flex-end;
}

.track-visits-rtl .refresh-control {
    flex-direction: row-reverse;
}

.track-visits-rtl .status-group {
    justify-content: flex-start;
}

/* Responsive RTL Adjustments */
@media (max-width: 768px) {
    .track-visits-rtl .sidebar {
        right: -250px !important;
        left: auto !important;
    }
    
    .track-visits-rtl .sidebar.active {
        right: 0 !important;
        left: auto !important;
    }
    
    .track-visits-rtl .main-content {
        margin-right: 0 !important;
        margin-left: 0 !important;
    }
}

/* WordPress Admin RTL Compatibility */
.track-visits-rtl .wrap,
.track-visits-rtl .loading,
.track-visits-rtl .debug-info,
.track-visits-rtl .refresh-control {
    direction: rtl;
}



/* Hide WordPress Admin Bar on Dashboard */
.wp-stats-dashboard #wpadminbar {
    display: none !important;
}

.wp-stats-dashboard html {
    margin-top: 0 !important;
}

/* Arabic Font Support */
.track-visits-rtl {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

/* Improve Arabic text rendering */
.track-visits-rtl * {
    font-feature-settings: "liga" 1, "kern" 1;
    text-rendering: optimizeLegibility;
}

/* Button icon positioning for all buttons in RTL */
.track-visits-rtl .btn {
    direction: rtl;
}
