/* Import Google Fonts for Enhanced Arabic Support */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Tajwal:wght@200;300;400;500;700;800;900&display=swap');

/* Root Variables for Consistent Theming with Enhanced Arabic Fonts */
:root {
    --primary-color: #0073aa;
    --primary-hover: #005d87;
    --secondary-color: #d9534f;
    --secondary-hover: #c9302c;
    --warning-color: #f39c12;
    --warning-hover: #d68910;
    --success-color: #27ae60;
    --success-hover: #229954;
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
    --dark-gray: #6c757d;
    --border-color: #ddd;
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 10px rgba(0, 0, 0, 0.1);
    --shadow-heavy: 0 8px 25px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    
    /* Enhanced Font Stack with Tajwal and Cairo */
    --font-family: 'Tajwal', 'Cairo', 'Segoe UI', 'Tahoma', 'Geneva', 'Verdana', sans-serif;
    --font-family-secondary: 'Cairo', 'Tajwal', 'Segoe UI', 'Arial', sans-serif;
    --font-family-headers: 'Tajwal', 'Cairo', 'Arial Black', 'Helvetica', sans-serif;
}

/* Enhanced RTL Support for Arabic */
[dir="rtl"] {
    text-align: right;
    direction: rtl;
    font-family: var(--font-family);
}

[dir="rtl"] .tsl-form-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .tsl-button {
    margin-left: 10px;
    margin-right: 0;
}

/* Arabic Font Optimization */
:lang(ar) {
    font-family: var(--font-family);
    line-height: 1.6;
    letter-spacing: 0.02em;
}

/* Admin Wrapper Styling with Enhanced Typography */
.tsl-wrap {
    font-family: var(--font-family);
    max-width: 1200px;
    margin: 20px auto;
    padding: 30px;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    line-height: 1.5;
}

.tsl-wrap h1 {
    font-family: var(--font-family-headers);
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 30px;
    font-size: 28px;
    line-height: 1.3;
}

.tsl-wrap h2 {
    font-family: var(--font-family-headers);
    color: var(--primary-color);
    font-weight: 600;
    margin: 30px 0 20px 0;
    font-size: 22px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    line-height: 1.4;
}

.tsl-wrap h3 {
    font-family: var(--font-family-headers);
    color: var(--dark-gray);
    font-weight: 500;
    margin: 20px 0 15px 0;
    font-size: 18px;
    line-height: 1.4;
}

/* Statistics Dashboard with Enhanced Typography */
.tsl-stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.tsl-stat-card {
    background: linear-gradient(135deg, var(--primary-color), #0085c7);
    color: white;
    padding: 25px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-light);
    transition: transform 0.3s ease;
    font-family: var(--font-family);
}

.tsl-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.tsl-stat-card:nth-child(2) {
    background: linear-gradient(135deg, var(--success-color), #2ecc71);
}

.tsl-stat-card:nth-child(3) {
    background: linear-gradient(135deg, var(--warning-color), #f1c40f);
}

.tsl-stat-card:nth-child(4) {
    background: linear-gradient(135deg, var(--secondary-color), #e74c3c);
}

.tsl-stat-card h3 {
    font-family: var(--font-family-secondary);
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 10px 0;
    opacity: 0.95;
    line-height: 1.3;
}

.tsl-stat-number {
    font-family: var(--font-family-headers);
    font-size: 32px;
    font-weight: 800;
    display: block;
    line-height: 1.2;
}

/* Admin Sections with Enhanced Typography */
.tsl-admin-section {
    background: var(--light-gray);
    padding: 25px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
    font-family: var(--font-family);
}

/* Enhanced Form Styling with Arabic Typography */
.tsl-form {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    font-family: var(--font-family);
}

.tsl-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: end;
    margin-bottom: 15px;
}

.tsl-form-group {
    flex: 1;
    min-width: 200px;
}

.tsl-form-group label {
    display: block;
    margin-bottom: 8px;
    font-family: var(--font-family-secondary);
    font-weight: 600;
    color: var(--dark-gray);
    font-size: 14px;
    line-height: 1.4;
}

.tsl-form input[type="text"],
.tsl-form input[type="datetime-local"],
.tsl-form input[type="file"],
.tsl-form input[type="search"],
.tsl-form select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: var(--font-family);
    line-height: 1.5;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: white;
}

.tsl-form input:focus,
.tsl-form select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.tsl-form input.error {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.1);
}

.tsl-form input.valid {
    border-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
}

.tsl-form small {
    display: block;
    margin-top: 5px;
    color: var(--dark-gray);
    font-size: 12px;
    font-family: var(--font-family-secondary);
    line-height: 1.4;
}

/* Enhanced Button Styling with Arabic Typography */
.tsl-button {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-family-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    min-width: 120px;
    position: relative;
    overflow: hidden;
    line-height: 1.2;
}

.tsl-button:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.tsl-button:hover:before {
    left: 100%;
}

.tsl-button-primary {
    background: var(--primary-color);
    color: white;
    border: 2px solid var(--primary-color);
}

.tsl-button-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

.tsl-button-secondary {
    background: var(--secondary-color);
    color: white;
    border: 2px solid var(--secondary-color);
}

.tsl-button-secondary:hover {
    background: var(--secondary-hover);
    border-color: var(--secondary-hover);
    transform: translateY(-1px);
}

.tsl-button-warning {
    background: var(--warning-color);
    color: white;
    border: 2px solid var(--warning-color);
}

.tsl-button-warning:hover {
    background: var(--warning-hover);
    border-color: var(--warning-hover);
}

.tsl-button-danger {
    background: var(--secondary-color);
    color: white;
    border: 2px solid var(--secondary-color);
}

.tsl-button-danger:hover {
    background: var(--secondary-hover);
    border-color: var(--secondary-hover);
}

.tsl-button-small {
    padding: 8px 16px;
    font-size: 12px;
    min-width: 80px;
}

.tsl-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.tsl-button-link {
    background: none;
    border: none;
    color: var(--primary-color);
    padding: 5px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.3s ease;
    font-family: var(--font-family);
}

.tsl-button-link:hover {
    background-color: var(--light-gray);
}

/* Enhanced Search Box */
.tsl-search-box {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    font-family: var(--font-family);
}

.tsl-search-box form {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.tsl-search-box input[type="search"] {
    flex: 1;
    min-width: 300px;
    font-family: var(--font-family);
}

/* Enhanced Table Styling with Arabic Typography */
.tsl-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    font-family: var(--font-family);
}

.tsl-table th {
    background: var(--primary-color);
    color: white;
    padding: 15px 12px;
    text-align: right;
    font-weight: 700;
    font-size: 14px;
    font-family: var(--font-family-headers);
    border-bottom: 2px solid var(--primary-hover);
    line-height: 1.3;
}

.tsl-table td {
    padding: 15px 12px;
    text-align: right;
    border-bottom: 1px solid var(--medium-gray);
    vertical-align: middle;
    font-family: var(--font-family);
    line-height: 1.4;
}

.tsl-table tr:hover {
    background-color: var(--light-gray);
}

.tsl-table tr.expired {
    background-color: #ffeaea;
}

.tsl-table tr.registered {
    background-color: #eafaf1;
}

.tsl-table tr.pending {
    background-color: #fff8e1;
}

.tsl-table .no-items td {
    text-align: center;
    padding: 40px;
    color: var(--dark-gray);
    font-style: italic;
    font-family: var(--font-family-secondary);
    font-size: 16px;
}

/* Code Display with Better Typography */
.tsl-code {
    background: var(--light-gray);
    padding: 5px 10px;
    border-radius: 4px;
    font-family: 'Courier New', 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    border: 1px solid var(--border-color);
    display: inline-block;
    margin-left: 5px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.code-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Enhanced Status Badges with Arabic Typography */
.device-registered {
    background: var(--success-color);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-family-secondary);
}

.device-pending {
    background: var(--warning-color);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-family-secondary);
}

.expired-badge {
    background: var(--secondary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    margin-right: 5px;
    font-family: var(--font-family-secondary);
}

.device-info {
    margin-top: 5px;
}

.device-info small {
    color: var(--dark-gray);
    font-size: 11px;
    font-family: var(--font-family-secondary);
    line-height: 1.3;
}

/* Action Buttons in Table */
.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Enhanced Frontend Login Form with Arabic Typography */
.tsl-login-form {
    font-family: var(--font-family);
    max-width: 450px;
    margin: 40px auto;
    padding: 40px 30px;
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-heavy);
    border: 1px solid var(--border-color);
    line-height: 1.5;
}

.tsl-login-form h2 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 24px;
    font-family: var(--font-family-headers);
    font-weight: 700;
    line-height: 1.3;
}

.tsl-form-group {
    margin-bottom: 20px;
}

.tsl-form-group label {
    font-family: var(--font-family-secondary);
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 8px;
    display: block;
    font-size: 14px;
}

.tsl-login-form input[type="text"] {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-family: var(--font-family);
    transition: all 0.3s ease;
    box-sizing: border-box;
    line-height: 1.4;
}

.tsl-login-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.tsl-login-form .tsl-button {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 700;
    margin-top: 10px;
    font-family: var(--font-family-headers);
}

.tsl-login-form .button-loader {
    display: inline-block;
    margin-right: 10px;
}

/* Enhanced Info Box */
.tsl-info {
    background: #e8f4fd;
    border: 1px solid #bee5eb;
    border-radius: var(--border-radius);
    padding: 15px;
    margin-top: 20px;
    font-family: var(--font-family);
}

.tsl-info p {
    margin: 0;
    color: #0c5460;
    font-size: 14px;
    text-align: center;
    line-height: 1.5;
    font-family: var(--font-family-secondary);
}

/* Enhanced Error and Success Messages */
.tsl-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin: 15px 0;
    font-size: 14px;
    text-align: center;
    font-family: var(--font-family);
    line-height: 1.4;
    font-weight: 500;
}

.tsl-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    padding: 12px 15px;
    border-radius: var(--border-radius);
    margin: 15px 0;
    font-size: 14px;
    text-align: center;
    font-family: var(--font-family);
    line-height: 1.4;
    font-weight: 500;
    position: relative;
}

.tsl-success .dashicons {
    margin-right: 5px;
    vertical-align: middle;
}

.tsl-success .notice-dismiss {
    position: absolute;
    top: 8px;
    right: 15px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #155724;
    font-weight: bold;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Enhanced Loading Animation */
.button-loader:after {
    content: " ";
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced Pagination with Arabic Typography */
.tablenav-pages {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    font-family: var(--font-family);
}

.tablenav-pages .button {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    font-family: var(--font-family-secondary);
}

.tablenav-pages .button:hover {
    background: var(--light-gray);
}

.current-page-selector {
    width: 50px !important;
    padding: 6px !important;
    text-align: center;
    font-family: var(--font-family);
}

.displaying-num {
    font-family: var(--font-family-secondary);
    font-weight: 500;
}

/* Enhanced Bulk Actions */
.tablenav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    padding: 10px 0;
    font-family: var(--font-family);
}

.alignleft {
    display: flex;
    align-items: center;
    gap: 10px;
}

.alignleft.actions.has-selection {
    background: #e8f4fd;
    padding: 10px 15px;
    border-radius: var(--border-radius);
    border: 1px solid #b8daff;
}

/* Checkbox Styling */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.check-column {
    width: 50px;
    text-align: center;
}

/* Copy Code Enhancement */
.copy-code {
    cursor: pointer;
    font-size: 16px;
    margin-right: 5px;
    opacity: 0.7;
    transition: all 0.3s ease;
    padding: 2px 4px;
    border-radius: 3px;
}

.copy-code:hover {
    opacity: 1;
    background-color: var(--light-gray);
}

/* Enhanced Responsive Design */
@media (max-width: 768px) {
    .tsl-wrap {
        margin: 10px;
        padding: 20px 15px;
    }
    
    .tsl-stats-dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .tsl-form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .tsl-form-group {
        min-width: auto;
    }
    
    .tsl-table {
        font-size: 12px;
    }
    
    .tsl-table th,
    .tsl-table td {
        padding: 10px 8px;
    }
    
    .row-actions {
        flex-direction: column;
        gap: 5px;
    }
    
    .tsl-button-small {
        width: 100%;
        margin-bottom: 5px;
    }
    
    .tsl-search-box form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .tsl-search-box input[type="search"] {
        min-width: auto;
        margin-bottom: 10px;
    }
    
    .tablenav {
        flex-direction: column;
        gap: 15px;
    }
    
    /* Enhanced mobile typography */
    .tsl-wrap h1 {
        font-size: 24px;
    }
    
    .tsl-wrap h2 {
        font-size: 20px;
    }
    
    .tsl-stat-number {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .tsl-stats-dashboard {
        grid-template-columns: 1fr;
    }
    
    .tsl-login-form {
        margin: 20px 10px;
        padding: 30px 20px;
    }
    
    .tsl-login-form h2 {
        font-size: 20px;
    }
    
    /* Hide less important columns on mobile */
    .tsl-table .hide-mobile {
        display: none;
    }
    
    .tsl-stat-number {
        font-size: 24px;
    }
}

/* Print Styles */
@media print {
    .tsl-wrap {
        box-shadow: none;
        border: 1px solid #000;
        font-family: var(--font-family);
    }
    
    .tsl-button,
    .row-actions {
        display: none;
    }
    
    .tsl-table {
        box-shadow: none;
    }
}

/* Enhanced Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .tsl-wrap {
        background: #2c3e50;
        color: #ecf0f1;
    }
    
    .tsl-form input,
    .tsl-form select {
        background: #34495e;
        color: #ecf0f1;
        border-color: #5d6d7e;
    }
    
    .tsl-table {
        background: #34495e;
    }
    
    .tsl-table tr:hover {
        background-color: #3e4651;
    }
    
    .tsl-code {
        background: #34495e;
        color: #ecf0f1;
        border-color: #5d6d7e;
    }
}

/* Custom Scrollbar */
.tsl-wrap ::-webkit-scrollbar {
    width: 8px;
}

.tsl-wrap ::-webkit-scrollbar-track {
    background: var(--light-gray);
    border-radius: 4px;
}

.tsl-wrap ::-webkit-scrollbar-thumb {
    background: var(--dark-gray);
    border-radius: 4px;
}

.tsl-wrap ::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Enhanced Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.tsl-admin-section,
.tsl-search-box,
.tsl-table {
    animation: fadeIn 0.3s ease-out;
}

.tsl-success {
    animation: slideInRight 0.3s ease-out;
}

/* Enhanced Focus Indicators for Accessibility */
.tsl-button:focus,
.tsl-form input:focus,
.tsl-form select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .tsl-button {
        border-width: 3px;
    }
    
    .tsl-table th,
    .tsl-table td {
        border: 1px solid #000;
    }
    
    .tsl-code {
        border: 2px solid #000;
    }
}



/* Arabic Text Enhancement */
.arabic-text,
[lang="ar"] {
    font-family: var(--font-family);
    font-feature-settings: 'liga' 1, 'kern' 1, 'calt' 1;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Enhanced Typography Scale */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }

/* Font Weight Utilities */
.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.font-black { font-weight: 900; }
