/* styles.css - API Key Manager */

:root {
  --bg-primary: #0a0f1e;
  --bg-secondary: #131a2e;
  --bg-tertiary: #1e2740;
  --text-primary: #f1f5f9;
  --text-secondary: #a3b3cc;
  --text-tertiary: #64748b;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-2: #06b6d4;
  --accent-3: #ec4899;
  --border: rgba(148, 163, 184, 0.18);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.55);
  --radius: 10px;
  --radius-lg: 16px;
  --transition: all 0.2s ease;
  --glow: 0 0 24px rgba(139, 92, 246, 0.35);
  --glass: rgba(19, 26, 46, 0.66);
  --grad-accent: linear-gradient(120deg, #8b5cf6 0%, #06b6d4 55%, #ec4899 100%);
}

.theme-light {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --border: #cbd5e1;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --glow: 0 0 20px rgba(124, 58, 237, 0.15);
  --glass: rgba(241, 245, 249, 0.8);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', 'Vazirmatn', sans-serif; background: var(--bg-primary); color: var(--text-primary); line-height: 1.5; min-height: 100vh; }
html[lang="fa"] body { font-family: 'Vazirmatn', 'Inter', sans-serif; }

/* ---------- Animated aurora background ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -10%, #1b2545 0%, transparent 60%),
    radial-gradient(90% 60% at 100% 100%, #17203c 0%, transparent 55%),
    var(--bg-primary);
}
.theme-light .aurora {
  background:
    radial-gradient(120% 70% at 50% -10%, #e8ecfb 0%, transparent 60%),
    radial-gradient(90% 60% at 100% 100%, #e6f4f7 0%, transparent 55%),
    var(--bg-primary);
}
.aurora-blob {
  position: absolute;
  width: 62vmax;
  height: 62vmax;
  border-radius: 50%;
  filter: blur(68px) saturate(165%);
  opacity: 0.55;
  will-change: transform;
}
.theme-light .aurora-blob { opacity: 0.32; }
.aurora-blob.b1 {
  background: radial-gradient(circle, rgba(139, 92, 246, 0.62) 0%, rgba(139, 92, 246, 0) 62%);
  top: -28vmax;
  left: -18vmax;
  animation: drift1 26s ease-in-out infinite alternate;
}
.aurora-blob.b2 {
  background: radial-gradient(circle, rgba(6, 182, 212, 0.5) 0%, rgba(6, 182, 212, 0) 62%);
  bottom: -30vmax;
  right: -18vmax;
  animation: drift2 32s ease-in-out infinite alternate;
}
.aurora-blob.b3 {
  width: 46vmax;
  height: 46vmax;
  background: radial-gradient(circle, rgba(236, 72, 153, 0.45) 0%, rgba(236, 72, 153, 0) 62%);
  top: 30%;
  left: 32%;
  animation: drift3 38s ease-in-out infinite alternate;
}
/* faint drifting grid + a rotating light beam for depth */
.aurora-grid {
  position: absolute;
  inset: -60%;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 58px 58px;
  -webkit-mask-image: radial-gradient(75% 65% at 50% 0%, #000 0%, transparent 78%);
  mask-image: radial-gradient(75% 65% at 50% 0%, #000 0%, transparent 78%);
  animation: gridPan 42s linear infinite;
}
.aurora-beam {
  position: absolute;
  top: -30vmax;
  left: 50%;
  width: 70vmax;
  height: 70vmax;
  margin-left: -35vmax;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(139, 92, 246, 0.16) 30deg, transparent 70deg, transparent 180deg, rgba(6, 182, 212, 0.13) 215deg, transparent 260deg);
  filter: blur(70px);
  animation: beamSpin 60s linear infinite;
}
.theme-light .aurora-beam { opacity: 0.5; }
@keyframes beamSpin { to { transform: rotate(360deg); } }
@keyframes gridPan {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-58px, -58px, 0); }
}
@keyframes drift1 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(12vw, 8vh) scale(1.15); }
  100% { transform: translate(-6vw, 14vh) scale(0.95); }
}
@keyframes drift2 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-10vw, -10vh) scale(1.2); }
  100% { transform: translate(8vw, -6vh) scale(0.9); }
}
@keyframes drift3 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(10vw, 10vh) scale(1.25); }
  100% { transform: translate(-14vw, -12vh) scale(0.95); }
}
/* brand wordmark picks up the palette */
.brand-text {
  background: linear-gradient(120deg, var(--text-primary) 20%, #a78bfa 55%, #22d3ee 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.theme-light .aurora-blob,
.theme-light .aurora-beam { opacity: 0.25; }
.theme-light .aurora-grid { opacity: 0.5; }
@media (prefers-reduced-motion: reduce) {
  .aurora-blob, .aurora-grid, .aurora-beam, .skeleton { animation: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- Toasts ---------- */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; z-index: 1000; }
.toast { padding: 12px 24px; background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--border); border-radius: var(--radius); transform: translateX(120%); opacity: 0; pointer-events: none; transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); font-size: 14px; box-shadow: var(--shadow-lg); }
.toast.show { transform: translateX(0); opacity: 1; pointer-events: auto; }

/* ---------- Top bar ---------- */
.top-bar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--glass); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 18px; }
.logo-icon { display: inline-block; animation: logoFloat 4s ease-in-out infinite; }
@keyframes logoFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-6deg); }
}
.logo-text {
  background: var(--grad-accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.top-bar-actions { display: flex; align-items: center; gap: 8px; }

.search-container { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; pointer-events: none; }
.search-container input { padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); color: var(--text-primary); font-size: 14px; width: 280px; transition: width 0.25s ease, border-color 0.2s, box-shadow 0.2s; }
.search-container input:focus { outline: none; width: 360px; border-color: var(--accent); box-shadow: var(--glow); }
.search-container input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: var(--text-tertiary); font-size: 16px; cursor: pointer; padding: 2px 6px; }
.search-clear:hover { color: var(--text-primary); }

.icon-button { background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; cursor: pointer; transition: var(--transition); font-size: 14px; }
.icon-button:hover { background: var(--accent); transform: translateY(-2px); box-shadow: var(--glow); }
.icon-button:active { transform: translateY(0) scale(0.95); }

.lang-select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-tertiary); color: var(--text-primary); font-size: 13px; cursor: pointer; }

/* ---------- Main ---------- */
.main-content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.providers-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.providers-header-actions { display: flex; gap: 8px; align-items: center; }

.btn { padding: 8px 16px; border-radius: var(--radius); border: none; font-weight: 500; cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center; gap: 6px; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%); color: white; border: none; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: var(--glow), var(--shadow); filter: brightness(1.08); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid transparent; }
.btn-ghost:hover { color: var(--danger); border-color: var(--border); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-secondary); font-size: 13px; cursor: pointer; transition: var(--transition); }
.chip:hover { border-color: var(--accent); color: var(--text-primary); transform: translateY(-1px); }
.chip.active { background: linear-gradient(135deg, var(--accent), var(--accent-hover)); color: white; border-color: transparent; box-shadow: var(--glow); }
.sort-select { padding: 7px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-secondary); color: var(--text-primary); font-size: 13px; cursor: pointer; }

/* ---------- Provider grid ---------- */
.providers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.provider-card {
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.25s, border-color 0.25s;
  cursor: pointer;
  animation: cardIn 0.4s cubic-bezier(0.34, 1.3, 0.64, 1) backwards;
  position: relative;
}
.provider-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--grad-accent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.provider-card:hover::before { opacity: 0.55; }
.provider-card:nth-child(1) { animation-delay: 0.02s; }
.provider-card:nth-child(2) { animation-delay: 0.05s; }
.provider-card:nth-child(3) { animation-delay: 0.08s; }
.provider-card:nth-child(4) { animation-delay: 0.11s; }
.provider-card:nth-child(5) { animation-delay: 0.14s; }
.provider-card:nth-child(n+6) { animation-delay: 0.17s; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.provider-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg), var(--glow); border-color: var(--accent); }
.provider-card.is-pinned { border-color: rgba(139, 92, 246, 0.5); }
.provider-header { display: flex; align-items: center; gap: 12px; padding: 16px; cursor: pointer; }
.provider-icon-placeholder { width: 36px; height: 36px; border-radius: 8px; background: var(--bg-tertiary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.provider-header img { width: 36px; height: 36px; border-radius: 8px; object-fit: contain; background: var(--bg-primary); flex-shrink: 0; padding: 2px; }
.provider-detail-header img { width: 48px; height: 48px; border-radius: 12px; object-fit: contain; background: var(--bg-primary); padding: 4px; flex-shrink: 0; }
.provider-info { flex: 1; min-width: 0; }
.provider-info h3 { font-size: 16px; font-weight: 500; }
.provider-info span { font-size: 12px; color: var(--text-tertiary); }
.provider-base-url { cursor: pointer; transition: color 0.15s; }
.provider-base-url:hover { color: var(--accent); }
.provider-menu-btn { margin-left: auto; background: transparent; border: none; padding: 4px 8px; font-size: 16px; cursor: pointer; opacity: 0.5; }
.provider-body { padding: 12px 16px; border-top: 1px solid var(--border); }
.pin-btn { background: transparent; border: none; font-size: 15px; cursor: pointer; opacity: 0.45; padding: 6px; border-radius: 6px; transition: var(--transition); }
.pin-btn:hover { opacity: 1; background: var(--bg-tertiary); transform: scale(1.15); }
.pin-btn.pinned { opacity: 1; }
.pin-flag { font-size: 12px; }

.card-models { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 16px 12px; }
.model-chip { padding: 2px 9px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 999px; font-size: 11px; color: var(--text-secondary); cursor: pointer; transition: var(--transition); font-family: 'Source Code Pro', monospace; }
.model-chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.model-chip.more { cursor: default; opacity: 0.7; }
.model-chip.more:hover { transform: none; border-color: var(--border); color: var(--text-secondary); }

.stat-badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bg-tertiary); }
.stat-badge.active { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.key-preview { font-family: monospace; font-size: 11px; color: var(--text-tertiary); padding: 4px 8px; background: var(--bg-primary); border-radius: 4px; word-break: break-all; }
.no-keys { font-size: 13px; color: var(--text-tertiary); cursor: pointer; padding: 4px 8px; border-radius: 4px; display: inline-block; transition: var(--transition); }
.no-keys:hover { color: var(--accent); background: var(--bg-tertiary); }

/* ---------- Modals ---------- */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.22s; z-index: 200; }
.modal.open { opacity: 1; pointer-events: auto; z-index: 210; }
.modal-content { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; transform: translateY(16px) scale(0.98); transition: transform 0.25s cubic-bezier(0.34, 1.3, 0.64, 1); box-shadow: var(--shadow-lg); }
.modal.open .modal-content { transform: translateY(0) scale(1); }
.modal-large .modal-content { max-width: 800px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border); }
.modal-close { background: transparent; border: none; font-size: 24px; cursor: pointer; color: var(--text-tertiary); transition: var(--transition); }
.modal-close:hover { color: var(--text-primary); transform: rotate(90deg); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); color: var(--text-primary); font-size: 14px; transition: border-color 0.2s, box-shadow 0.2s; }
.form-group input:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 0; border-top: 1px solid var(--border); }
.key-row { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-primary); border-radius: var(--radius); border: 1px solid var(--border); transition: var(--transition); }
.key-row:hover { border-color: var(--accent); }
.key-info { flex: 1; min-width: 0; }
.key-name { font-size: 13px; font-weight: 500; }
.key-value { font-family: monospace; font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }
.icon-btn { background: transparent; border: none; padding: 4px 8px; font-size: 14px; cursor: pointer; transition: var(--transition); }
.icon-btn:hover { background: var(--bg-tertiary); border-radius: 4px; transform: scale(1.12); }
.icon-btn.danger:hover { background: rgba(239, 68, 68, 0.15); }
.key-status { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; text-transform: uppercase; }
.models-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.model-tag { padding: 2px 8px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 4px; font-size: 12px; color: var(--text-secondary); cursor: pointer; transition: var(--transition); }
.model-tag:hover { border-color: var(--accent); color: var(--accent); }
.footer { text-align: center; padding: 24px; color: var(--text-tertiary); font-size: 13px; border-top: 1px solid var(--border); margin-top: 32px; }
.footer a { color: var(--accent); text-decoration: none; }
/* Provider Detail */
.provider-detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.provider-detail-info h2 { font-size: 18px; margin-bottom: 4px; }
.provider-detail-base { font-size: 12px; color: var(--text-tertiary); cursor: pointer; }

.actions-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.edit-mode-toggle { font-size: 13px; color: var(--accent); cursor: pointer; padding: 4px 8px; border-radius: var(--radius); }
.edit-mode-toggle:hover { background: var(--bg-tertiary); }
.edit-mode-toggle.editing { color: var(--success); }
.empty-state-full { text-align: center; padding: 40px; color: var(--text-tertiary); grid-column: 1/-1; }
.models-section { margin-bottom: 16px; }
.keys-section { margin-top: 16px; }
.keys-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; flex-wrap: wrap; }
.keys-header > div { display: flex; gap: 8px; flex-wrap: wrap; }
.keys-list { display: flex; flex-direction: column; gap: 8px; }
.empty-state { padding: 24px; text-align: center; color: var(--text-tertiary); }

.toast.error { border-color: var(--danger); }
.loading-state { padding: 40px; text-align: center; color: var(--text-tertiary); grid-column: 1/-1; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(1.1); }
.form-hint { font-size: 12px; color: var(--text-tertiary); margin: -6px 0 12px; }
.form-hint.warning { color: var(--warning); }
.encrypt-status { padding: 10px 12px; border-radius: var(--radius); background: var(--bg-primary); border: 1px solid var(--border); font-size: 13px; margin-bottom: 14px; }
.encrypt-status .status-on { color: var(--success); }
.encrypt-status .status-off { color: var(--text-tertiary); }
.encrypt-status .status-locked { color: var(--warning); }
.key-lock { font-size: 11px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.backup-actions { flex-wrap: wrap; }

.directory-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.directory-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); transition: var(--transition); }
.directory-item:hover { border-color: var(--accent); transform: translateX(2px); }
.directory-item .provider-icon-placeholder, .directory-item img { width: 28px; height: 28px; border-radius: 6px; }
.directory-info { flex: 1; min-width: 0; }
.directory-name { font-size: 14px; font-weight: 500; }
.directory-category { font-size: 11px; color: var(--text-tertiary); background: var(--bg-tertiary); border-radius: 999px; padding: 1px 8px; margin-left: 6px; }
.directory-url { font-size: 12px; color: var(--text-tertiary); word-break: break-all; }
.directory-added { color: var(--success); font-size: 13px; }
.directory-search input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); color: var(--text-primary); font-size: 14px; }

/* ---------- Recycle bin ---------- */
.trash-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.trash-section-title { font-size: 13px; color: var(--text-secondary); margin: 8px 0 4px; }
.trash-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--bg-primary); opacity: 0.85; transition: var(--transition); }
.trash-item:hover { opacity: 1; border-color: var(--accent); }
.trash-info { flex: 1; min-width: 0; }
.trash-name { font-size: 14px; }
.trash-date { font-size: 11px; color: var(--text-tertiary); }

/* ---------- Key tester ---------- */
.keytest-provider { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.keytest-controls { margin-bottom: 12px; }
.keytest-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.keytest-results { display: flex; flex-direction: column; gap: 6px; }
.keytest-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-primary); animation: cardIn 0.3s ease backwards; }
.keytest-row.pass { border-color: rgba(34, 197, 94, 0.5); }
.keytest-row.fail { border-color: rgba(239, 68, 68, 0.5); }
.keytest-name { font-size: 13px; font-weight: 500; }
.keytest-status { font-size: 12px; }
.keytest-status.pass { color: var(--success); }
.keytest-status.fail { color: var(--danger); }
.keytest-status.pending { color: var(--text-tertiary); }
.keytest-status small { color: var(--text-tertiary); margin-inline-start: 4px; }
.testing-row .keytest-status { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- RTL (Persian) ---------- */
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] .search-container input { padding: 8px 36px 8px 30px; }
html[dir="rtl"] .search-icon { left: auto; right: 12px; }
html[dir="rtl"] .search-clear { right: auto; left: 8px; }
html[dir="rtl"] .provider-menu-btn { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .keys-header,
html[dir="rtl"] .providers-header,
html[dir="rtl"] .modal-header,
html[dir="rtl"] .form-actions { direction: rtl; }
html[dir="rtl"] .form-actions { justify-content: flex-start; }
html[dir="rtl"] .key-value,
html[dir="rtl"] .directory-url,
html[dir="rtl"] .provider-base-url { direction: ltr; text-align: right; font-family: 'Source Code Pro', monospace; }
html[dir="rtl"] .toast-container { right: auto; left: 24px; align-items: flex-start; }
html[dir="rtl"] .toast { transform: translateX(-120%); }
html[dir="rtl"] .toast.show { transform: translateX(0); }
html[dir="rtl"] .models-tags { direction: rtl; }
html[dir="rtl"] .actions-row { direction: rtl; }
html[dir="rtl"] .card-models { direction: rtl; }

/* ---------- Mobile-first responsive ---------- */
@media (max-width: 768px) {
  :root { --radius: 10px; --radius-lg: 14px; }

  .top-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
  }
  .logo { justify-content: center; }
  .top-bar-actions { justify-content: center; flex-wrap: wrap; }
  .search-container { width: 100%; }
  .search-container input { width: 100%; font-size: 16px; }
  .search-container input:focus { width: 100%; }

  .icon-button { padding: 10px 14px; font-size: 16px; }

  .main-content { padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .providers-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .providers-header-actions { flex-direction: column; }
  .providers-header-actions .btn { justify-content: center; padding: 12px 16px; font-size: 15px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-chips { justify-content: center; }
  .chip { padding: 8px 14px; font-size: 13px; }
  .sort-select { padding: 10px 12px; font-size: 14px; }
  .providers-grid { grid-template-columns: 1fr; gap: 12px; }

  .provider-card:active { transform: none; }
  .provider-header { padding: 14px; }
  .provider-header img, .provider-icon-placeholder { width: 40px; height: 40px; }
  .provider-info h3 { font-size: 17px; }
  .provider-body { padding: 12px 14px; }
  .key-preview { font-size: 12px; padding: 6px 10px; }
  .no-keys { padding: 8px; font-size: 14px; }

  .modal { align-items: flex-end; padding: 0; }
  .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-header { padding: 14px 18px; position: sticky; top: 0; background: var(--bg-secondary); z-index: 1; }
  .modal-close { font-size: 28px; padding: 6px 10px; }
  .form-group input, .form-group select, .form-group textarea {
    font-size: 16px;
    padding: 12px 14px;
  }
  .form-actions { padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); position: sticky; bottom: 0; background: var(--bg-secondary); }
  .form-actions .btn { flex: 1; justify-content: center; padding: 12px 16px; font-size: 15px; }

  .key-row { flex-wrap: wrap; padding: 12px; }
  .key-status { order: -1; }
  .icon-btn { padding: 10px 12px; font-size: 16px; }
  .models-tags .model-tag { font-size: 13px; padding: 4px 10px; }
  .actions-row .btn { flex: 1; justify-content: center; }
  .keys-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .keys-header > div { display: flex; gap: 8px; }
  .keys-header .btn { flex: 1; justify-content: center; }

  .directory-item { padding: 12px; }
  .directory-item .btn { padding: 10px 14px; }
  .directory-list { max-height: 55vh; }

  .toast-container { left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); align-items: stretch; }
  .toast { text-align: center; }

  .footer { padding: 16px; font-size: 12px; }
}

@media (max-width: 360px) {
  .top-bar-actions .icon-button { padding: 8px 10px; font-size: 14px; }
  .stat-badge { font-size: 11px; }
}

@media (hover: none) and (pointer: coarse) {
  .provider-card:hover { transform: none; box-shadow: none; }
  .provider-card:active { border-color: var(--accent); }
}
