@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;1,300;1,400&family=Jost:wght@300;400;500&display=swap');

:root {
  --cream: #F5F0E8;
  --ivory: #FAF7F2;
  --warm-white: #FEFCF9;
  --charcoal: #2C2825;
  --dark: #1A1714;
  --mid: #6B6560;
  --light: #B8B0A6;
  --accent: #8B5E3C;
  --accent-light: #C4956A;
  --gold: #C9A96E;
  --border: #E8E2D9;
  --shadow: rgba(44,40,37,0.08);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Jost', sans-serif;
  font-weight: 300;
  background: var(--ivory);
  color: var(--charcoal);
  min-height: 100vh;
}

/* ===================== TYPOGRAPHY ===================== */
h1, h2, h3 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* ===================== HEADER ===================== */
.site-header {
  background: var(--warm-white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-decoration: none;
}

.logo-main {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--dark);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.logo-sub {
  font-size: 10px;
  font-weight: 300;
  color: var(--light);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.header-user {
  font-size: 13px;
  color: var(--mid);
  letter-spacing: 0.05em;
}

.btn-logout {
  font-size: 12px;
  font-family: 'Jost', sans-serif;
  font-weight: 400;
  color: var(--mid);
  text-decoration: none;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 16px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: var(--charcoal);
  color: var(--charcoal);
}

/* ===================== MAIN LAYOUT ===================== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 24px;
}

/* ===================== PAGE TITLE ===================== */
.page-title {
  margin-bottom: 48px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
}

.page-title h1 {
  font-size: 42px;
  color: var(--dark);
  line-height: 1.1;
}

.page-title p {
  font-size: 13px;
  color: var(--light);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 8px;
}

/* ===================== POSTS GRID ===================== */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 2px;
}

/* ===================== POST CARD ===================== */
.post-card {
  background: var(--warm-white);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 60px var(--shadow);
  z-index: 2;
  position: relative;
}

.post-media {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--cream);
}

.post-media-grid {
  display: grid;
  width: 100%;
  height: 100%;
}

.post-media-grid.has-extra {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.post-media-grid.has-extra .media-main {
  grid-row: 1 / 3;
}

.media-item {
  overflow: hidden;
  position: relative;
}

.media-item img,
.media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.post-card:hover .media-item img,
.post-card:hover .media-item video {
  transform: scale(1.03);
}

.media-item + .media-item {
  border-left: 2px solid var(--ivory);
}

.media-item:last-child:nth-child(3) {
  border-top: 2px solid var(--ivory);
}

.video-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.video-badge svg {
  width: 20px;
  height: 20px;
  fill: var(--charcoal);
  margin-left: 3px;
}

.post-no-media {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.post-no-media span {
  font-family: 'Cormorant Garamond', serif;
  font-size: 48px;
  color: var(--border);
  letter-spacing: 0.1em;
}

/* ===================== POST INFO ===================== */
.post-info {
  padding: 20px;
}

.post-text {
  font-size: 13px;
  line-height: 1.7;
  color: var(--charcoal);
  white-space: pre-line;
}

.post-text .fabric-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 500;
  color: var(--dark);
  display: block;
  margin-bottom: 8px;
  line-height: 1.2;
}

.post-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.post-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.post-meta-label {
  color: var(--light);
  letter-spacing: 0.05em;
}

.post-meta-value {
  color: var(--charcoal);
  font-weight: 400;
}

.post-price {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 12px;
}

.post-date {
  font-size: 11px;
  color: var(--light);
  margin-top: 10px;
  letter-spacing: 0.05em;
}

/* ===================== LOGIN PAGE ===================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  padding: 24px;
}

.login-box {
  background: var(--warm-white);
  padding: 64px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--border);
}

.login-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px;
  font-weight: 400;
  color: var(--dark);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 11px;
  color: var(--light);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 48px;
}

.login-divider {
  width: 40px;
  height: 1px;
  background: var(--gold);
  margin: 0 auto 32px;
}

.login-desc {
  font-size: 14px;
  color: var(--mid);
  line-height: 1.6;
  margin-bottom: 40px;
}

.tg-login-wrap {
  display: flex;
  justify-content: center;
}

.login-error {
  margin-top: 20px;
  font-size: 13px;
  color: #c0392b;
}

/* ===================== PAGINATION ===================== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--mid);
  transition: all 0.2s;
}

.pagination a:hover {
  border-color: var(--charcoal);
  color: var(--charcoal);
}

.pagination .active {
  background: var(--charcoal);
  color: var(--warm-white);
  border-color: var(--charcoal);
}

/* ===================== ADMIN ===================== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 240px;
  background: var(--dark);
  padding: 32px 0;
  flex-shrink: 0;
}

.admin-sidebar-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 24px 32px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: block;
  text-decoration: none;
}

.admin-nav {
  padding: 16px 0;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

.admin-nav a:hover, .admin-nav a.active {
  color: var(--warm-white);
  background: rgba(255,255,255,0.06);
}

.admin-main {
  flex: 1;
  background: var(--ivory);
  padding: 40px;
  overflow-y: auto;
}

.admin-header {
  margin-bottom: 32px;
}

.admin-header h1 {
  font-size: 32px;
  color: var(--dark);
}

/* Статистика */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--warm-white);
  padding: 28px;
  border: 1px solid var(--border);
}

.stat-number {
  font-family: 'Cormorant Garamond', serif;
  font-size: 48px;
  font-weight: 400;
  color: var(--dark);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--light);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 8px;
}

/* Форма настроек */
.settings-section {
  background: var(--warm-white);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.settings-section-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--cream);
}

.settings-section-header h3 {
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--charcoal);
}

.settings-field {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: start;
}

.settings-field:last-child { border-bottom: none; }

.settings-field label {
  font-size: 13px;
  font-weight: 400;
  color: var(--charcoal);
  padding-top: 8px;
}

.settings-field .field-desc {
  font-size: 11px;
  color: var(--light);
  margin-top: 4px;
}

.settings-field input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--ivory);
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.2s;
}

.settings-field input:focus {
  border-color: var(--accent);
}

.btn-save {
  display: inline-block;
  padding: 12px 40px;
  background: var(--charcoal);
  color: var(--warm-white);
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  margin: 24px 28px;
}

.btn-save:hover { background: var(--accent); }

.alert-success {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #2e7d32;
  padding: 12px 20px;
  font-size: 13px;
  margin-bottom: 24px;
}

/* Admin table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--warm-white);
  border: 1px solid var(--border);
}

.admin-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--light);
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--charcoal);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.admin-table tr:last-child td { border-bottom: none; }

.btn-danger {
  padding: 4px 12px;
  background: transparent;
  border: 1px solid #e74c3c;
  color: #e74c3c;
  font-size: 11px;
  font-family: 'Jost', sans-serif;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

.btn-danger:hover { background: #e74c3c; color: white; }

.media-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
}

/* Admin login */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
}

.admin-login-box {
  background: var(--charcoal);
  padding: 48px;
  width: 360px;
  border: 1px solid rgba(255,255,255,0.1);
}

.admin-login-box h2 {
  color: var(--gold);
  font-size: 24px;
  margin-bottom: 32px;
  letter-spacing: 0.05em;
}

.admin-login-box input[type=password] {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--warm-white);
  font-family: 'Jost', sans-serif;
  font-size: 14px;
  margin-bottom: 16px;
  outline: none;
}

.admin-login-box button {
  width: 100%;
  padding: 12px;
  background: var(--gold);
  color: var(--dark);
  border: none;
  font-family: 'Jost', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .posts-grid { grid-template-columns: 1fr; gap: 1px; }
  .main-content { padding: 24px 16px; }
  .login-box { padding: 40px 24px; }
  .admin-layout { flex-direction: column; }
  .admin-sidebar { width: 100%; }
  .admin-main { padding: 24px 16px; }
  .settings-field { grid-template-columns: 1fr; }
}

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