/* ============================================
   Админ панел — модерни стилове
   ============================================ */
:root {
  --c-bg:        #0a0a0a;
  --c-bg-2:      #0f0f0f;
  --c-bg-3:      #161616;
  --c-bg-4:      #1c1c1c;
  --c-surface:   #131313;
  --c-surface-2: #1a1a1a;
  --c-border:    #232323;
  --c-border-2:  #2e2e2e;
  --c-text:      #f5f5f5;
  --c-text-dim:  #9a9a9a;
  --c-text-mute: #666;
  --c-white:     #fff;
  --c-success:   #4ade80;
  --c-error:     #ff6b6b;
  --c-warn:      #fbbf24;
  --c-accent:    #fff;

  --sidebar-w:   272px;

  --t-fast: 120ms cubic-bezier(.4,0,.2,1);
  --t-base: 200ms cubic-bezier(.4,0,.2,1);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
}

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

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

/* === Login === */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, rgba(255,255,255,.04), transparent 60%), var(--c-bg);
}
.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 36px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.login-box h1 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: -0.02em;
}
.login-box .sub {
  color: var(--c-text-dim);
  text-align: center;
  margin-bottom: 28px;
  font-size: 13px;
}

/* ============================================
   ОБЩА СТРУКТУРА
   ============================================ */
.admin-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.main {
  padding: 32px 40px 60px;
  min-width: 0;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(255,255,255,.025), transparent 50%),
    var(--c-bg);
}

/* ============================================
   SIDEBAR — модерен дизайн
   ============================================ */
.sidebar {
  background: linear-gradient(180deg, #0d0d0d 0%, #080808 100%);
  border-right: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

.sidebar-brand {
  padding: 22px 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--c-border);
}
.sidebar-brand-logo {
  width: 42px; height: 42px;
  background: var(--c-white);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 4px;
}
.sidebar-brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand-text { min-width: 0; }
.sidebar-brand-text strong { font-size: 14px; font-weight: 700; display: block; line-height: 1.2; letter-spacing: -0.01em; }
.sidebar-brand-text small { font-size: 11px; color: var(--c-text-mute); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; display: block; }

.sidebar-cta {
  margin: 16px 16px 8px;
  padding: 11px 14px;
  background: var(--c-bg-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-dim);
  transition: all var(--t-fast);
}
.sidebar-cta:hover {
  background: var(--c-white);
  color: var(--c-bg);
  border-color: var(--c-white);
  transform: translateY(-1px);
}
.sidebar-cta svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-nav {
  padding: 8px 12px;
  flex: 1;
}

.sidebar-section {
  padding: 16px 12px 8px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5c5c5c;
  font-weight: 700;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 1px;
  color: #a8a8a8;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
  position: relative;
}
.sidebar-nav a svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .65;
  transition: opacity var(--t-fast);
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.04);
  color: var(--c-white);
}
.sidebar-nav a:hover svg { opacity: 1; }
.sidebar-nav a.active {
  background: linear-gradient(90deg, rgba(255,255,255,.1) 0%, rgba(255,255,255,.03) 100%);
  color: var(--c-white);
  font-weight: 600;
}
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--c-white);
  border-radius: 0 3px 3px 0;
}

/* Профил долу */
.sidebar-footer {
  border-top: 1px solid var(--c-border);
  padding: 14px;
  margin-top: auto;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--c-bg-3);
  border-radius: var(--r);
  border: 1px solid var(--c-border);
}
.sidebar-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #fff, #888);
  color: var(--c-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info small { display: block; font-size: 10.5px; color: var(--c-text-mute); letter-spacing: 0.05em; text-transform: uppercase; margin-top: 1px; }
.sidebar-logout {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  color: var(--c-text-dim);
  transition: background var(--t-fast), color var(--t-fast);
}
.sidebar-logout svg { width: 16px; height: 16px; }
.sidebar-logout:hover { background: rgba(255,107,107,.1); color: var(--c-error); }

/* ============================================
   МОБИЛНО — sidebar като drawer
   ============================================ */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  width: 44px;
  height: 44px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text);
  z-index: 110;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sidebar-mobile-toggle svg { width: 22px; height: 22px; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 95;
  opacity: 0;
  transition: opacity var(--t-base);
}
.sidebar-backdrop.open { display: block; opacity: 1; }

@media (max-width: 880px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform var(--t-base);
    box-shadow: 8px 0 32px rgba(0,0,0,.5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mobile-toggle { display: flex; }
  .main { padding: 70px 18px 40px; }
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 20px;
}
.main-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.main-header .subtitle {
  color: var(--c-text-dim);
  margin-top: 6px;
  font-size: 14px;
}

/* ============================================
   ПАНЕЛИ
   ============================================ */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 26px;
  margin-bottom: 20px;
  transition: border-color var(--t-base);
}
.panel h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

/* ============================================
   DASHBOARD TILES
   ============================================ */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.tile {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  transition: border-color var(--t-base), transform var(--t-base), background var(--t-base);
  position: relative;
  overflow: hidden;
}
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 100% 0%, rgba(255,255,255,.04), transparent 60%);
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
}
.tile:hover {
  border-color: var(--c-border-2);
  transform: translateY(-2px);
}
.tile:hover::before { opacity: 1; }
.tile-num {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #fff 0%, #999 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tile-label {
  color: var(--c-text-dim);
  font-size: 13px;
  font-weight: 500;
}

/* ============================================
   ФОРМИ
   ============================================ */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  color: var(--c-text-dim);
  font-weight: 500;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="url"],
.field input[type="datetime-local"],
.field input[type="date"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text);
  font-size: 14px;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.field input:hover, .field select:hover, .field textarea:hover {
  border-color: var(--c-border-2);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--c-white);
  background: var(--c-bg-2);
}
.field textarea { min-height: 110px; resize: vertical; font-family: inherit; line-height: 1.55; }
.field textarea.large { min-height: 280px; }
.field .hint { font-size: 12px; color: var(--c-text-mute); margin-top: 6px; line-height: 1.5; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }

/* ============================================
   БУТОНИ
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.btn-primary {
  background: var(--c-white);
  color: var(--c-bg);
}
.btn-primary:hover { background: #e5e5e5; transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--c-text);
  border-color: var(--c-border);
}
.btn-ghost:hover { background: var(--c-bg-3); border-color: var(--c-border-2); }
.btn-danger {
  background: transparent;
  color: var(--c-error);
  border-color: rgba(255,107,107,.25);
}
.btn-danger:hover { background: rgba(255,107,107,.1); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================
   ТАБЛИЦИ
   ============================================ */
.table-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead th {
  background: var(--c-bg-3);
  text-align: left;
  padding: 14px 18px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-dim);
  border-bottom: 1px solid var(--c-border);
}
tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: rgba(255,255,255,.02); }
.cell-img { width: 70px; }
.cell-img img, .cell-img .ph {
  width: 56px; height: 40px; object-fit: cover;
  background: var(--c-bg-3); border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-mute); font-size: 11px;
}
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions .btn { margin-left: 4px; }

/* ============================================
   FLASH MSGS
   ============================================ */
.flash {
  padding: 14px 18px;
  border-radius: var(--r-sm);
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.flash-success { background: rgba(74,222,128,.1); color: var(--c-success); border: 1px solid rgba(74,222,128,.25); }
.flash-error   { background: rgba(255,107,107,.1); color: var(--c-error);   border: 1px solid rgba(255,107,107,.25); }
.flash-success::before { content: '✓'; font-weight: 800; }
.flash-error::before   { content: '!'; font-weight: 800; }

/* ============================================
   IMAGE PREVIEW
   ============================================ */
.img-preview {
  width: 130px; height: 130px;
  background: var(--c-bg-3);
  border-radius: var(--r-sm);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-mute); font-size: 12px; text-align: center; padding: 8px;
  margin-bottom: 10px;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ============================================
   ТЕКСТОВЕ — групи и карти
   ============================================ */
.collapse-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 0;
  margin-bottom: 24px;
}
.collapse-panel summary {
  cursor: pointer;
  padding: 18px 24px;
  font-size: 14px;
  user-select: none;
  list-style: none;
}
.collapse-panel summary::-webkit-details-marker { display: none; }
.collapse-panel[open] summary { border-bottom: 1px solid var(--c-border); margin-bottom: 8px; }
.collapse-panel form { padding: 0 24px 24px; }

.text-group {
  margin-bottom: 32px;
}
.text-group-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
.text-group-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-dim);
  background: var(--c-bg-3);
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--c-border);
}

.text-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

.text-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: 14px 16px;
  transition: border-color var(--t-fast);
}
.text-card:focus-within { border-color: var(--c-border-2); }

.text-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 10px;
}
.text-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.01em;
}
.text-card-fullkey {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10.5px;
  color: var(--c-text-mute);
  margin-top: 2px;
  word-break: break-all;
}
.text-card-del {
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text-mute);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--t-fast);
}
.text-card-del:hover {
  background: rgba(255,107,107,.1);
  color: var(--c-error);
  border-color: rgba(255,107,107,.3);
}

.text-card textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  min-height: 50px;
  transition: border-color var(--t-fast);
}
.text-card textarea:hover { border-color: var(--c-border-2); }
.text-card textarea:focus {
  outline: none;
  border-color: var(--c-white);
  background: var(--c-bg-2);
}

.text-card-hint {
  font-size: 11px;
  color: var(--c-text-mute);
  margin-top: 6px;
  font-style: italic;
}

.texts-save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  background: var(--c-bg-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
  box-shadow: 0 -8px 24px rgba(0,0,0,.4);
  backdrop-filter: blur(10px);
}

@media (max-width: 700px) {
  .text-cards { grid-template-columns: 1fr; }
}
