:root {
  --navy: #1e3a5f;
  --gold: #c9a227;
  --bg: #0b1120;
  --card: #111827;
  --border: #1f2d3d;
  --text: #e2e8f0;
  --muted: #64748b;
  --success: #22c55e;
  --error: #ef4444;
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --navbar-height: 64px;
  --transition: 0.3s ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Cairo', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

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

a:hover {
  color: #d4af37;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  transition: var(--transition);
}

input, textarea, select {
  font-family: inherit;
  outline: none;
}

ul, ol {
  list-style: none;
}

.app-container {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-right: var(--sidebar-width);
  margin-left: 0;
  transition: var(--transition);
}

[dir="ltr"] .main-content {
  margin-left: var(--sidebar-width);
  margin-right: 0;
}

.sidebar.collapsed + .main-content {
  margin-right: var(--sidebar-collapsed);
}

[dir="ltr"] .sidebar.collapsed + .main-content {
  margin-left: var(--sidebar-collapsed);
  margin-right: 0;
}

@media (max-width: 768px) {
  .main-content {
    margin-right: 0;
  }
  
  [dir="ltr"] .main-content {
    margin-left: 0;
  }
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 100;
  overflow-y: auto;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--navbar-height);
}

.sidebar-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  transition: var(--transition);
}

.sidebar.collapsed .sidebar-title {
  display: none;
}

.sidebar.collapsed .sidebar-logo {
  justify-content: center;
}

.sidebar-logo svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.sidebar-toggle {
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background: var(--border);
  color: var(--text);
}

.sidebar.collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.sidebar-nav ul {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--navy);
  color: var(--text);
}

.sidebar-nav a.active {
  border-left: 3px solid var(--gold);
}

.sidebar-nav svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-nav a span {
  display: none;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: var(--border);
  color: var(--muted);
  border-radius: 8px;
  font-size: 0.875rem;
}

.sidebar-toggle-btn:hover {
  background: var(--navy);
  color: var(--text);
}

.sidebar.collapsed .sidebar-toggle-btn .toggle-text {
  display: none;
}

.sidebar.collapsed .sidebar-toggle-btn .toggle-icon {
  transform: rotate(180deg);
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  height: var(--navbar-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--gold);
}

.brand-icon {
  font-size: 1.5rem;
}

.brand-text {
  font-size: 1.125rem;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lang-select {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.875rem;
  cursor: pointer;
}

.lang-select:hover {
  border-color: var(--gold);
  color: var(--text);
}

.auth-buttons {
  display: flex;
  gap: 10px;
}

.btn-outline {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
}

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .auth-buttons {
    display: none;
  }
}

.user-menu:hover {
  background: var(--border);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-weight: 600;
  font-size: 0.875rem;
}

.user-name {
  font-weight: 500;
  color: var(--text);
}

.page-content {
  padding: 24px;
  flex: 1;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

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

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  transition: var(--transition);
}

.btn-primary {
  background: var(--navy);
  color: var(--text);
}

.btn-primary:hover {
  background: #2a4a73;
}

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

.btn-secondary:hover {
  background: #2a3a4d;
}

.btn-gold {
  background: var(--gold);
  color: #0b1120;
}

.btn-gold:hover {
  background: #d4af37;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

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

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.05);
}

.drop-zone-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--muted);
}

.drop-zone-text {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 8px;
}

.drop-zone-hint {
  font-size: 0.875rem;
  color: var(--muted);
}

.progress-container {
  margin: 16px 0;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy), var(--gold), var(--navy));
  background-size: 200% 100%;
  animation: progress-gradient 2s linear infinite;
  border-radius: 4px;
  transition: width 0.3s ease;
}

@keyframes progress-gradient {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

.progress-text {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.terminal {
  background: #0a0f1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.875rem;
  overflow: hidden;
}

.terminal-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.terminal-dot.red { background: #ff5f56; }
.terminal-dot.yellow { background: #ffbd2e; }
.terminal-dot.green { background: #27c93f; }

.terminal-title {
  margin-left: 12px;
  color: var(--muted);
  font-size: 0.75rem;
}

.terminal-body {
  padding: 16px;
  max-height: 300px;
  overflow-y: auto;
}

.terminal-line {
  margin-bottom: 4px;
  line-height: 1.8;
}

.terminal-prompt {
  color: var(--success);
  margin-right: 8px;
}

.terminal-command {
  color: var(--text);
}

.terminal-output {
  color: var(--muted);
  padding-left: 16px;
}

.terminal-error {
  color: var(--error);
}

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

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

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.875rem;
  transition: var(--transition);
}

.form-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.1);
}

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

.form-input.error {
  border-color: var(--error);
}

.form-error {
  color: var(--error);
  font-size: 0.75rem;
  margin-top: 4px;
}

.form-hint {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--card);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

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

.table tbody tr:hover {
  background: rgba(30, 58, 95, 0.3);
}

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

.file-icon {
  width: 40px;
  height: 40px;
  background: var(--navy);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

.file-name {
  font-weight: 600;
  color: var(--text);
}

.file-meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 500px;
  transform: scale(0.9);
  transition: var(--transition);
}

.modal-overlay.open .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-body {
  margin-bottom: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  animation: toast-slide-in 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@keyframes toast-slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-warning .toast-icon { color: var(--gold); }
.toast-info .toast-icon { color: var(--navy); }

.toast-message {
  flex: 1;
  color: var(--text);
  font-size: 0.875rem;
}

.toast-close {
  background: transparent;
  color: var(--muted);
  padding: 4px;
}

.toast-close:hover {
  color: var(--text);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.spinner-lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 32, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.loading-dots {
  display: flex;
  gap: 8px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-12px); }
}

.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--card) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  background: var(--navy);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
}

.stat-info {
  flex: 1;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.badge-warning {
  background: rgba(201, 162, 39, 0.15);
  color: var(--gold);
}

.badge-info {
  background: rgba(30, 58, 95, 0.3);
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

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

:root[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
}

:root[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

:root[dir="rtl"] .sidebar.collapsed + .main-content {
  margin-right: var(--sidebar-collapsed);
}

:root[dir="rtl"] .sidebar-toggle {
  transform: rotate(180deg);
}

:root[dir="rtl"] .sidebar.collapsed .sidebar-toggle {
  transform: rotate(0deg);
}

:root[dir="rtl"] .sidebar-nav a.active {
  border-left: none;
  border-right: 3px solid var(--gold);
}

:root[dir="rtl"] .toast-container {
  right: auto;
  left: 24px;
}

@keyframes toast-slide-in-rtl {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

:root[dir="rtl"] .toast {
  animation: toast-slide-in-rtl 0.3s ease;
}

:root[dir="rtl"] .modal {
  text-align: right;
}

:root[dir="rtl"] .table th,
:root[dir="rtl"] .table td {
  text-align: right;
}

@media (max-width: 768px) {
  :root[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }
  
  :root[dir="rtl"] .sidebar.open {
    transform: translateX(0);
  }
  
  :root[dir="rtl"] .main-content {
    margin-right: 0;
  }
  
  .page-content {
    padding: 16px;
  }
  
  .card {
    padding: 16px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr;
  }
}