/* =============================================
   الأنماط العامة - اتجاه RTL عربي
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;900&display=swap');

:root {
  --primary:      #1a56db;
  --primary-dark: #1e429f;
  --accent:       #0ea5e9;
  --success:      #0d9488;
  --danger:       #dc2626;
  --warning:      #d97706;
  --bg:           #f1f5f9;
  --surface:      #ffffff;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --radius:       12px;
  --shadow:       0 4px 24px rgba(0,0,0,.08);
  --shadow-lg:    0 8px 40px rgba(0,0,0,.13);
  --transition:   .22s cubic-bezier(.4,0,.2,1);
}

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

body {
  font-family: 'Cairo', Arial, sans-serif;
  direction: rtl;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.7;
}

/* ---- Topbar ---- */
.topbar {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--accent) 100%);
  padding: 0 2rem;
  box-shadow: 0 2px 16px rgba(30,66,159,.25);
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  max-width: 1100px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: flex; align-items: center; gap: .6rem;
  color: #fff; text-decoration: none;
  font-size: 1.25rem; font-weight: 700;
}
.brand svg { width: 32px; height: 32px; }
.nav { display: flex; gap: .25rem; }
.nav a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: .45rem 1rem;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 600;
  transition: var(--transition);
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,.18); color: #fff; }

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--accent) 100%);
  color: #fff;
  padding: 4rem 2rem 5.5rem;
  text-align: center;
}
.hero h1 { font-size: 2.4rem; font-weight: 900; margin-bottom: .5rem; }
.hero p  { font-size: 1.1rem; opacity: .88; max-width: 540px; margin: auto; }

/* ---- Layout ---- */
.container { max-width: 1100px; margin: auto; padding: 2rem 1.5rem; }
.layout-grid { display: grid; grid-template-columns: 1fr 340px; gap: 2rem; margin-top: -2.5rem; }
@media (max-width: 800px) { .layout-grid { grid-template-columns: 1fr; } }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.card-body { padding: 1.5rem; }

/* ---- Upload Zone ---- */
.upload-zone {
  border: 2.5px dashed var(--primary);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: #f0f4ff;
}
.upload-zone:hover, .upload-zone.drag-over {
  background: #e0e9ff;
  border-color: var(--primary-dark);
  transform: scale(1.01);
}
.upload-zone .icon { font-size: 3.5rem; margin-bottom: .75rem; }
.upload-zone h3 { font-size: 1.1rem; font-weight: 700; color: var(--primary-dark); }
.upload-zone p  { font-size: .9rem; color: var(--text-muted); margin-top: .3rem; }
#file-input { display: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .7rem 1.6rem;
  border-radius: 8px;
  font-family: 'Cairo', Arial, sans-serif;
  font-size: .95rem; font-weight: 700;
  border: none; cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(26,86,219,.3); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #0f766e; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: .35rem 1rem; font-size: .85rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

/* ---- Progress ---- */
.progress-wrap { margin-top: 1.25rem; }
.progress-label { font-size: .88rem; color: var(--text-muted); margin-bottom: .4rem; display: flex; justify-content: space-between; }
.progress-bar {
  background: var(--border);
  border-radius: 99px; height: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 99px;
  width: 0;
  transition: width .4s ease;
}

/* ---- Alerts ---- */
.alert {
  padding: .9rem 1.2rem;
  border-radius: 8px;
  font-size: .92rem;
  margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: .6rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger   { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.alert-info     { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.alert-warning  { background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; }

/* ---- Stats ---- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.25rem; }
.stat-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-box .num { font-size: 1.6rem; font-weight: 900; color: var(--primary); }
.stat-box .lbl { font-size: .8rem; color: var(--text-muted); margin-top: .1rem; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .85rem 1rem; text-align: right; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 700; color: var(--text-muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #f8fafc; }
.badge {
  display: inline-block; padding: .2rem .7rem;
  border-radius: 99px; font-size: .78rem; font-weight: 700;
}
.badge-done       { background: #d1fae5; color: #065f46; }
.badge-error      { background: #fee2e2; color: #7f1d1d; }
.badge-processing { background: #fef3c7; color: #78350f; }
.badge-pending    { background: #e0f2fe; color: #075985; }

/* ---- File Name Preview ---- */
.file-preview {
  background: var(--bg); border-radius: 8px;
  padding: .75rem 1rem; margin-top: 1rem;
  display: flex; align-items: center; gap: .75rem;
  font-size: .9rem; font-weight: 600; color: var(--primary-dark);
  display: none;
}
.file-preview .size { color: var(--text-muted); font-weight: 400; font-size: .82rem; margin-right: auto; }

/* ---- Text Viewer ---- */
.text-viewer {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  font-family: 'Cairo', Arial, sans-serif;
  font-size: .95rem;
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 600px;
  overflow-y: auto;
  direction: rtl;
}

/* ---- Info List ---- */
.info-list { list-style: none; }
.info-list li {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.info-list li:last-child { border-bottom: none; }
.info-list .key { color: var(--text-muted); min-width: 110px; }
.info-list .val { font-weight: 700; }

/* ---- Spinner ---- */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 3px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Empty State ---- */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state .icon { font-size: 3.5rem; margin-bottom: .75rem; }
.empty-state h3 { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.empty-state p  { font-size: .9rem; margin-top: .3rem; }

/* ---- Footer ---- */
footer {
  text-align: center; padding: 1.75rem;
  color: var(--text-muted); font-size: .85rem;
  border-top: 1px solid var(--border); margin-top: 3rem;
}

/* ---- Pagination ---- */
.pagination { display: flex; gap: .4rem; justify-content: center; margin-top: 1.5rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: .4rem .85rem;
  border-radius: 7px;
  font-size: .88rem; font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text);
  transition: var(--transition);
}
.pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- API Key Notice ---- */
.api-notice {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #fcd34d; border-radius: 10px;
  padding: 1rem 1.25rem; font-size: .9rem; color: #78350f;
}
.api-notice a { color: var(--primary-dark); font-weight: 700; }

/* ---- Search bar ---- */
.search-bar {
  display: flex; gap: .5rem; margin-bottom: 1.25rem;
}
.search-bar input {
  flex: 1;
  padding: .6rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Cairo', Arial, sans-serif;
  font-size: .92rem;
  direction: rtl;
  outline: none;
  transition: var(--transition);
}
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
