/* =====================================================
   Social Automation - Arabic RTL Stylesheet
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

body {
    font-family: 'Cairo', 'Segoe UI', system-ui, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.7;
    min-height: 100vh;
    direction: rtl;
    text-align: right;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* --- Auth Pages --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.auth-card .logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-card .logo h1 {
    font-size: 24px;
    color: var(--gray-800);
    font-weight: 700;
}

.auth-card .logo p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

.auth-card h2 {
    font-size: 20px;
    margin-bottom: 24px;
    text-align: center;
    color: var(--gray-700);
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--gray-800);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: 'Cairo', sans-serif;
    direction: rtl;
    text-align: right;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: left 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
    padding-right: 14px;
    padding-left: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: 'Cairo', sans-serif;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover {
    background: #059669;
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* --- Layout --- */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--gray-900);
    color: #fff;
    padding: 0;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-header p {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 16px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--gray-300);
    font-size: 14px;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border-right-color: var(--primary-light);
}

.sidebar-nav .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-400);
    font-size: 13px;
}

.sidebar-footer a:hover {
    color: #fff;
    text-decoration: none;
}

.main-content {
    flex: 1;
    margin-right: 260px;
    margin-left: 0;
    padding: 24px 32px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.page-header p {
    color: var(--gray-500);
    font-size: 14px;
    margin-top: 4px;
}

/* --- Cards --- */
.card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 20px;
}

/* --- Stats Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: box-shadow 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.stat-card .stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-card .stat-icon.green { background: #d1fae5; color: #059669; }
.stat-card .stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-card .stat-icon.orange { background: #fed7aa; color: #ea580c; }
.stat-card .stat-icon.red { background: #fee2e2; color: #dc2626; }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 10px 14px;
    text-align: right;
    font-size: 14px;
}

table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

table td {
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

table tr:hover td {
    background: var(--gray-50);
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* --- Pagination --- */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    direction: rtl;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}

.pagination a:hover {
    background: var(--gray-50);
    text-decoration: none;
}

.pagination .active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* --- Toolbar --- */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    direction: rtl;
}

.toolbar .form-control {
    width: auto;
    min-width: 160px;
}

/* --- Toggle Switch --- */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--gray-300);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle .slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    right: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .slider {
    background: var(--primary);
}

.toggle input:checked + .slider::before {
    transform: translateX(-20px);
}

/* --- Progress Bar --- */
.progress {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 0.3s;
}

.progress-bar.success { background: var(--success); }
.progress-bar.danger { background: var(--danger); }

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    direction: rtl;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-start;
    gap: 8px;
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-500);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--gray-700);
    margin-bottom: 8px;
}

/* --- Steps --- */
.steps {
    display: flex;
    gap: 0;
    margin-bottom: 32px;
}

.step {
    flex: 1;
    text-align: center;
    padding: 12px;
    position: relative;
    font-size: 14px;
    color: var(--gray-400);
}

.step.active {
    color: var(--primary);
    font-weight: 600;
}

.step .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-500);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-bottom: 8px;
}

.step.active .step-number {
    background: var(--primary);
    color: #fff;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .main-content {
        margin-right: 0;
        padding: 16px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Code / LTR elements --- */
code, pre, .ltr {
    direction: ltr;
    text-align: left;
}

/* --- Facebook/Instagram button colors --- */
.btn-facebook {
    background: #1877f2;
    color: #fff;
    border: none;
}
.btn-facebook:hover {
    background: #166fe5;
    color: #fff;
}

.btn-instagram {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: #fff;
    border: none;
}
.btn-instagram:hover {
    opacity: 0.9;
    color: #fff;
}
