/* ========================================
   RealWatchCo - Watch Photo Blog Styles
   ======================================== */

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

:root {
  --color-bg: #fafaf9;
  --color-surface: #ffffff;
  --color-text: #1c1917;
  --color-text-muted: #78716c;
  --color-border: #e7e5e4;
  --color-primary: #1c1917;
  --color-primary-hover: #44403c;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-success: #16a34a;
  --color-accent: #a16207;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Georgia', 'Times New Roman', serif;
  --max-width: 1200px;
  --radius: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Container */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* ========================================
   Header
   ======================================== */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.logo:hover {
  text-decoration: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-weight: 500;
  transition: color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-text);
  text-decoration: none;
}

.nav-logout {
  color: var(--color-danger);
}

/* ========================================
   Hero
   ======================================== */
.hero {
  text-align: center;
  padding: 3rem 0 2rem;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.hero-subtitle {
  color: var(--color-text-muted);
  font-size: 1.05rem;
}

/* ========================================
   Post Grid
   ======================================== */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1rem 0 2rem;
}

.post-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, transform 0.2s;
}

.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card-link {
  display: block;
  color: inherit;
}

.post-card-link:hover {
  text-decoration: none;
}

.post-card-image {
  aspect-ratio: 1;
  overflow: hidden;
  background: #f5f5f4;
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.post-card:hover .post-card-image img {
  transform: scale(1.03);
}

.post-card-content {
  padding: 1rem;
}

.post-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.post-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.tag {
  font-size: 0.75rem;
  background: #f5f5f4;
  color: var(--color-accent);
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-weight: 500;
}

.post-card-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.comment-count {
  color: var(--color-text-muted);
}

/* ========================================
   Single Post
   ======================================== */
.post-single {
  max-width: 800px;
  margin: 2rem auto;
}

.post-header {
  margin-bottom: 1.5rem;
}

.post-header h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 0.75rem;
}

.post-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.watch-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #f5f5f4;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.spec strong {
  color: var(--color-text-muted);
  font-weight: 500;
}

.post-image {
  margin: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: #f5f5f4;
}

.post-image img {
  width: 100%;
  cursor: zoom-in;
}

.post-body {
  font-size: 1.05rem;
  line-height: 1.75;
  color: #292524;
}

.post-body p {
  margin-bottom: 1rem;
}

.post-body h2, .post-body h3 {
  margin: 1.5rem 0 0.75rem;
}

.post-body blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: 1rem;
  color: var(--color-text-muted);
  margin: 1rem 0;
}

.post-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.back-link {
  margin: 2rem 0;
  font-size: 0.9rem;
}

/* ========================================
   Comments
   ======================================== */
.comments-section {
  max-width: 800px;
  margin: 0 auto 2rem;
}

.comments-section h3 {
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
}

.comments-list {
  margin-bottom: 2rem;
}

.comment {
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
}

.comment:last-child {
  border-bottom: none;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
}

.comment-author {
  font-weight: 600;
}

.comment-date {
  color: var(--color-text-muted);
}

.comment-body {
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-delete-form {
  margin-left: auto;
}

.btn-delete-comment {
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
}

.btn-delete-comment:hover {
  text-decoration: underline;
}

.no-comments {
  color: var(--color-text-muted);
  font-style: italic;
  margin-bottom: 1.5rem;
}

/* Comment Form */
.comment-form-wrapper {
  background: var(--color-surface);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.comment-form-wrapper h4 {
  margin-bottom: 1rem;
}

.comment-message {
  padding: 0.75rem;
  border-radius: var(--radius);
  margin-top: 1rem;
  font-size: 0.9rem;
}

.comment-message.success {
  background: #f0fdf4;
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

.comment-message.error {
  background: #fef2f2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-align: center;
  line-height: 1.4;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: #f5f5f4;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--color-danger-hover);
  color: #fff;
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn-full {
  width: 100%;
}

/* ========================================
   Forms
   ======================================== */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--color-surface);
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(28,25,23,0.08);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.form-check label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.current-image {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.current-image img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.current-image span {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ========================================
   Admin Dashboard
   ======================================== */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2rem 0 1.5rem;
}

.dashboard-header h1 {
  font-size: 1.5rem;
}

.dashboard-actions {
  display: flex;
  gap: 0.5rem;
}

.posts-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.posts-table th,
.posts-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
}

.posts-table th {
  background: #f5f5f4;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.table-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
}

.thumb-cell {
  width: 64px;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 0.375rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge.published {
  background: #f0fdf4;
  color: var(--color-success);
}

.badge.draft {
  background: #fefce8;
  color: var(--color-accent);
}

/* ========================================
   Login
   ======================================== */
.login-section {
  max-width: 400px;
  margin: 4rem auto;
}

.login-section h1 {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-form {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

/* ========================================
   Alerts
   ======================================== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: #fef2f2;
  color: var(--color-danger);
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: var(--color-success);
  border: 1px solid #bbf7d0;
}

/* ========================================
   Editor
   ======================================== */
.editor-section {
  max-width: 800px;
  margin: 2rem auto;
}

.editor-section h1 {
  margin-bottom: 1.5rem;
}

.editor-form {
  background: var(--color-surface);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ========================================
   Empty State & Error
   ======================================== */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--color-text-muted);
}

.empty-state .btn {
  margin-top: 1rem;
}

.error-page {
  text-align: center;
  padding: 4rem 1rem;
}

.error-page h1 {
  font-size: 4rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.error-page p {
  margin-bottom: 1.5rem;
  color: var(--color-text-muted);
}

/* ========================================
   Pagination
   ======================================== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.375rem;
  padding: 2rem 0;
}

.page-link {
  display: inline-block;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-surface);
  transition: all 0.15s;
}

.page-link:hover {
  background: #f5f5f4;
  text-decoration: none;
}

.page-link.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ========================================
   Lightbox
   ======================================== */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}

.lightbox-content {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
}

.lightbox-content img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}

/* ========================================
   Footer
   ======================================== */
.site-footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 640px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  .post-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
  }

  .post-header h1 {
    font-size: 1.5rem;
  }

  .header-inner {
    height: 56px;
  }

  .nav {
    gap: 1rem;
  }

  .nav-link {
    font-size: 0.8rem;
  }

  .posts-table th:nth-child(3),
  .posts-table td:nth-child(3),
  .posts-table th:nth-child(5),
  .posts-table td:nth-child(5) {
    display: none;
  }

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

  .watch-specs {
    flex-direction: column;
    gap: 0.375rem;
  }
}

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

  .dashboard-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
}
