/* ==========================================================================
   TimrX Admin Panel — Premium Design
   Complete styling matching blogs.css & hub.css design system
   ========================================================================== */

/* ---------- Core Design Tokens ---------- */
:root {
  --bg: #0b0b0b;
  --text: #f5f5f5;
  --muted: #a7a7a7;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --panel: #0f0f0f;
  --card-bg: #0f0f0f;
  --accent-blue: #0ea5e9;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --danger: #ef4444;
  --danger-light: #fca5a5;
  --success: #10b981;
  --maxw: 1100px;
  --gutter: 28px;
  --navH: 70px;
  --radius: 18px;
  --radius-sm: 8px;
  --radius-lg: 24px;
}

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

/* ---------- HTML & Body ---------- */
html {
  scroll-padding-top: var(--navH);
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
  margin: 0;
  position: relative;
  line-height: 1.6;
}

/* ---------- Animated Gradient Background ---------- */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(14, 165, 233, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 40% 90%, rgba(236, 72, 153, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  animation: bgPulse 20s ease-in-out infinite;
}

@keyframes bgPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

body > * {
  position: relative;
  z-index: 1;
}

/* ---------- Main Wrapper ---------- */
.wrap {
  max-width: var(--maxw);
  margin: calc(var(--navH) + 20px) auto 60px;
  padding: 0 20px;
  opacity: 0;
  animation: fadeIn 0.8s ease forwards;
  animation-delay: 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Top Control Bar ---------- */
.bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  padding: 20px 24px;
  background: linear-gradient(135deg, rgba(20, 20, 20, 0.6), rgba(12, 12, 12, 0.6));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  animation: slideDown 0.6s ease forwards;
  animation-delay: 0.3s;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Bar Inputs & Selects */
.bar input,
.bar select {
  background: #111;
  border: 1px solid var(--line);
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar input::placeholder {
  color: #888;
}

.bar input:focus,
.bar select:focus {
  border-color: var(--accent-blue);
  background: rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12), 0 4px 12px rgba(14, 165, 233, 0.15);
}

.bar select {
  appearance: none;
  cursor: pointer;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: #151515;
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(139, 92, 246, 0.2));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.btn:hover {
  border-color: rgba(14, 165, 233, 0.5);
  background: rgba(20, 20, 20, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.25);
}

.btn:hover::before {
  opacity: 1;
}

.btn:active {
  transform: translateY(0);
}

/* Primary Button */
.btn.primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border: 0;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
}

.btn.primary::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
}

.btn.primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 32px rgba(14, 165, 233, 0.45);
  border-color: transparent;
}

/* Danger Button Styles */
.btn[style*="border-color:#b91c1c"],
.btn[style*="border-color: #b91c1c"] {
  border-color: #b91c1c !important;
  color: var(--danger-light) !important;
  background: rgba(185, 28, 28, 0.1);
}

.btn[style*="border-color:#b91c1c"]:hover,
.btn[style*="border-color: #b91c1c"]:hover {
  border-color: var(--danger) !important;
  background: rgba(185, 28, 28, 0.2);
  box-shadow: 0 8px 20px rgba(185, 28, 28, 0.3);
}

/* ---------- Grid Layout ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  opacity: 0;
  animation: fadeInUp 0.8s ease forwards;
  animation-delay: 0.4s;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Post Cards ---------- */
.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #101010;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.02);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  animation: cardFadeIn 0.5s ease forwards;
}

.card::before {
  content: '';
  position: absolute;
  inset: -1px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.3), rgba(139, 92, 246, 0.3));
  border-radius: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(14, 165, 233, 0.4);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(14, 165, 233, 0.2);
}

.card:hover::before {
  opacity: 0.5;
}

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Staggered card animations */
.card:nth-child(1) { animation-delay: 0.45s; }
.card:nth-child(2) { animation-delay: 0.5s; }
.card:nth-child(3) { animation-delay: 0.55s; }
.card:nth-child(4) { animation-delay: 0.6s; }
.card:nth-child(5) { animation-delay: 0.65s; }
.card:nth-child(6) { animation-delay: 0.7s; }
.card:nth-child(7) { animation-delay: 0.75s; }
.card:nth-child(8) { animation-delay: 0.8s; }

.card strong {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  transition: color 0.3s ease;
}

.card:hover strong {
  color: var(--accent-blue);
}

/* ---------- Tags & Pills ---------- */
.tag {
  font-size: 12px;
  font-weight: 800;
  color: #8abfe1;
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(14, 165, 233, 0.1);
  transition: all 0.3s ease;
}

.card:hover .tag {
  background: rgba(14, 165, 233, 0.2);
  border-color: var(--accent-blue);
}

/* ---------- Text Utilities ---------- */
.muted {
  color: var(--muted);
  font-size: 14px;
}

strong {
  font-weight: 700;
  color: var(--text);
}

/* ---------- Layouts ---------- */
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

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

/* ---------- Modal Overlay ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: radial-gradient(1200px 700px at 50% 10%, rgba(255,255,255,.06), transparent 60%),
              rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  display: none;
  place-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal.show {
  display: grid;
}

/* Modal Panel */
.modal .panel {
  width: min(840px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #0f0f0f;
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Smaller login panel */
.modal .panel[style*="width:min(420px"] {
  width: min(420px, 96vw);
}

@keyframes modalPop {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal .panel h3 {
  margin: 0 0 16px 0;
  font-family: "Bebas Neue", Inter, sans-serif;
  font-size: clamp(24px, 3vw, 28px);
  font-weight: 900;
  background: linear-gradient(135deg, #ffffff, #d0d0d0);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Modal Form Elements */
.modal .panel label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
  margin-top: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel input,
.panel textarea,
.panel select {
  width: 100%;
  background: #111;
  border: 1px solid var(--line);
  color: #fff;
  padding: 10px;
  border-radius: 8px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel input::placeholder,
.panel textarea::placeholder {
  color: #666;
}

.panel input:focus,
.panel textarea:focus,
.panel select:focus {
  border-color: var(--accent-blue);
  background: rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12), 0 4px 12px rgba(14, 165, 233, 0.15);
}

.panel textarea {
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  resize: vertical;
  line-height: 1.6;
}

/* Modal Actions Row */
.panel .row {
  margin-top: 12px;
  gap: 8px;
}

.panel .row .muted {
  margin-right: auto;
}

.panel .row .btn {
  margin-left: 0;
}

.panel .row .btn.primary {
  margin-left: auto;
}

/* Input width override */
.panel input[style*="max-width"] {
  max-width: 240px;
}

/* ---------- Custom Scrollbar ---------- */
.modal .panel::-webkit-scrollbar {
  width: 8px;
}

.modal .panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.modal .panel::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  border-radius: 4px;
  transition: background 0.3s ease;
}

.modal .panel::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #38bdf8, #a78bfa);
}

/* ---------- Responsive Design ---------- */
@media (max-width: 900px) {
  .wrap {
    padding: 0 16px;
    margin-top: calc(var(--navH) + 16px);
  }

  .bar {
    padding: 16px 18px;
    gap: 10px;
  }

  .modal .panel {
    padding: 20px;
  }

  .card {
    padding: 14px;
  }
}

@media (max-width: 600px) {
  .bar {
    flex-direction: column;
    align-items: stretch;
  }

  .bar input,
  .bar select {
    width: 100%;
  }

  .actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .modal .panel {
    padding: 16px;
  }

  .modal .panel h3 {
    font-size: 22px;
  }

  .panel .row {
    flex-direction: column;
    align-items: stretch;
  }

  .panel .row .btn {
    width: 100%;
    margin-left: 0 !important;
  }

  .panel input[style*="max-width"] {
    max-width: 100%;
  }
}

/* ---------- Accessibility & Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card,
  .bar,
  .wrap,
  .grid {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
  }
}

/* ---------- Logout Button ---------- */
.btn-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-logout:hover {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-logout:active {
  transform: translateY(0);
}

/* ---------- Focus Visible (Accessibility) ---------- */
.btn:focus-visible,
.btn-logout:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}
