/* Dark theme styles */
body.dark-theme {
    background-color: #181a1b;
    color: #e0e0e0;
}
.dark-theme .dashboard-container,
.dark-theme .modal-content,
.dark-theme .login-card {
    background: #23272b;
    color: #e0e0e0;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
.dark-theme .poem-item {
    background: #23272b;
    border-left: 4px solid #e74c3c;
}
.dark-theme .poem-item h3,
.dark-theme .header-content h1,
.dark-theme .dashboard-header h2 {
    color: #fff;
}
.dark-theme .btn,
.dark-theme .btn-primary,
.dark-theme .btn-secondary,
.dark-theme .btn-danger,
.dark-theme .btn-edit {
    color: #fff;
}
.dark-theme .btn-primary {
    background: #c0392b;
}
.dark-theme .btn-secondary {
    background: #636e72;
}
.dark-theme .btn-danger {
    background: #e74c3c;
}
.dark-theme .btn-edit {
    background: #2980b9;
}
.dark-theme .modal {
    background: rgba(0,0,0,0.8);
}
.dark-theme .form-group input,
.dark-theme .form-group textarea {
    background: #23272b;
    color: #e0e0e0;
    border-color: #444;
}
.dark-theme .form-group input:focus,
.dark-theme .form-group textarea:focus {
    border-color: #e74c3c;
}
.dark-theme .poem-meta {
    color: #b2bec3;
}

.dark-theme .admin-header {
    background: #23272b;
    color: #e0e0e0;
}

.dark-theme .header-content h1 {
    color: #fff;
}

.dark-theme .nav a {
    color: #e0e0e0;
}

.dark-theme .nav a:hover {
    background: #34495e;
}

.dark-theme .form-group label {
    color: #e0e0e0;
}

.dark-theme .checkbox-group label {
    color: #e0e0e0;
}

.dark-theme .close-btn {
    color: #e0e0e0;
}

.dark-theme .close-btn:hover {
    color: #e74c3c;
}

/* Theme toggle styles */
.theme-toggle {
    position: fixed;
    left: 2rem;
    bottom: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #e74c3c 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 1rem 1.2rem;
    font-size: 1.2rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
    width: 60px;
    height: 60px;
}

.theme-toggle:hover {
    background: linear-gradient(135deg, #e74c3c 0%, #667eea 100%);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.dark-theme .theme-toggle {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.dark-theme .theme-toggle:hover {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}

/* Theme toggle icon animations */
.theme-toggle #theme-icon {
    transition: transform 0.3s ease;
}

.theme-toggle:hover #theme-icon {
    transform: rotate(15deg);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Source Sans Pro', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Enhanced Login/Register page styles (replaces earlier login styles for better visual polish) */
.login-container {
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  background: linear-gradient(180deg, rgba(245,246,250,0.6), rgba(249,250,251,0.6));
}

.login-card {
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  padding: 2.25rem;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(16,24,40,0.06);
  width: 100%;
  max-width: 520px;
  border: 1px solid rgba(16,24,40,0.04);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.login-card:hover { transform: translateY(-4px); box-shadow: 0 26px 60px rgba(16,24,40,0.08); }

.login-header { text-align: center; margin-bottom: 1.25rem; }
.login-header h1 { font-family: 'Playfair Display', serif; font-size: 1.6rem; color: #1f2937; margin-bottom: 0.25rem; }
.login-header p { color: #6b7280; font-size: 0.95rem; }

.login-form { display:flex; flex-direction:column; gap:1rem; }
.form-group { display:flex; flex-direction:column; gap:0.35rem; }
.form-group label { font-weight:700; color:#334155; font-size:0.95rem; }
.form-group input, .form-group textarea {
  padding: 12px 14px; border-radius:10px; border:1px solid rgba(15,23,42,0.06); background: #fff; font-size:1rem;
  transition: box-shadow 160ms ease, border-color 160ms ease;
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: rgba(231,76,60,0.9); box-shadow: 0 6px 20px rgba(103,80,231,0.06) inset; }

.form-actions { display:flex; gap:0.5rem; justify-content:flex-end; margin-top:0.5rem; }
.btn-primary { background: linear-gradient(90deg,#667eea,#e74c3c); color:#fff; padding:0.6rem 1rem; border-radius:10px; border:none; font-weight:700; }
.btn-primary:hover { transform: translateY(-2px); }
.btn-secondary { background: transparent; border: 1px solid rgba(15,23,42,0.06); color:#374151; padding:0.55rem 0.9rem; border-radius:10px; }

/* Success & error banners */
.error-message { display:block; background:#fee2e2; color:#991b1b; padding:0.75rem 1rem; border-radius:8px; margin-top:0.5rem; border:1px solid rgba(255,0,0,0.06); }
.success-message { display:block; background:#ecfdf5; color:#065f46; padding:0.75rem 1rem; border-radius:8px; margin-top:0.5rem; border:1px solid rgba(16,185,129,0.08); box-shadow: 0 6px 18px rgba(16,185,129,0.04); }

/* Compact variant used for inline notices */
.notice-inline { padding:0.45rem 0.7rem; border-radius:8px; font-size:0.95rem; }

/* Dark theme adjustments for login and notices */
body.dark-theme .login-container { background: linear-gradient(180deg,#0f1720,#0b1220); }
body.dark-theme .login-card { background: linear-gradient(180deg,#0f1724,#091018); border:1px solid rgba(255,255,255,0.04); box-shadow: 0 18px 40px rgba(0,0,0,0.6); }
body.dark-theme .login-header h1 { color:#f8fafc; }
body.dark-theme .login-header p { color:#9aa4b2; }
body.dark-theme .form-group label { color:#d1e0ea; }
body.dark-theme .form-group input, body.dark-theme .form-group textarea { background:#0b1116; color:#e6eef6; border-color: rgba(255,255,255,0.04); }
body.dark-theme .form-group input:focus, body.dark-theme .form-group textarea:focus { box-shadow: 0 6px 20px rgba(103,80,231,0.06) inset; border-color: rgba(231,76,60,0.9); }

body.dark-theme .error-message { background:#4c1d1d; color:#ffd6d6; border-color: rgba(255,255,255,0.04); }
body.dark-theme .success-message { background:#06374b; color:#b6fff4; border-color: rgba(255,255,255,0.04); box-shadow: none; }

/* Make forms responsive */
@media (max-width: 640px) {
  .login-card { padding:1.25rem; margin: 1rem; }
  .login-header h1 { font-size:1.4rem; }
}

/* Login page styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    padding: 3rem;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #7f8c8d;
    font-style: italic;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: #2c3e50;
}

.form-group input,
.form-group textarea {
    padding: 12px;
    border: 2px solid #ecf0f1;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #e74c3c;
}

/* Ensure modals and error messages are hidden by default; JS may toggle visibility */
.modal {
    display: none;
}
.modal.show {
    display: block;
}
.error-message {
    display: none;
}

.error-message {
    background: #e74c3c;
    color: white;
    padding: 1rem;
    border-radius: 5px;
    margin-top: 1rem;
    text-align: center;
}

/* Admin dashboard styles */
.admin-header {
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1rem 2rem;
}

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

.header-content h1 {
    font-family: 'Playfair Display', serif;
    color: #2c3e50;
}

.admin-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.dashboard-container {
    background: white;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Admin layout & visual fixes (appended overrides) */
/* Header: ensure nav buttons align and wrap on narrow screens */
.header-content {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}
.header-content nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.header-content nav a,
.header-content nav button {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Base button styles (consistent across admin) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 0.9rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
}
.btn:focus { outline: 3px solid rgba(102,126,234,0.18); outline-offset: 2px; }

/* Ensure primary/secondary text colors remain legible */
.btn-primary { color: #fff; }
.btn-secondary { color: #1f2d3d; }

/* Poems list layout (dashboard) */
.poems-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.poem-item {
    background: linear-gradient(180deg,#ffffff,#fafbfc);
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(16,24,40,0.04);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 120px;
}
.poem-item h3 { margin: 0; font-size: 1.05rem; }
.poem-actions { margin-top: auto; display: flex; gap: 0.5rem; }

/* Tweak poem actions: left-align and compact buttons */
.poem-actions {
    margin-top: 0.5rem; /* slight space above actions */
    display: flex;
    gap: 0.45rem;
    justify-content: flex-start; /* align left */
    align-items: center;
    flex-wrap: wrap;
}

/* Make action buttons more compact inside poem cards */
.poem-actions .btn {
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Ensure poem meta and actions layout nicely on small screens */
.poem-item .poem-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    .poem-actions .btn { padding: 0.3rem 0.5rem; font-size: 0.82rem; }
}

/* Modal defaults and centering */
.modal {
    display: none; /* hidden by default, JS toggles .active */
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 1rem;
}
.modal.active { display: flex; }
.modal-content {
    width: 100%;
    max-width: 960px;
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 12px 36px rgba(16,24,40,0.12);
    overflow: auto;
}
.close-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

/* Modal header close button positioning */
.modal-header { position: relative; }
.modal-header .close-btn {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.25rem 0.5rem;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 6px;
}
.modal-header .close-btn:hover { background: rgba(0,0,0,0.04); }

/* Ensure analytics lists use grid so items wrap properly */
.analytics-panel .analytics-list { display: grid; grid-template-columns: 1fr; gap: 0.9rem; }

/* Loading spinner centering */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; padding: 1.5rem 0; }
.loading .spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(0,0,0,0.06); border-top-color: rgba(102,126,234,0.9); animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Form actions spacing */
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; align-items: center; margin-top: 0.6rem; }

/* Small responsive tweaks */
@media (max-width: 720px) {
    .header-content { padding: 0.75rem; }
    .admin-main { padding: 1rem; }
    .dashboard-container { padding: 1rem; }
    .poems-list { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .header-content nav { width: 100%; justify-content: flex-end; }
    .header-content h1 { flex: 1 1 100%; text-align: left; }
}

/* Improve contrast for dark theme poem cards */
.dark-theme .poem-item { background: linear-gradient(180deg,#1f2326,#161718); box-shadow: 0 8px 24px rgba(0,0,0,0.6); }

/* End of admin layout fixes */

/* Login page card adjustments */
.login-card { max-width: 420px; margin: 1.5rem auto; }

/* Map JS preview modal open class to .active to match CSS rules */
.modal.open { display: flex; }

/* Footer fixes for admin */
.footer-bottom {
    margin-top: 2rem;
    padding: 1.25rem 0;
    text-align: center;
    color: #6b7280;
}
.footer-bottom a { color: inherit; text-decoration: underline; }

/* Analytics spacing and chart container */
.analytics-chart { min-height: 220px; background: transparent; }

/* Analytics items and bars */
.analytics-item {
    background: linear-gradient(180deg, #ffffff, #fafbfc);
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(16,24,40,0.04);
    margin-bottom: 0.75rem;
    border-left: 4px solid #667eea;
}

.analytics-item h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #1f2937;
}

.analytics-meta {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
}

.analytics-bar-wrap {
    background: #f3f4f6;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.analytics-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    width: 0%;
    transition: width 0.8s ease-out;
}

.analytics-legend {
    font-size: 0.85rem;
    color: #374151;
    font-weight: 500;
}

/* Dark theme analytics styles */
.dark-theme .analytics-item {
    background: linear-gradient(180deg, #1f2326, #161718);
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    border-left-color: #667eea;
}

.dark-theme .analytics-item h4 {
    color: #f8fafc;
}

.dark-theme .analytics-meta {
    color: #9aa4b2;
}

.dark-theme .analytics-bar-wrap {
    background: #374151;
}

.dark-theme .analytics-legend {
    color: #d1e0ea;
}
