:root {
  --primary: #4361ee;
  --primary-dark: #3a54e0;
  --success: #06d6a0;
  --danger: #ef4747;
  --warning: #ffa94d;
  --dark: #1a1a2e;
  --light: #f8f9fa;
  --gray: #6c757d;
  --border: #e0e0e0;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 30px rgba(0,0,0,0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', 'Arial', sans-serif;
  color: var(--dark);
  line-height: 1.6;
  background: #f5f7fa;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ========== صفحة الدخول ========== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  font-family: 'Segoe UI', sans-serif;
}

.lang-switcher {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.lang-btn {
  padding: 8px 14px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
  color: var(--dark);
}

.lang-btn:hover {
  background: var(--light);
}

.lang-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  text-align: center;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.logo {
  margin-bottom: 30px;
}

.logo i {
  font-size: 56px;
  color: var(--primary);
  margin-bottom: 16px;
  display: block;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.logo h2 {
  font-weight: 700;
  font-size: 32px;
  color: var(--dark);
  margin: 12px 0 4px;
}

.logo p {
  color: var(--gray);
  font-size: 14px;
}

.input-group {
  margin-bottom: 20px;
  text-align: right;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--dark);
  text-align: right;
  font-size: 14px;
}

input, select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  direction: rtl;
  text-align: right;
  transition: all 0.3s ease;
  background: #f8f9fa;
}

input:focus, select:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #2d3fb8 100%);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--dark);
}

.btn-outline:hover {
  background: var(--light);
  border-color: var(--primary);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  width: auto;
}

.toggle-link {
  color: var(--primary);
  text-decoration: none;
  margin-top: 16px;
  display: inline-block;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.toggle-link:hover {
  text-decoration: underline;
  color: var(--primary-dark);
}

.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin-top: 12px;
  min-height: 20px;
  text-align: center;
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.hidden {
  display: none !important;
}

/* ========== لوحة التحكم ========== */
.dashboard-page {
  background: #f5f7fa;
  min-height: 100vh;
  padding-bottom: 40px;
}

header {
  background: linear-gradient(135deg, var(--dark) 0%, #2d2d4a 100%);
  color: white;
  padding: 18px 0;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 40;
}

header .logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

header .logo i {
  font-size: 32px;
}

header .logo h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
}

.user-dropdown {
  position: relative;
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  cursor: pointer;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.dropdown-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  margin-top: 12px;
  z-index: 100;
  animation: slideDown 0.3s ease;
  overflow: hidden;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-menu a {
  display: block;
  padding: 14px 18px;
  color: var(--dark);
  text-decoration: none;
  transition: all 0.2s;
  border-right: 3px solid transparent;
}

.dropdown-menu a:hover {
  background: var(--light);
  border-right-color: var(--primary);
  padding-right: 15px;
}

.card {
  background: white;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, var(--light) 0%, #f0f2f8 100%);
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--dark);
}

.card-body {
  padding: 28px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}

.summary-card {
  background: white;
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all 0.3s ease;
  border-left: 4px solid transparent;
}

.summary-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}

.summary-card.income {
  border-left-color: var(--primary);
}

.summary-card.expense {
  border-left-color: var(--danger);
}

.summary-card.balance {
  border-left-color: var(--success);
}

.summary-card .icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  flex-shrink: 0;
}

.income .icon { 
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.expense .icon { 
  background: linear-gradient(135deg, var(--danger) 0%, #d43333 100%);
}

.balance .icon { 
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.summary-card .info .value {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--dark);
}

.summary-card .info .label {
  color: var(--gray);
  font-size: 0.95rem;
}

.export-actions {
  display: flex;
  gap: 8px;
}

.analysis-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

@media (max-width: 900px) {
  .analysis-section { 
    grid-template-columns: 1fr;
  }
}

.pie-container, .trend-container {
  background: #f9fafb;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.pie-container h4, .trend-container h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--dark);
}

/* ========== الاتجاه الأسبوعي ========== */
.trend-line {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 10px;
  height: 240px;
  padding: 20px 10px 0;
}

.day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 50px;
}

.day span:first-child {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  margin-top: 8px;
}

.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 4px 4px 0 0;
  transition: all 0.4s ease;
  min-height: 6px;
  box-shadow: 0 2px 4px rgba(67, 97, 238, 0.2);
}

.bar:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 8px rgba(67, 97, 238, 0.3);
}

/* ========== جدول المعاملات ========== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 600px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.transaction-table {
  width: 100%;
  border-collapse: collapse;
}

.transaction-table th,
.transaction-table td {
  padding: 14px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.transaction-table th {
  background: linear-gradient(135deg, var(--light) 0%, #f0f2f8 100%);
  font-weight: 700;
  color: var(--dark);
  font-size: 14px;
}

.transaction-table tbody tr {
  transition: all 0.2s ease;
}

.transaction-table tbody tr:hover {
  background: #f9fafb;
}

.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge-income { 
  background: #d1fadb; 
  color: #059669;
}

.badge-expense { 
  background: #fee2e2; 
  color: #dc2626;
}

/* ========== Utilities ========== */
.mt-4 { margin-top: 2rem; }
.mb-4 { margin-bottom: 2rem; }
.w-100 { width: 100%; }
.ml-2 { margin-left: 8px; }
.bold { font-weight: 700; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .login-card {
    padding: 30px 24px;
    max-width: 100%;
  }

  .summary-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .card-body {
    padding: 20px;
  }

  header .logo h1 {
    display: none;
  }

  .dropdown-toggle span {
    display: none;
  }

  .transaction-table {
    font-size: 13px;
  }

  .transaction-table th,
  .transaction-table td {
    padding: 10px 8px;
  }
}

@media (max-width: 480px) {
  .login-page {
    padding: 16px;
  }

  .login-card {
    padding: 24px;
  }

  .lang-switcher {
    top: 12px;
    right: 12px;
  }

  .lang-btn {
    padding: 6px 10px;
    font-size: 12px;
  }

  .logo i {
    font-size: 40px;
  }

  .logo h2 {
    font-size: 24px;
  }

  header .container {
    flex-direction: column;
    gap: 10px;
  }

  .export-actions {
    flex-direction: column;
    width: 100%;
  }

  .export-actions .btn {
    width: 100%;
  }

  .trend-line {
    gap: 6px;
  }

  .day span:first-child {
    font-size: 11px;
  }
}
