:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #0f766e;
  --warn: #b45309;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  direction: rtl;
  color: var(--text);
  background: var(--bg);
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
}

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

a:hover {
  text-decoration: underline;
}

.container {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.topbar-brand h1 {
  font-size: 1.1rem;
  margin: 0 0 0.4rem 0;
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-meta {
  text-align: left;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.user-meta span {
  color: var(--muted);
  font-size: 0.85rem;
}

.page-content {
  padding: 1rem 0 2rem 0;
}

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

.card h3, .card h4 {
  margin-top: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.row > * {
  flex: 1 1 220px;
}

label {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.2rem;
}

input, select, button, textarea {
  font: inherit;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  background: #fff;
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}

button:hover, .btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

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

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

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

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

.fa-rtl-panel {
  direction: rtl;
  text-align: right;
}

.fa-filter-row {
  background: #fafcff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.fa-table-clean {
  border-radius: 8px;
  overflow: hidden;
}

.fa-table-clean th {
  background: #eef2f7;
}

.fa-table-clean td, .fa-table-clean th {
  white-space: nowrap;
}

.fa-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.fa-label {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.fa-input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 0.55rem 0.7rem;
  background: #fff;
}

.fa-help {
  font-size: 0.88rem;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
}

.fa-error {
  font-size: 0.9rem;
  color: #a40000;
  background: #fff1f1;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 10px;
}

.fa-input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

input.js-time[list]::-webkit-calendar-picker-indicator {
  display: none !important;
}

.jp-popup {
  direction: rtl;
  text-align: right;
}

.jp-title {
  color: #0f172a;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
}

th, td {
  text-align: right;
  border-bottom: 1px solid var(--border);
  padding: 0.55rem;
  vertical-align: top;
}

th {
  background: #f3f4f6;
  font-weight: 700;
}

.status-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.8rem;
}

.status-sent {
  background: #dcfce7;
  color: var(--ok);
}

.status-failed {
  background: #fee2e2;
  color: var(--danger);
}

.status-pending {
  background: #e0f2fe;
  color: #075985;
}

.status-skipped {
  background: #fef3c7;
  color: var(--warn);
}

.live-meeting-card {
  direction: rtl;
  text-align: right;
}

.live-alert {
  border-radius: 8px;
  padding: 8px 10px;
  margin: 8px 0;
}

.live-alert-ok {
  background: #e8f9ef;
  border: 1px solid #b8efcc;
  color: #0a7f2e;
}

.live-alert-err {
  background: #fff1f1;
  border: 1px solid #ffbcbc;
  color: #a40000;
}

.live-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.live-panel-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.live-panel-item h5 {
  margin: 0 0 8px 0;
}

.live-panel-wide {
  grid-column: 1 / -1;
}

.live-pre {
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  line-height: 1.7;
}

.live-list {
  margin: 0;
  padding-right: 18px;
}

.live-list li {
  margin-bottom: 6px;
}

.live-table {
  margin-top: 12px;
}

.owner-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.right-sidebar {
  width: 260px;
  background: #0f172a;
  color: #fff;
  padding: 18px 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.owner-brand {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.owner-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.owner-nav a {
  display: block;
  border-radius: 8px;
  padding: 8px 10px;
  color: #e2e8f0;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.04);
}

.owner-nav a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.content-area {
  flex: 1;
  padding: 14px;
}

/* Timeline v2: مراحل ضبط، آپلود، پیاده‌سازی، تولید صورتجلسه، آماده */
.ai-timeline-v2 {
  direction: rtl;
  margin: 10px 0;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ai-timeline-title {
  margin: 0 0 10px 0;
  font-size: 1rem;
}
.ai-timeline-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: flex-start;
}
.ai-timeline-step {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 140px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}
.ai-timeline-step.active {
  border-color: var(--primary);
  opacity: 1;
}
.ai-timeline-step.done {
  border-color: #0f766e;
  background: #f0fdf4;
}
.ai-timeline-step.pending {
  opacity: 0.7;
}
.ai-timeline-icon {
  font-size: 1.1rem;
}
.ai-timeline-label {
  font-weight: 600;
  font-size: 0.9rem;
}
.ai-timeline-state {
  font-size: 0.82rem;
  color: var(--text);
}
.ai-timeline-progress {
  font-size: 0.8rem;
  color: var(--muted);
}
.ai-timeline-jalali {
  font-size: 0.78rem;
  width: 100%;
}

/* Accessibility: keyboard focus */
.btn:focus-visible,
.btn-ghost:focus-visible,
.btn-primary:focus-visible,
.minutes-ai-toolbar button:focus-visible,
.minutes-ai-toolbar a:focus-visible,
#aiTranscriptPreview:focus-visible,
#aiErrorBox[role="alert"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
button:disabled,
button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Responsive: AI panel */
@media (max-width: 768px) {
  .minutes-ai-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .minutes-ai-toolbar .btn-primary,
  .minutes-ai-toolbar .btn-ghost,
  .minutes-ai-toolbar a {
    width: 100%;
  }
  .ai-timeline-steps {
    flex-direction: column;
  }
  .ai-timeline-step {
    min-width: 100%;
  }
  .minutes-ai-grid {
    grid-template-columns: 1fr;
  }
  .minutes-ai-buttons {
    flex-wrap: wrap;
  }
}

.status-chip {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.84rem;
  line-height: 1.6;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.owner-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.owner-timeline li {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
}

@media (max-width: 700px) {
  .container {
    width: calc(100% - 1rem);
  }

  .topbar-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .user-meta {
    text-align: right;
  }

  .live-panel-grid {
    grid-template-columns: 1fr;
  }

  .owner-shell {
    flex-direction: column;
  }

  .right-sidebar {
    width: 100%;
    border-left: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }
}
