/* ================================================
   تطبيق متتبع الأسهم - ثندر
   الأنماط الرئيسية
   ================================================ */

/* --- المتغيرات --- */
:root {
    --primary: #1a2332;
    --primary-light: #243447;
    --primary-lighter: #2d4258;
    --accent: #2d8cf0;
    --accent-hover: #1a73e8;
    --accent-glow: rgba(45, 140, 240, 0.15);
    --profit: #00c853;
    --profit-bg: rgba(0, 200, 83, 0.1);
    --loss: #ff1744;
    --loss-bg: rgba(255, 23, 68, 0.1);
    --warning: #f5a623;
    --warning-bg: rgba(245, 166, 35, 0.1);
    --purification: #9c27b0;
    --purification-bg: rgba(156, 39, 176, 0.1);
    --bg-page: #f0f2f5;
    --bg-card: #ffffff;
    --bg-input: #f8f9fb;
    --border: #e0e4ea;
    --border-light: #eef1f5;
    --text-primary: #1a2332;
    --text-secondary: #5f6b7a;
    --text-muted: #8e99a9;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --sidebar-width: 250px;
    --header-height: 64px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- إعادة ضبط --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    background-color: var(--bg-page);
    direction: rtl;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: var(--accent);
    transition: var(--transition);
}

a:hover {
    color: var(--accent-hover);
}

/* --- الرأس العلوي --- */
.top-header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 18px;
}

.logo:hover {
    color: #fff;
    opacity: 0.9;
}

.logo-icon {
    font-size: 26px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

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

.user-name {
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    font-weight: 500;
}

.btn-logout {
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

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

/* زر القائمة للجوال */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    flex-direction: column;
    gap: 5px;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: var(--transition);
}

/* --- القائمة الجانبية --- */
.sidebar {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-left: 1px solid var(--border-light);
    overflow-y: auto;
    z-index: 900;
    transition: var(--transition);
    box-shadow: -2px 0 8px rgba(0,0,0,0.03);
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: var(--transition);
    position: relative;
    border-radius: 0;
}

.nav-item::before {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    transition: var(--transition);
}

.nav-item:hover {
    color: var(--accent);
    background: var(--accent-glow);
}

.nav-item.active {
    color: var(--accent);
    background: var(--accent-glow);
    font-weight: 700;
}

.nav-item.active::before {
    height: 70%;
}

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

.nav-divider {
    height: 1px;
    background: var(--border-light);
    margin: 12px 20px;
}

/* --- المحتوى الرئيسي --- */
.main-content {
    margin-right: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding: 28px;
}

.content-wrapper {
    max-width: 1400px;
    margin: 0 auto;
}

/* --- عنوان الصفحة --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title .icon {
    font-size: 28px;
}

/* --- البطاقات --- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    border: 1px solid var(--border-light);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 4px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card.card-primary::before { background: linear-gradient(90deg, var(--accent), #60a5fa); }
.stat-card.card-profit::before { background: linear-gradient(90deg, var(--profit), #69f0ae); }
.stat-card.card-loss::before { background: linear-gradient(90deg, var(--loss), #ff6e40); }
.stat-card.card-warning::before { background: linear-gradient(90deg, var(--warning), #ffd54f); }
.stat-card.card-purification::before { background: linear-gradient(90deg, var(--purification), #ce93d8); }
.stat-card.card-info::before { background: linear-gradient(90deg, #00bcd4, #4dd0e1); }

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.stat-card-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-card-icon {
    font-size: 28px;
    opacity: 0.8;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.stat-card-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* --- البطاقات/الصناديق --- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-input);
}

.card-header h2 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 24px;
}

/* --- الجداول --- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

table thead th {
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    padding: 14px 16px;
    text-align: right;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
}

table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    vertical-align: middle;
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: var(--accent-glow);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* --- النماذج --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group label .required {
    color: var(--loss);
    margin-right: 2px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-family: 'Tajawal', sans-serif;
    font-size: 15px;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    direction: rtl;
}

.form-control:focus {
    border-color: var(--accent);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235f6b7a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 16px center;
    padding-left: 40px;
}

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

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

/* --- حقل محسوب (للقراءة فقط) --- */
.computed-field {
    background: linear-gradient(135deg, var(--accent-glow), transparent);
    border: 2px dashed var(--accent);
    font-weight: 700;
    color: var(--accent);
}

/* --- الأزرار --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: 'Tajawal', sans-serif;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
    box-shadow: 0 4px 12px rgba(45, 140, 240, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #1565c0);
    color: #fff;
    box-shadow: 0 6px 16px rgba(45, 140, 240, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--profit), #00a844);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 200, 83, 0.3);
}

.btn-success:hover {
    color: #fff;
    box-shadow: 0 6px 16px rgba(0, 200, 83, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--loss), #d50000);
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 23, 68, 0.3);
}

.btn-danger:hover {
    color: #fff;
    box-shadow: 0 6px 16px rgba(255, 23, 68, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
}

/* --- التنبيهات --- */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease;
}

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

.alert-success {
    background: var(--profit-bg);
    color: #1b5e20;
    border: 1px solid rgba(0, 200, 83, 0.3);
}

.alert-success::before {
    content: '✅';
}

.alert-danger {
    background: var(--loss-bg);
    color: #b71c1c;
    border: 1px solid rgba(255, 23, 68, 0.3);
}

.alert-danger::before {
    content: '❌';
}

.alert-warning {
    background: var(--warning-bg);
    color: #e65100;
    border: 1px solid rgba(245, 166, 35, 0.3);
}

.alert-warning::before {
    content: '⚠️';
}

.alert-info {
    background: rgba(0, 188, 212, 0.08);
    color: #006064;
    border: 1px solid rgba(0, 188, 212, 0.3);
}

.alert-info::before {
    content: 'ℹ️';
}

/* --- ألوان الربح والخسارة --- */
.text-profit {
    color: var(--profit) !important;
    font-weight: 700;
}

.text-loss {
    color: var(--loss) !important;
    font-weight: 700;
}

.text-warning {
    color: var(--warning) !important;
}

.text-purification {
    color: var(--purification) !important;
    font-weight: 700;
}

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

/* --- شارة (Badge) --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 50px;
    white-space: nowrap;
}

.badge-deposit {
    background: var(--profit-bg);
    color: var(--profit);
}

.badge-withdrawal {
    background: var(--loss-bg);
    color: var(--loss);
}

.badge-profit {
    background: var(--profit-bg);
    color: var(--profit);
}

.badge-dividend {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-capital {
    background: rgba(45, 140, 240, 0.1);
    color: var(--accent);
}

/* --- صفحة تسجيل الدخول --- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #1a3a5c 50%, #0d2137 100%);
    padding: 20px;
}

.login-container {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.5s ease;
}

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

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-header .login-icon {
    font-size: 52px;
    margin-bottom: 16px;
    display: block;
}

.login-header h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* --- الذيل --- */
.main-footer {
    margin-right: var(--sidebar-width);
    padding: 20px 28px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-card);
}

/* --- الأوفرلاي --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 850;
    backdrop-filter: blur(2px);
}

/* --- حالة فارغة --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 60px;
    margin-bottom: 16px;
    opacity: 0.5;
}

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

.empty-state p {
    font-size: 14px;
    margin-bottom: 20px;
}

/* --- مجموعة أزرار الإجراءات --- */
.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* --- تقرير الملخص --- */
.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.summary-value {
    font-weight: 700;
    font-size: 16px;
}

/* --- فلتر التقارير --- */
.filter-bar {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 20px 24px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
}

.filter-bar .form-group {
    margin-bottom: 0;
    min-width: 180px;
}

/* --- تصميم متقدم للجدول --- */
.table-total-row td {
    font-weight: 700;
    background: var(--bg-input);
    border-top: 2px solid var(--border);
}

/* --- لوحة التحكم --- */
.dashboard-section {
    margin-bottom: 32px;
}

.dashboard-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- الحركة والتحريك --- */
.fade-in {
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Tooltip --- */
[title] {
    position: relative;
}

/* --- سكرول بار مخصص --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- تأكيد الحذف --- */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.confirm-dialog.active {
    display: flex;
}

.confirm-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
}

.confirm-box h3 {
    margin-bottom: 12px;
    font-size: 18px;
}

.confirm-box p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* --- تبويبات --- */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 24px;
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 20px;
    font-family: 'Tajawal', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: 0;
    left: 0;
    height: 2px;
    background: transparent;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--accent);
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active::after {
    background: var(--accent);
}

.tab-content {
    display: none;
}

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

/* --- مساعدات --- */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.d-flex { display: flex; }
.gap-2 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.w-100 { width: 100%; }
.fw-bold { font-weight: 700; }
