@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  --bg: #faf8f5;
  --bg-gradient-1: #ffe8d6;
  --bg-gradient-2: #d4e5e0;
  --ink: #1a1a1a;
  --muted: #737373;
  --accent: #e85d31;
  --accent-hover: #c94a22;
  --accent-glow: rgba(232, 93, 49, 0.25);
  --accent-2: #2a9d8f;
  --accent-2-hover: #238578;
  --accent-2-glow: rgba(42, 157, 143, 0.25);
  --card: rgba(255, 255, 255, 0.85);
  --card-solid: #ffffff;
  --card-hover: rgba(255, 255, 255, 0.95);
  --line: #e5ddd0;
  --shadow: 0 20px 40px rgba(20, 20, 20, 0.1), 0 8px 16px rgba(20, 20, 20, 0.06);
  --shadow-sm: 0 4px 12px rgba(20, 20, 20, 0.06);
  --shadow-lg: 0 32px 64px rgba(20, 20, 20, 0.12);
  --shadow-glow: 0 0 40px var(--accent-glow);
  --radius: 20px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --backdrop: blur(12px);
}

[data-theme="dark"] {
  --bg: #0f0f17;
  --bg-gradient-1: #1a1a2e;
  --bg-gradient-2: #0d2137;
  --ink: #f0f0f0;
  --muted: #9ca3af;
  --card: rgba(30, 30, 48, 0.8);
  --card-solid: #1e1e30;
  --card-hover: rgba(40, 40, 60, 0.9);
  --line: #2d2d45;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 8px 16px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 32px 64px rgba(0, 0, 0, 0.6);
  --accent-glow: rgba(232, 93, 49, 0.35);
  --accent-2-glow: rgba(42, 157, 143, 0.35);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: 
    radial-gradient(ellipse at 0% 0%, var(--bg-gradient-1) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, var(--bg-gradient-2) 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  padding: 40px 24px 80px;
  transition: background var(--transition-slow), color var(--transition);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.shell {
  max-width: 1140px;
  margin: 0 auto;
  display: grid;
  gap: 32px;
}

/* Header */
header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2.2rem;
  color: var(--accent);
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px var(--accent-glow));
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-4px) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(0deg); }
  75% { transform: translateY(-4px) rotate(2deg); }
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  margin: 0;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--ink) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 1.25rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

h2 i {
  color: var(--accent);
}

.tagline {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--card);
  backdrop-filter: var(--backdrop);
  -webkit-backdrop-filter: var(--backdrop);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: transparent;
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-icon {
  font-size: 1.5rem;
  color: var(--accent);
  opacity: 0.9;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Grid & Cards */
.grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.card {
  background: var(--card);
  backdrop-filter: var(--backdrop);
  -webkit-backdrop-filter: var(--backdrop);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  position: relative;
}

.card:hover {
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.search-box input {
  padding: 10px 14px 10px 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  width: 180px;
  transition: width var(--transition), border-color var(--transition), box-shadow var(--transition);
  background: var(--card-solid);
}

.search-box input:focus {
  width: 240px;
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Form Elements */
label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

label i {
  color: var(--accent);
  font-size: 0.85rem;
}

.required {
  color: var(--accent);
}

input,
textarea {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--card-solid);
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

input:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  transform: translateY(-1px);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

.field {
  margin-bottom: 20px;
}

.field-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.char-count {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.2) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition);
}

button:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}

button:hover::after {
  opacity: 1;
}

button:active {
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.primary:hover {
  box-shadow: 0 8px 24px var(--accent-glow), 0 4px 8px rgba(0,0,0,0.1);
}

.secondary {
  background: var(--line);
  color: var(--ink);
}

.secondary:hover {
  background: var(--muted);
  color: white;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 2px dashed var(--line);
}

.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.danger {
  background: transparent;
  color: #dc3545;
  border: 2px solid #dc3545;
}

.danger:hover {
  background: #dc3545;
  color: white;
}

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--card-solid);
  border: 1px solid var(--line);
  color: var(--ink);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 6px 16px var(--accent-glow);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.spinning i {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Theme Switch */
.switch {
  font-size: 17px;
  position: relative;
  display: inline-block;
  width: 3.5em;
  height: 2em;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  background-color: #2185d6;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  cursor: pointer;
  transition: all 0.4s ease;
  border-radius: 30px;
  box-shadow: 0 0 0 rgba(33, 133, 214, 0);
}

.slider:hover {
  box-shadow: 0 0 15px rgba(33, 133, 214, 0.5);
}

.slider::before {
  position: absolute;
  content: "";
  height: 1.4em;
  width: 1.4em;
  border-radius: 50%;
  left: 10%;
  bottom: 15%;
  box-shadow: inset 15px -4px 0px 15px #fdf906;
  background-color: #28096b;
  transition: all 0.4s ease;
  transform-origin: center;
}

.slider:hover::before {
  transform: rotate(45deg);
}

.clouds_stars {
  position: absolute;
  content: "";
  border-radius: 50%;
  height: 10px;
  width: 10px;
  left: 70%;
  bottom: 50%;
  background-color: #fff;
  transition: all 0.3s;
  box-shadow:
    -12px 0 0 0 white,
    -6px 0 0 1.6px white,
    0.3px 16px 0 white,
    -6.5px 16px 0 white;
  filter: blur(0.55px);
}

.switch input:checked ~ .clouds_stars {
  transform: translateX(-20px);
  height: 2px;
  width: 2px;
  border-radius: 50%;
  left: 80%;
  top: 15%;
  background-color: #fff;
  backdrop-filter: blur(10px);
  transition: all 0.3s;
  box-shadow:
    -7px 10px 0 #fff,
    8px 15px 0 #fff,
    -17px 1px 0 #fff,
    -20px 10px 0 #fff,
    -7px 23px 0 #fff,
    -15px 25px 0 #fff;
  filter: none;
  animation: twinkle 2s infinite;
}

.switch input:checked + .slider {
  background-color: #28096b !important;
}

.switch input:checked + .slider::before {
  transform: translateX(100%);
  box-shadow: inset 8px -4px 0 0 #fff;
}

.switch input:checked + .slider:hover::before {
  transform: translateX(100%) rotate(-45deg);
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Status */
.status {
  font-size: 0.9rem;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: none;
}

.status:not(:empty) {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status.error {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
  border: 1px solid rgba(220, 53, 69, 0.2);
}

.status.success {
  background: rgba(42, 157, 143, 0.1);
  color: var(--accent-2);
  border: 1px solid rgba(42, 157, 143, 0.2);
}

/* Blog List */
.blog-list {
  max-height: 500px;
  overflow-y: auto;
  padding-right: 8px;
}

.blog-list::-webkit-scrollbar {
  width: 8px;
}

.blog-list::-webkit-scrollbar-track {
  background: transparent;
}

.blog-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.blog-list::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  margin: 0;
}

/* Post Card */
.post {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-bottom: 14px;
  background: var(--card-solid);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

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

.post::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 0 4px 4px 0;
  transition: height var(--transition);
}

.post:hover {
  transform: translateX(6px);
  box-shadow: var(--shadow);
  border-color: transparent;
}

.post:hover::before {
  height: 60%;
}

.post:last-child {
  margin-bottom: 0;
}

.post h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.post h3::before {
  content: '';
  width: 4px;
  height: 20px;
  background: var(--accent);
  border-radius: 2px;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.post-meta i {
  font-size: 0.75rem;
}

.post-body {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 12px;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.post-actions button {
  padding: 8px 14px;
  font-size: 0.8rem;
}

/* Pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(239, 111, 63, 0.1);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
}

.pulse {
  width: 8px;
  height: 8px;
  background: var(--accent-2);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(42, 157, 143, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(42, 157, 143, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(42, 157, 143, 0);
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  background: var(--card-solid);
  backdrop-filter: var(--backdrop);
  -webkit-backdrop-filter: var(--backdrop);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 4px solid var(--accent);
  min-width: 280px;
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(120%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.toast.success {
  border-left-color: var(--accent-2);
}

.toast.error {
  border-left-color: #dc3545;
}

.toast i {
  font-size: 1.1rem;
}

.toast.success i {
  color: var(--accent-2);
}

.toast.error i {
  color: #dc3545;
}

/* Footer */
footer {
  text-align: center;
  padding-top: 32px;
  color: var(--muted);
  font-size: 0.85rem;
  opacity: 0.9;
}

footer a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

footer a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

footer i {
  color: var(--accent);
  animation: heartbeat 1.2s ease-in-out infinite;
  display: inline-block;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.25); }
  28% { transform: scale(1); }
  42% { transform: scale(1.25); }
  70% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 768px) {
  body {
    padding: 24px 16px 60px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 20px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .search-box {
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }

  .search-box input:focus {
    width: 100%;
  }

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

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .post-actions {
    flex-wrap: wrap;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: auto;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .stats-bar {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.6rem;
  }

  .stat-card {
    padding: 14px 16px;
  }
}

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

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Selection styling */
::selection {
  background: var(--accent-glow);
  color: var(--ink);
}
