/* MYS Agency Portal — Styles v1
   Design: тёмная тема, акцент #C9A96E (gold), минимализм
   Совместимо с: iOS Safari, Chrome, Firefox */

:root {
  --gold:        #C9A96E;
  --gold-light:  #e0c08a;
  --bg-primary:  #0f0f0f;
  --bg-secondary:#1a1a1a;
  --bg-card:     #222222;
  --bg-card-hover:#2a2a2a;
  --text-primary: #f0f0f0;
  --text-secondary:#a0a0a0;
  --text-muted:  #666;
  --border:      rgba(255,255,255,0.1);
  --border-hover:rgba(201,169,110,0.4);
  --radius:      12px;
  --radius-sm:   8px;
  --input-fs:    16px; /* iOS no-zoom */
  --transition:  0.18s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── Loading screen ─────────────────────────────────────────── */
#app-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: 8px;
}
.loading-logo  { font-size: 24px; font-weight: 700; letter-spacing: 0.05em; color: var(--gold); }
.loading-sub   { font-size: 13px; color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; }

/* ── Header ─────────────────────────────────────────────────── */
.ag-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,15,15,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.ag-header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.ag-logo { font-size: 16px; font-weight: 700; letter-spacing: 0.05em; color: var(--text-primary); }
.ag-logo-sub { color: var(--gold); font-weight: 400; }
.ag-header-actions { display: flex; align-items: center; gap: 12px; }
.ag-agency-name { font-size: 13px; color: var(--text-secondary); }

.ag-badge {
  background: var(--gold); color: #000;
  border-radius: 10px; padding: 1px 7px;
  font-size: 11px; font-weight: 700;
  margin-left: 4px;
}

/* ── Sections ───────────────────────────────────────────────── */
.ag-section { display: none; }
.ag-section.active { display: block; }
.ag-section-inner { max-width: 1200px; margin: 0 auto; padding: 28px 20px 120px; }

.ag-page-title { font-size: 28px; font-weight: 700; margin-bottom: 24px; }
.ag-back-btn {
  background: none; border: none; color: var(--gold);
  font-size: 14px; cursor: pointer; margin-bottom: 16px;
  padding: 0; display: inline-flex; align-items: center; gap: 4px;
}

/* ── Filters ────────────────────────────────────────────────── */
.ag-filters {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.ag-filter-group { display: flex; flex-direction: column; gap: 6px; }
.ag-filter-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.ag-range-row { display: flex; align-items: center; gap: 6px; }

.ag-select, .ag-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--input-fs);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.ag-select:focus, .ag-input:focus { border-color: var(--gold); }
.ag-input-sm { width: 72px; padding: 8px 8px; }

/* ── Catalog grid ───────────────────────────────────────────── */
.ag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.ag-grid-loading { color: var(--text-muted); font-size: 14px; padding: 32px 0; grid-column: 1/-1; }
.ag-grid-empty   { color: var(--text-muted); font-size: 14px; padding: 32px 0; grid-column: 1/-1; text-align: center; }

/* ── Model card ─────────────────────────────────────────────── */
.ag-model-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color var(--transition), transform var(--transition);
  cursor: pointer;
  position: relative;
}
.ag-model-card:hover { border-color: var(--border-hover); }
.ag-model-card.selected { border-color: var(--gold); }

.ag-card-photo {
  position: relative;
  aspect-ratio: 3/4;
  background: var(--bg-secondary);
  overflow: hidden;
}
.ag-card-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}
.ag-model-card:hover .ag-card-photo img { transform: scale(1.03); }

.ag-card-check {
  position: absolute; top: 10px; left: 10px; z-index: 2;
  width: 26px; height: 26px;
  background: rgba(0,0,0,0.55);
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  pointer-events: none;
}
.ag-model-card.selected .ag-card-check {
  background: var(--gold);
  border-color: var(--gold);
}
.ag-card-check-icon {
  color: #000; font-size: 13px; font-weight: 700; display: none;
}
.ag-model-card.selected .ag-card-check-icon { display: block; }

.ag-card-view-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 30px; height: 30px;
  background: rgba(0,0,0,0.55);
  border: none; border-radius: 50%;
  color: var(--text-primary); font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background var(--transition);
}
.ag-card-view-btn:hover { background: var(--gold); color: #000; }

.ag-card-info {
  padding: 10px 12px 12px;
}
.ag-card-id   { font-size: 10px; color: var(--text-muted); margin-bottom: 2px; }
.ag-card-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-card-meta { font-size: 12px; color: var(--text-secondary); }

/* ── Model profile overlay ──────────────────────────────────── */
.ag-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.ag-overlay.open { opacity: 1; pointer-events: all; }

.ag-profile-sheet {
  background: var(--bg-secondary);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 680px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 24px 24px 40px;
  position: relative;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.ag-overlay.open .ag-profile-sheet { transform: translateY(0); }

.ag-profile-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-card); border: none;
  color: var(--text-secondary); font-size: 18px;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ── Request Cart (floating) ────────────────────────────────── */
.ag-cart {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  background: var(--gold);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  min-width: 320px; max-width: calc(100vw - 32px);
  animation: cart-in 0.25s ease;
}
@keyframes cart-in { from { transform: translateX(-50%) translateY(80px); opacity: 0; } }

.ag-cart-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  flex-wrap: wrap;
}
.ag-cart-info { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.ag-cart-count { font-size: 20px; font-weight: 800; color: #000; }
.ag-cart-label { font-size: 13px; font-weight: 600; color: rgba(0,0,0,0.6); }
.ag-cart-pills { display: flex; gap: 4px; flex-wrap: wrap; }

.ag-pill {
  background: rgba(0,0,0,0.15);
  border-radius: 20px;
  padding: 3px 8px 3px 10px;
  font-size: 11px; font-weight: 700; color: #000;
  display: flex; align-items: center; gap: 4px;
}
.ag-pill-remove {
  background: none; border: none; cursor: pointer;
  color: rgba(0,0,0,0.5); font-size: 13px; line-height: 1;
  padding: 0;
}
.ag-pill-remove:hover { color: #000; }

/* ── Request Form sheet ─────────────────────────────────────── */
.ag-form-sheet {
  background: var(--bg-secondary);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 680px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 8px 24px 40px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}
.ag-overlay.open .ag-form-sheet { transform: translateY(0); }

.ag-sheet-handle {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--border);
  margin: 8px auto 20px;
}
.ag-sheet-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

.ag-form-selected {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  min-height: 44px;
}

.ag-form-group { margin-bottom: 16px; }
.ag-form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }

.ag-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: var(--input-fs);
  font-family: inherit;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}
.ag-textarea:focus { border-color: var(--gold); }

.ag-form-actions {
  display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.ag-btn {
  border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 10px 20px;
  transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.ag-btn-primary { background: var(--gold); color: #000; }
.ag-btn-primary:hover { background: var(--gold-light); }
.ag-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.ag-btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.ag-btn-ghost:hover { border-color: var(--gold); color: var(--gold); }

/* ── Requests list ──────────────────────────────────────────── */
.ag-request-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}
.ag-req-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ag-req-id   { font-size: 12px; color: var(--text-muted); }
.ag-req-date { font-size: 12px; color: var(--text-muted); }
.ag-req-status {
  display: inline-block;
  border-radius: 20px; padding: 3px 10px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.ag-req-status.pending  { background: rgba(255,204,0,0.15); color: #ffd60a; }
.ag-req-status.approved { background: rgba(52,199,89,0.15);  color: #34c759; }
.ag-req-status.rejected { background: rgba(255,59,48,0.15);  color: #ff3b30; }
.ag-req-desc { font-size: 14px; color: var(--text-secondary); margin-top: 6px; }
.ag-req-models { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Toast ──────────────────────────────────────────────────── */
.ag-toast {
  position: fixed; bottom: 96px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  z-index: 300;
  animation: toast-in 0.2s ease;
  white-space: nowrap;
}
.ag-toast.success { border-color: #34c759; color: #34c759; }
.ag-toast.error   { border-color: #ff3b30; color: #ff3b30; }
@keyframes toast-in { from { opacity:0; transform: translateX(-50%) translateY(16px); } }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .ag-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .ag-section-inner { padding: 20px 16px 140px; }
  .ag-page-title { font-size: 22px; }
  .ag-filters { gap: 12px; }
}
@media (min-width: 900px) {
  .ag-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
