/* =====================================================
   admin.css – Panel CRM Gminny Żłobek w Koziegłowach
   ===================================================== */

:root {
  --adm-sidebar: 240px;
  --adm-primary:  #D52888;
  --adm-primary-dark: #A8006A;
  --adm-secondary: #18AEC7;
  --adm-bg:       #EEF9FB;
  --adm-surface:  #FFFFFF;
  --adm-border:   #9DDAE2;
  --adm-text:     #3A3A3A;
  --adm-muted:    #7A7A8A;
  --adm-danger:   #E74C3C;
  --adm-warning:  #F39C12;
  --adm-success:  #27AE60;
  --adm-radius:   10px;
  --adm-shadow:   0 2px 12px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body.admin-body {
  font-family: 'Nunito', 'Trebuchet MS', sans-serif;
  background: var(--adm-bg);
  color: var(--adm-text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--adm-primary); }
*:focus-visible { outline: 3px solid var(--adm-primary); outline-offset: 2px; border-radius: 4px; }

/* ── Login Screen ─────────────────────────── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FDF0F8, #EEF9FB);
  padding: 1rem;
}

.login-card {
  background: var(--adm-surface);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: .5rem; }
.login-card h1 { font-size: 1.5rem; margin-bottom: .25rem; color: var(--adm-text); }
.login-card p { color: var(--adm-muted); font-size: .9rem; margin-bottom: 2rem; }

.login-form .adm-group { margin-bottom: 1.25rem; text-align: left; }
.login-form label { display: block; font-weight: 700; font-size: .85rem; margin-bottom: .4rem; }
.login-form input {
  width: 100%;
  padding: .75rem 1rem;
  border: 2px solid var(--adm-border);
  border-radius: var(--adm-radius);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color .2s;
}
.login-form input:focus { border-color: var(--adm-primary); outline: none; }
.login-error {
  background: #FFF0F0;
  border: 1px solid #FFCDD2;
  color: var(--adm-danger);
  padding: .6rem 1rem;
  border-radius: var(--adm-radius);
  font-size: .85rem;
  margin-bottom: 1rem;
  display: none;
}
.login-error.visible { display: block; }
.login-btn {
  width: 100%;
  padding: .85rem;
  background: var(--adm-primary);
  color: #fff;
  border: none;
  border-radius: var(--adm-radius);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s;
}
.login-btn:hover { background: var(--adm-primary-dark); }
.login-hint { font-size: .78rem; color: var(--adm-muted); margin-top: 1rem; }

/* ── Admin Layout ─────────────────────────── */
#admin-app { display: none; min-height: 100vh; }
#admin-app.visible { display: flex; flex-direction: column; }

/* Top bar */
.adm-topbar {
  background: var(--adm-surface);
  border-bottom: 1px solid var(--adm-border);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--adm-shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.adm-topbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 800;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--adm-text);
}
.adm-topbar-brand .icon { font-size: 1.4rem; }
.adm-topbar-brand span { color: var(--adm-primary); font-size: .8rem; font-weight: 600; display: block; }

.adm-topbar-actions { display: flex; align-items: center; gap: .75rem; }
.adm-user-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--adm-bg);
  border-radius: 20px;
  padding: .35rem .9rem;
  font-size: .85rem;
  font-weight: 600;
}

/* Content area */
.adm-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ── Tabs ─────────────────────────────────── */
.adm-tabs {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
  background: var(--adm-surface);
  border-radius: 14px;
  padding: .4rem;
  box-shadow: var(--adm-shadow);
}
.adm-tab {
  flex: 1;
  min-width: 120px;
  padding: .65rem 1rem;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--adm-muted);
  font-family: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, color .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  white-space: nowrap;
}
.adm-tab:hover { background: var(--adm-bg); color: var(--adm-text); }
.adm-tab[aria-selected="true"] {
  background: var(--adm-primary);
  color: #fff;
}
.adm-tab .badge {
  background: rgba(255,255,255,.3);
  border-radius: 20px;
  padding: .05rem .45rem;
  font-size: .75rem;
}
.adm-tab[aria-selected="true"] .badge { background: rgba(255,255,255,.25); }
.adm-tab:not([aria-selected="true"]) .badge { background: var(--adm-border); color: var(--adm-muted); }

.adm-panel { display: none; }
.adm-panel.active { display: block; }

/* ── Cards / Sections ─────────────────────── */
.adm-card {
  background: var(--adm-surface);
  border-radius: 14px;
  box-shadow: var(--adm-shadow);
  border: 1px solid var(--adm-border);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.adm-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--adm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
}
.adm-card-header h2 { font-size: 1.1rem; }
.adm-card-body { padding: 1.25rem; }

/* Stats row */
.adm-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.adm-stat-card {
  background: var(--adm-surface);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--adm-shadow);
  border: 1px solid var(--adm-border);
  text-align: center;
}
.adm-stat-card .stat-icon { font-size: 1.8rem; margin-bottom: .4rem; }
.adm-stat-card .stat-val { font-size: 2rem; font-weight: 800; color: var(--adm-primary); }
.adm-stat-card .stat-lbl { font-size: .8rem; color: var(--adm-muted); font-weight: 600; }

/* ── Buttons ──────────────────────────────── */
.adm-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--adm-radius);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background .2s, color .2s, transform .1s;
  text-decoration: none;
}
.adm-btn:active { transform: scale(.97); }
.adm-btn-primary { background: var(--adm-primary); color: #fff; }
.adm-btn-primary:hover { background: var(--adm-primary-dark); color: #fff; text-decoration: none; }
.adm-btn-secondary { background: var(--adm-secondary); color: #fff; }
.adm-btn-secondary:hover { background: #4aa57a; color: #fff; text-decoration: none; }
.adm-btn-outline { background: transparent; border-color: var(--adm-border); color: var(--adm-text); }
.adm-btn-outline:hover { border-color: var(--adm-primary); color: var(--adm-primary); text-decoration: none; }
.adm-btn-danger { background: var(--adm-danger); color: #fff; }
.adm-btn-danger:hover { background: #c0392b; text-decoration: none; }
.adm-btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.adm-btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.adm-btn-block { width: 100%; justify-content: center; }

/* ── Forms ────────────────────────────────── */
.adm-group { margin-bottom: 1.1rem; }
.adm-group label {
  display: block;
  font-weight: 700;
  font-size: .85rem;
  margin-bottom: .35rem;
  color: var(--adm-text);
}
.adm-group label .req { color: var(--adm-primary); }

.adm-group input[type="text"],
.adm-group input[type="email"],
.adm-group input[type="password"],
.adm-group input[type="url"],
.adm-group select,
.adm-group textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 2px solid var(--adm-border);
  border-radius: var(--adm-radius);
  font-family: inherit;
  font-size: .95rem;
  color: var(--adm-text);
  background: #FAFAFA;
  transition: border-color .2s, box-shadow .2s;
}
.adm-group input:focus,
.adm-group select:focus,
.adm-group textarea:focus {
  border-color: var(--adm-primary);
  box-shadow: 0 0 0 3px rgba(232,112,154,.18);
  outline: none;
}
.adm-group textarea { resize: vertical; min-height: 80px; }
.adm-group .hint { font-size: .78rem; color: var(--adm-muted); margin-top: .3rem; }

/* Editor toolbar */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  padding: .5rem;
  background: var(--adm-bg);
  border: 2px solid var(--adm-border);
  border-bottom: none;
  border-radius: var(--adm-radius) var(--adm-radius) 0 0;
}
.editor-toolbar button {
  background: var(--adm-surface);
  border: 1px solid var(--adm-border);
  border-radius: 6px;
  padding: .25rem .6rem;
  font-size: .85rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  color: var(--adm-text);
  transition: background .15s;
  min-width: 32px;
}
.editor-toolbar button:hover { background: var(--adm-primary); color: #fff; border-color: var(--adm-primary); }
#article-content-editor {
  min-height: 200px;
  border: 2px solid var(--adm-border);
  border-radius: 0 0 var(--adm-radius) var(--adm-radius);
  padding: .75rem 1rem;
  font-family: inherit;
  font-size: .95rem;
  line-height: 1.7;
  color: var(--adm-text);
  background: #FAFAFA;
  overflow-y: auto;
}
#article-content-editor:focus { border-color: var(--adm-primary); outline: none; box-shadow: 0 0 0 3px rgba(232,112,154,.18); }
#article-content-editor p { margin-bottom: .75rem; }
#article-content-editor ul, #article-content-editor ol { padding-left: 1.5rem; margin-bottom: .75rem; }

/* Toggle switch */
.toggle-group { display: flex; align-items: center; gap: .75rem; }
.toggle-switch { position: relative; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  transition: background .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--adm-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Article list ─────────────────────────── */
.article-list { display: flex; flex-direction: column; gap: .75rem; }
.article-item {
  background: #FAFAFA;
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.article-item-info { flex: 1; min-width: 200px; }
.article-item-title { font-weight: 800; font-size: .95rem; margin-bottom: .2rem; }
.article-item-meta { font-size: .78rem; color: var(--adm-muted); display: flex; gap: .75rem; flex-wrap: wrap; }
.article-item-actions { display: flex; gap: .5rem; flex-shrink: 0; }

/* Status badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
}
.badge-published { background: #D5F5E3; color: #1E8449; }
.badge-draft { background: #FFF3CD; color: #856404; }
.badge-new { background: #D5EAF5; color: #1A5276; }
.badge-contacted { background: #FEF9E7; color: #7D6608; }
.badge-accepted { background: #D5F5E3; color: #1E8449; }
.badge-rejected { background: #FADBD8; color: #922B21; }

/* ── Gallery grid (admin) ─────────────────── */
.adm-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}
.adm-gallery-item {
  border-radius: var(--adm-radius);
  overflow: hidden;
  border: 2px solid var(--adm-border);
  background: #f5f3ff;
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.adm-gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.adm-gallery-item .adm-gallery-placeholder {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  font-size: 2rem;
}
.adm-gallery-item .adm-gallery-placeholder span {
  font-size: .7rem;
  font-weight: 700;
  color: rgba(58,58,58,.6);
  text-align: center;
  padding: 0 .25rem;
}
.adm-gallery-actions {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  opacity: 0;
  transition: opacity .2s;
}
.adm-gallery-item:hover .adm-gallery-actions { opacity: 1; }
.adm-gallery-item:focus-within .adm-gallery-actions { opacity: 1; }
.adm-gallery-type {
  position: absolute;
  top: .4rem;
  left: .4rem;
  background: rgba(0,0,0,.6);
  color: #fff;
  border-radius: 4px;
  padding: .1rem .4rem;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
}

/* ── Table ────────────────────────────────── */
.adm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  white-space: nowrap;
}
.adm-table th {
  background: var(--adm-bg);
  border-bottom: 2px solid var(--adm-border);
  padding: .65rem .9rem;
  text-align: left;
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--adm-muted);
}
.adm-table td {
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--adm-border);
  vertical-align: middle;
}
.adm-table tr:last-child td { border-bottom: none; }
.adm-table tr:hover td { background: var(--adm-bg); }

/* ── Upload area ──────────────────────────── */
.upload-zone {
  border: 2.5px dashed var(--adm-border);
  border-radius: var(--adm-radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--adm-primary);
  background: #FFF0F5;
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-zone p { color: var(--adm-muted); font-size: .88rem; }
.upload-zone strong { color: var(--adm-primary); }
.upload-preview {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.upload-preview img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--adm-border);
}

/* ── Alerts ───────────────────────────────── */
.adm-alert {
  padding: .8rem 1.1rem;
  border-radius: var(--adm-radius);
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.adm-alert-success { background: #D5F5E3; color: #1E8449; border: 1px solid #A9DFBF; }
.adm-alert-error   { background: #FADBD8; color: #922B21; border: 1px solid #F1948A; }
.adm-alert-info    { background: #D6EAF8; color: #1A5276; border: 1px solid #85C1E9; }

/* ── Empty state ──────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--adm-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: .5rem; color: var(--adm-text); }
.empty-state p { font-size: .9rem; }

/* ── Modal ────────────────────────────────── */
.adm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.adm-modal-overlay.open { opacity: 1; visibility: visible; }
.adm-modal {
  background: var(--adm-surface);
  border-radius: 16px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(16px) scale(.98);
  transition: transform .2s;
}
.adm-modal-overlay.open .adm-modal { transform: none; }
.adm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--adm-border);
  position: sticky;
  top: 0;
  background: var(--adm-surface);
  z-index: 5;
}
.adm-modal-header h2 { font-size: 1.15rem; }
.adm-modal-close {
  background: var(--adm-bg);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.adm-modal-close:hover { background: var(--adm-border); }
.adm-modal-body { padding: 1.5rem; }
.adm-modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--adm-border);
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  flex-wrap: wrap;
}

/* ── Confirm dialog ───────────────────────── */
.adm-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s;
}
.adm-confirm-overlay.open { opacity: 1; visibility: visible; }
.adm-confirm {
  background: var(--adm-surface);
  border-radius: 14px;
  max-width: 380px;
  width: 100%;
  padding: 1.75rem;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.15);
}
.adm-confirm .confirm-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.adm-confirm h3 { font-size: 1.1rem; margin-bottom: .5rem; }
.adm-confirm p { color: var(--adm-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.adm-confirm-actions { display: flex; gap: .75rem; justify-content: center; }

/* ── Responsive ───────────────────────────── */
@media (max-width: 600px) {
  .adm-content { padding: 1rem; }
  .adm-tab { font-size: .8rem; padding: .55rem .6rem; min-width: 80px; }
  .adm-table { font-size: .8rem; }
}

/* Logout btn */
.logout-btn {
  background: transparent;
  border: 1.5px solid var(--adm-border);
  border-radius: var(--adm-radius);
  padding: .4rem .8rem;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--adm-muted);
  transition: border-color .2s, color .2s;
}
.logout-btn:hover { border-color: var(--adm-danger); color: var(--adm-danger); }
