@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
  --primary-blue: #0284c7;
  --primary-blue-hover: #0369a1;
  --primary-green: #0d9488;
  --primary-green-hover: #0f766e;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --danger-border: #fca5a5;
  --bg-page: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
}

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

body {
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.6;
  padding-bottom: 90px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 20px;
}

/* Header */
.page-header {
  text-align: center;
  margin-bottom: 35px;
}

.page-header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Sections */
.section {
  margin-bottom: 35px;
}

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

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
}

.section-title svg {
  width: 24px;
  height: 24px;
  color: var(--primary-green);
}

.section-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: -12px;
  margin-bottom: 18px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-outline-blue {
  background: transparent;
  color: var(--primary-blue);
  border: 1.5px solid #bae6fd;
}
.btn-outline-blue:hover {
  background: #f0f9ff;
  border-color: var(--primary-blue);
}

.btn-green {
  background-color: var(--primary-green);
  color: #fff;
  padding: 9px 18px;
}
.btn-green:hover {
  background-color: var(--primary-green-hover);
}

.btn-delete {
  background: #fff;
  color: var(--danger);
  border: 1.5px solid var(--danger-border);
  padding: 8px 12px;
  border-radius: var(--radius-md);
}
.btn-delete:hover {
  background: var(--danger-light);
}

.btn-test {
  padding: 6px 14px;
  font-size: 0.88rem;
}

/* Provider Cards */
.provider-card {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.provider-card:hover {
  box-shadow: var(--shadow-md);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 12px;
}

.card-name-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #0369a1;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary-blue);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Form Groups */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.form-group .label-hint {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--input-border);
  background-color: var(--input-bg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.12);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Test Connection Output */
.test-status {
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  display: none;
}

.test-status.success {
  display: block;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.test-status.error {
  display: block;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.test-status.testing {
  display: block;
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Quick Catalog Table */
.catalog-table-wrapper {
  background: #fff;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  padding: 4px;
}

.catalog-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.92rem;
}

.catalog-table th {
  background: #f0fdf4;
  color: #166534;
  font-weight: 700;
  padding: 14px 18px;
  border-bottom: 2px solid #bbf7d0;
  white-space: nowrap;
}

.catalog-table td {
  padding: 14px 18px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.catalog-table tr:hover {
  background: #f8fafc;
}

.badge-tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
}

.btn-add-table {
  background: #f0fdf4;
  color: #15803d;
  border: 1.5px solid #bbf7d0;
  padding: 6px 12px;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-table:hover {
  background: #15803d;
  color: #fff;
}

/* Playground / Test Chat */
.playground-card {
  background: #fff;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 30px;
}

.chat-box {
  min-height: 180px;
  max-height: 350px;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.chat-msg {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  max-width: 80%;
  font-size: 0.95rem;
}

.chat-msg.user {
  background: #0284c7;
  color: #fff;
  margin-left: auto;
}

.chat-msg.ai {
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  margin-right: auto;
}

.chat-msg-meta {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 4px;
  text-align: left;
}

/* Sticky Save Bar */
.sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 2px solid #e2e8f0;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
  z-index: 1000;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  display: none;
  z-index: 2000;
}
