/**
 * @license
 * SPDX-License-Identifier: Apache-2.0
 */

/* Reset and Base Styles */
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #eef0f2; /* Light gray background for the entire page */
  color: #333;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

#root {
  display: flex;
  flex-grow: 1;
  width: 100%; /* Ensure root takes full width */
}

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

/* Landing Page Styles */
.landing-page-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* justify-content: center; Removed to allow scrolling for posts */
  text-align: center;
  flex-grow: 1; /* Take up all space in #root */
  padding: 40px 20px;
  background-color: #f9f9f9;
  width: 100%; /* Ensure it takes full width of #root */
  overflow-y: auto; /* Allow scrolling if content exceeds viewport */
}

.landing-page-container header h1 {
  font-size: 2.8rem;
  color: #2c3e50; /* Dark blue-gray, same as admin sidebar */
  margin-bottom: 20px;
  font-weight: 600;
}

.landing-page-container p {
  font-size: 1.2rem;
  color: #555;
  margin-bottom: 30px;
  max-width: 600px;
  line-height: 1.6;
}

.cta-button {
  padding: 12px 28px;
  font-size: 1.1rem;
  font-weight: 500;
  color: #fff;
  background-color: #1abc9c; /* Teal, same as admin active item */
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 40px; /* Space before posts section */
}

.cta-button:hover {
  background-color: #16a085; /* Darker teal */
  transform: translateY(-1px);
}
.cta-button:active {
  transform: translateY(0);
}

/* Landing Page Posts Grid */
.posts-section {
  width: 100%;
  max-width: 1200px; /* Max width for the posts content */
  margin-top: 20px;
}

.posts-section h2 {
  font-size: 2rem;
  color: #333;
  margin-bottom: 30px;
  border-bottom: 2px solid #1abc9c;
  padding-bottom: 10px;
  display: inline-block;
}

.posts-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 25px;
  padding: 0 10px; /* Some padding on the sides of the grid */
}

.post-item {
  background-color: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.1);
  overflow: hidden; /* To contain image border-radius effects */
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  display: flex;
  flex-direction: column;
}
.post-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.post-item img {
  width: 100%;
  height: 220px;
  object-fit: cover; /* Crop image to fit */
  display: block;
}

.post-item-title {
  padding: 15px;
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin: 0;
  text-align: left;
  background-color: #fdfdfd;
  border-top: 1px solid #eee;
}


/* Admin Layout */
.admin-layout {
  display: flex;
  flex-grow: 1;
  width: 100%; /* Ensure it takes full width of #root */
}

.sidebar {
  width: 260px;
  background-color: #2c3e50; /* Dark blue-gray */
  color: #ecf0f1; /* Light gray text */
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0; /* Prevent sidebar from shrinking */
  height: 100vh; /* Full height sidebar */
  position: fixed; /* Fixed position */
  left: 0;
  top: 0;
  overflow-y: auto;
  z-index: 100; /* Ensure sidebar is above other content if overlaps occur */
}

.sidebar-header {
  padding: 0 20px 20px 20px;
  border-bottom: 1px solid #3b4c5d;
  margin-bottom: 15px;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: #ffffff;
  text-align: center;
}

.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar li button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #ecf0f1;
  padding: 15px 25px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  border-left: 3px solid transparent; /* For active indicator */
}

.sidebar li button:hover {
  background-color: #34495e; /* Slightly lighter dark blue */
  color: #ffffff;
}

.sidebar li.active button {
  background-color: #1abc9c; /* Teal accent for active */
  color: #ffffff;
  font-weight: bold;
  border-left: 3px solid #ffffff;
}

.main-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  margin-left: 260px; /* Account for fixed sidebar width */
  background-color: #f4f6f8; /* Light background for content */
  width: calc(100% - 260px); /* Ensure main area takes remaining width */
  overflow-y: auto;
}

.admin-header {
  background-color: #ffffff;
  padding: 15px 30px;
  border-bottom: 1px solid #dfe3e8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-header h1 {
  margin: 0;
  font-size: 1.8rem;
  color: #2c3e50;
}

.view-site-button {
  padding: 8px 15px;
  font-size: 0.9rem;
  color: #2c3e50;
  background-color: #e9ecef;
  border: 1px solid #ced4da;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.view-site-button:hover {
  background-color: #d6dbe0;
  border-color: #adb5bd;
}

.admin-content {
  padding: 30px;
  flex-grow: 1;
}

.admin-content h2 { /* General h2 for sections within admin content */
  font-size: 1.5rem;
  color: #333;
  margin-top: 0;
  margin-bottom: 20px;
}
.admin-content h3 { /* General h3 for sub-sections */
  font-size: 1.3rem;
  color: #2c3e50;
  margin-top: 25px;
  margin-bottom: 15px;
}

.admin-content p {
  line-height: 1.6;
  margin-bottom: 15px;
}

.welcome-message {
  font-size: 1.2rem;
  margin-bottom: 25px;
  color: #555;
}

/* Stat Cards for Dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

.stat-card {
  background-color: #ffffff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.08);
  border: 1px solid #e0e0e0;
}

.stat-card h3 { /* Overriding general h3 for stat cards specifically */
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 1.1rem;
  color: #34495e; /* Dark blue-gray */
}

.stat-card p {
  font-size: 1.8rem;
  font-weight: bold;
  color: #1abc9c; /* Teal accent */
  margin-bottom: 0;
}

.stat-card .status-online {
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: #2ecc71; /* Green for online */
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.stat-card p .status-online + span { /* If text follows the dot */
  vertical-align: middle;
}

/* Form Group and Input Styling (shared by post form and dashboard upload) */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}
.form-group input[type="text"],
.form-group input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}
.form-group input[type="file"] {
  padding: 8px; /* Slightly different padding for file input */
}
.form-text.text-muted {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 5px;
}


/* Admin Post Form Styles */
.post-form {
    /* Specific styles for post form if needed, beyond .form-group */
}

.image-preview {
  margin-top: 15px;
  margin-bottom: 15px;
  border: 1px dashed #ccc;
  padding: 10px;
  display: inline-block;
  max-width: 300px; /* Limit preview size */
}
.image-preview img {
  max-width: 100%;
  height: auto;
  display: block;
}
.image-preview p { /* Text within image preview, like "Preview:" */
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 5px;
    font-weight: 500;
}

.submit-post-button {
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  background-color: #1abc9c; /* Teal */
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.submit-post-button:hover {
  background-color: #16a085; /* Darker teal */
}

.form-message {
    padding: 10px;
    margin-top: 15px;
    border-radius: 4px;
    text-align: center;
}
.form-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.form-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Dashboard JPG Upload Section Styles */
.dashboard-jpg-upload-section {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #e0e0e0; /* Separator line */
}
/* Uses .form-group for label and input styling */
.dashboard-jpg-preview { /* Specific styling for dashboard's JPG preview */
  max-width: 250px; /* Potentially smaller preview than post image */
}
/* .image-preview and .dashboard-jpg-preview will share img and p styles if not overridden */


/* Footer */
.admin-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.9rem;
  color: #7f8c8d;
  background-color: #e9edf1;
  border-top: 1px solid #dfe3e8;
}

/* Accessibility: Focus visibility */
*:focus-visible {
  outline: 3px solid #3498db;
  outline-offset: 2px;
}
.sidebar li button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: -3px; /* Inside border */
}
.view-site-button:focus-visible,
.submit-post-button:focus-visible {
  outline: 2px solid #007bff; /* Standard blue focus */
  outline-offset: 1px;
}
.cta-button:focus-visible {
   outline: 3px solid #0056b3; /* Darker blue focus for landing page button */
   outline-offset: 1px;
}
.form-group input:focus-visible {
  outline: 2px solid #1abc9c;
  outline-offset: 0;
  border-color: #1abc9c;
}


/* Responsive adjustments */
@media (max-width: 992px) {
  .admin-header h1 {
    font-size: 1.6rem;
  }
  .admin-content {
    padding: 20px;
  }
  .landing-page-container header h1 {
    font-size: 2.4rem;
  }
  .landing-page-container p {
    font-size: 1.1rem;
  }
  .posts-grid-container {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .admin-layout {
     width: auto;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    overflow-y: visible;
    z-index: auto;
  }

  .sidebar ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }

  .sidebar li {
    flex-basis: calc(50% - 10px); /* Two items per row with some gap */
    margin: 5px;
  }
  .sidebar li button {
     padding: 12px 15px;
     font-size: 0.9rem;
     text-align: center;
     border-left: none;
     border-bottom: 3px solid transparent;
  }
  .sidebar li.active button {
    border-left: none;
    border-bottom: 3px solid #ffffff;
  }

  .main-area {
    margin-left: 0;
    width: 100%;
  }

  .admin-header {
    padding: 15px 20px;
    flex-direction: column;
    align-items: flex-start;
  }
  .admin-header h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
  }
  .view-site-button {
    align-self: flex-start;
  }

  .stats-grid {
    grid-template-columns: 1fr; /* Stack cards on small screens */
  }

  .landing-page-container header h1 {
    font-size: 2rem;
  }
  .landing-page-container p {
    font-size: 1rem;
  }
  .cta-button {
    padding: 10px 20px;
    font-size: 1rem;
  }
  .posts-grid-container {
    grid-template-columns: 1fr; /* Stack posts on small screens */
    gap: 20px;
  }
  .post-item img {
    height: 200px;
  }
  .post-item-title {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .sidebar li {
    flex-basis: 100%; /* One item per row on very small screens */
    margin: 5px 0;
  }
   .landing-page-container header h1 {
    font-size: 1.8rem;
  }
  .form-group input[type="text"],
  .form-group input[type="file"] {
    font-size: 0.9rem;
  }
  .image-preview, .dashboard-jpg-preview { /* Apply to both previews */
    max-width: 100%;
  }
}
