/*
 * RubyPythMore Blog Styles
 */

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

html {
  overflow-x: hidden;
  width: 100%;
  position: relative;
}

body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
}

.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

/* Prevent any element from causing overflow */
main,
nav,
footer,
section,
article,
div {
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

a {
  color: #000000;
}

a:hover {
  color: #333333;
}

/* Navigation */
.navbar {
  background-color: #000000;
  color: white;
  padding: 1rem 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  width: 100%;
  overflow-x: hidden;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.navbar .logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
  transition: opacity 0.3s;
}

.navbar .logo:hover {
  opacity: 0.8;
}

.navbar .logo svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.nav-links {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-shrink: 0;
}

.nav-link {
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
}

.nav-link:hover {
  background-color: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.navbar .btn {
  background-color: #ffffff !important;
  color: #000000 !important;
}

.navbar .btn:hover {
  background-color: #f0f0f0 !important;
}

.navbar .btn-primary {
  background-color: #ffffff !important;
  color: #000000 !important;
}

.navbar .btn-primary:hover {
  background-color: #f0f0f0 !important;
}

/* Main Content */
main.container {
  min-height: calc(100vh - 200px);
  padding: 2rem 20px;
}

/* Alerts */
.alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
}

.alert-success {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.alert-danger {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background-color: #000000;
  color: #ffffff;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
}

.btn:hover {
  background-color: #333333;
}

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.btn-primary {
  background-color: #000000;
  color: #ffffff;
}

.btn-primary:hover {
  background-color: #333333;
}

.btn-secondary {
  background-color: #95a5a6;
  color: #ffffff;
}

.btn-secondary:hover {
  background-color: #7f8c8d;
}

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

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

.btn-link {
  background: none;
  color: #000000;
  text-decoration: underline;
  padding: 0;
}

.btn-link:hover {
  color: #333333;
}

.btn-link.danger {
  color: #e74c3c;
}

/* Blog Header */
.blog-header {
  text-align: center;
  padding: 3rem 2rem;
  background-color: white;
  margin-bottom: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.blog-header h1 {
  font-size: 3rem;
  color: #2c3e50;
  margin-bottom: 0.5rem;
}

.blog-header p {
  font-size: 1.2rem;
  color: #7f8c8d;
  max-width: 800px;
  margin: 0 auto;
}

/* Admin Quick Actions */
.admin-quick-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}

.admin-quick-actions .btn-icon-large {
  background-color: #000000;
  color: #ffffff;
}

.admin-quick-actions .btn-icon-large:hover {
  background-color: #333333;
}

/* Posts Grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.post-card {
  background-color: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.post-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: #7f8c8d;
}

.post-meta .categories {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.post-meta .date {
  display: block;
}

.categories {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.category {
  background-color: #000000;
  color: white;
  padding: 0.25rem 0.6rem;
  border-radius: 10px;
  font-size: 0.7rem;
  text-transform: uppercase;
  text-align: center;
  display: inline-block;
  white-space: nowrap;
  font-weight: 500;
}

.post-card h2 {
  margin-bottom: 1rem;
}

.post-card h2 a {
  color: #000000;
  text-decoration: none;
}

.post-card h2 a:hover {
  color: #333333;
}

.post-excerpt {
  color: #555;
  margin-bottom: 1rem;
  flex: 1;
}

.post-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid #ecf0f1;
}

.read-more {
  color: #000000;
  text-decoration: none;
  font-weight: 500;
}

.read-more:hover {
  color: #333333;
}

.comment-count {
  font-size: 0.875rem;
  color: #7f8c8d;
}

/* Post Detail */
.post-detail {
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
}

.back-link {
  color: #000000;
  text-decoration: none;
  margin-bottom: 1rem;
  display: inline-block;
}

.back-link:hover {
  color: #333333;
}

.post-detail h1 {
  font-size: 2.5rem;
  color: #2c3e50;
  margin: 1rem 0;
}

.post-content {
  margin-top: 2rem;
  font-size: 1.1rem;
  line-height: 1.8;
  overflow-wrap: break-word;
  word-wrap: break-word;
  max-width: 100%;
}

.post-content pre,
.post-content code {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Comments */
.comments-section {
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.comment-form {
  margin: 2rem 0;
  padding: 1.5rem;
  background-color: #f8f9fa;
  border-radius: 8px;
}

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

.comment {
  padding: 1rem;
  border-bottom: 1px solid #ecf0f1;
}

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

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.comment-date {
  font-size: 0.875rem;
  color: #7f8c8d;
}

.comment-content {
  color: #555;
}

.comment-actions {
  margin-top: 0.5rem;
}

/* Admin */
.admin-posts .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.admin-posts .btn,
.admin-posts .btn-primary,
.admin-post-form .btn,
.admin-post-form .btn-primary,
.posts-table .btn {
  background-color: #000000 !important;
  background: #000000 !important;
  color: #ffffff !important;
}

.admin-posts .btn:hover,
.admin-posts .btn-primary:hover,
.admin-post-form .btn:hover,
.admin-post-form .btn-primary:hover,
.posts-table .btn:hover {
  background-color: #333333 !important;
  background: #333333 !important;
}

.admin-posts .btn-danger,
.admin-post-form .btn-danger,
.posts-table .btn-danger {
  background-color: #e74c3c !important;
  background: #e74c3c !important;
  color: #ffffff !important;
}

.admin-posts .btn-danger:hover,
.admin-post-form .btn-danger:hover,
.posts-table .btn-danger:hover {
  background-color: #c0392b !important;
  background: #c0392b !important;
}

.admin-posts .btn-secondary,
.admin-post-form .btn-secondary {
  background-color: #95a5a6 !important;
  background: #95a5a6 !important;
  color: #ffffff !important;
}

.admin-posts .btn-secondary:hover,
.admin-post-form .btn-secondary:hover {
  background-color: #7f8c8d !important;
  background: #7f8c8d !important;
}

.btn-icon {
  padding: 0.5rem !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 4px;
}

.btn-icon svg {
  flex-shrink: 0;
}

.btn-with-icon {
  display: inline-flex !important;
  align-items: center;
  gap: 0.5rem;
}

.btn-with-icon svg {
  flex-shrink: 0;
}

.btn-icon-large {
  padding: 0.75rem !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 4px;
}

.btn-icon-large svg {
  flex-shrink: 0;
}

.posts-table {
  width: 100%;
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.posts-table th,
.posts-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #ecf0f1;
}

.posts-table th {
  background-color: #f8f9fa;
  font-weight: 600;
}

.status {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.status.published {
  background-color: #d4edda;
  color: #155724;
}

.status.draft {
  background-color: #f8d7da;
  color: #721c24;
}

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

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

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #2c3e50;
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.form-control:focus {
  outline: none;
  border-color: #000000;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.form-group.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-group.checkbox input {
  width: auto;
}

/* Tom Select styling */
.ts-wrapper .ts-control {
  border: 1px solid #ddd !important;
  border-radius: 4px !important;
  padding: 0.75rem !important;
  min-height: 44px !important;
}

.ts-wrapper.focus .ts-control {
  border-color: #000000 !important;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1) !important;
}

.ts-dropdown {
  z-index: 10000 !important;
  background: white !important;
  border: 1px solid #ddd !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.admin-post-form {
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.errors {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.errors ul {
  margin-left: 1.5rem;
}

/* Admin Dashboard */
.admin-dashboard {
  padding: 2rem 0;
}

.admin-dashboard h1 {
  margin-bottom: 2rem;
  color: #000000;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.stat-card {
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  text-align: center;
}

.stat-value {
  font-size: 3rem;
  font-weight: bold;
  color: #000000;
  margin-bottom: 0.5rem;
}

.stat-label {
  font-size: 1.1rem;
  color: #7f8c8d;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.dashboard-column {
  background-color: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}

.dashboard-column h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
  color: #000000;
  border-bottom: 2px solid #000000;
  padding-bottom: 0.5rem;
}

.dashboard-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
  min-height: 200px;
  flex: 1;
}

.dashboard-column .empty-state {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 1rem 0;
}

.dashboard-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #ecf0f1;
}

.dashboard-list li:last-child {
  border-bottom: none;
}

.item-name {
  color: #2c3e50;
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 1rem;
}

.item-count,
.item-meta {
  color: #7f8c8d;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.column-link {
  display: inline-block;
  margin-top: auto;
  color: #000000;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
}

.column-link:hover {
  color: #333333;
}

/* Footer */
.footer {
  background-color: #000000;
  color: white;
  padding: 2rem 0;
  text-align: center;
  margin-top: 4rem;
}

.empty-state {
  text-align: center;
  color: #7f8c8d;
  padding: 2rem;
  font-size: 1.1rem;
}

.login-prompt {
  text-align: center;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 8px;
  margin: 2rem 0;
}

/* Auth Forms */
.auth-form {
  max-width: 450px;
  margin: 2rem auto;
  background-color: #000000;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.auth-form h1 {
  text-align: center;
  margin-bottom: 2rem;
  color: #ffffff;
}

.auth-form label {
  color: #ffffff;
}

.auth-link {
  text-align: center;
  margin-top: 1.5rem;
  color: #ffffff;
}

.auth-link a {
  color: #ffffff;
  text-decoration: underline;
}

.auth-link a:hover {
  color: #f0f0f0;
}

.auth-form .btn {
  background-color: #ffffff;
  color: #000000;
}

.auth-form .btn:hover {
  background-color: #f0f0f0;
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.user-menu-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.user-icon {
  color: #ffffff;
}

.dropdown-menu {
  position: fixed;
  top: 60px;
  right: 10px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  z-index: 1001;
}

.user-dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: #2c3e50;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s;
  border-bottom: 1px solid #ecf0f1;
}

.dropdown-item:last-child {
  border-bottom: none;
}

.dropdown-item:hover {
  background-color: #f8f9fa;
}

.dropdown-item:first-child {
  border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 8px 8px;
}

.dropdown-icon {
  color: #7f8c8d;
  flex-shrink: 0;
}

.dropdown-item.sign-out {
  color: #e74c3c;
}

.dropdown-item.sign-out .dropdown-icon {
  color: #e74c3c;
}

/* Profile Page */
.profile-container {
  max-width: 600px;
  margin: 2rem auto;
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.profile-container h1 {
  margin-bottom: 2rem;
  color: #2c3e50;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.info-group label {
  display: block;
  font-weight: 600;
  color: #7f8c8d;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  text-transform: uppercase;
}

.info-group p {
  color: #2c3e50;
  font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  /* Force all containers to fit */
  * {
    max-width: 100%;
  }

  .container {
    padding: 0 15px;
    width: 100%;
  }

  /* Navigation */
  .navbar {
    width: 100%;
  }

  .navbar .container {
    flex-wrap: wrap;
    width: 100%;
  }

  .navbar .logo {
    font-size: 1.25rem;
  }

  .nav-links {
    gap: 0.5rem;
  }

  /* Blog Header */
  .blog-header {
    width: 100%;
    box-sizing: border-box;
  }

  .blog-header h1 {
    font-size: 2rem;
  }

  .blog-header p {
    font-size: 1rem;
  }

  /* Posts Grid */
  .posts-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    width: 100%;
  }

  .post-card {
    width: 100%;
    box-sizing: border-box;
  }

  /* Post Detail */
  .post-detail {
    padding: 1.5rem;
  }

  .post-detail h1 {
    font-size: 1.75rem;
  }

  /* Admin */
  .admin-posts .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .posts-table {
    overflow-x: auto;
    display: block;
  }

  .posts-table table {
    min-width: 600px;
  }

  /* Forms */
  .auth-form {
    padding: 1.5rem;
    margin: 1rem;
  }

  .admin-post-form {
    padding: 1.5rem;
  }

  /* Profile */
  .profile-container {
    padding: 1.5rem;
    margin: 1rem;
  }

  /* Comments */
  .comments-section {
    padding: 1.5rem;
  }

  .comment-form {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  /* Prevent horizontal overflow */
  html, body {
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Container */
  .container {
    padding: 0 10px;
    max-width: 100%;
  }

  /* Navigation */
  .navbar {
    padding: 0.75rem 0;
  }

  .navbar .container {
    padding: 0 10px;
    gap: 0.5rem;
  }

  .navbar .logo {
    font-size: 1rem;
    max-width: 100px;
  }

  .navbar .logo svg {
    width: 100px;
    max-width: 100%;
  }

  .nav-links {
    gap: 0.5rem;
    flex-shrink: 0;
  }

  /* Make sign up/sign in buttons smaller on mobile */
  .navbar .btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  /* Make tables responsive */
  .posts-table {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .posts-table table {
    min-width: 500px;
  }

  /* Ensure images don't overflow */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Text shouldn't overflow */
  .post-content,
  .post-excerpt,
  .comment-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Blog Header */
  .blog-header {
    padding: 2rem 1rem;
  }

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

  .blog-header p {
    font-size: 0.9rem;
  }

  /* Post Cards */
  .post-card {
    padding: 1rem;
  }

  .post-card h2 {
    font-size: 1.25rem;
  }

  /* Post Detail */
  .post-detail {
    padding: 1rem;
  }

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

  .post-content {
    font-size: 1rem;
  }

  /* Buttons */
  .btn {
    font-size: 0.875rem;
    padding: 0.4rem 0.8rem;
  }

  .btn-sm {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
  }

  /* Admin Table */
  .posts-table th,
  .posts-table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
  }

  /* Forms */
  .form-control {
    font-size: 0.875rem;
  }

  .auth-form,
  .admin-post-form,
  .profile-container,
  .comments-section {
    padding: 1rem;
  }

  /* Dropdown */
  .dropdown-menu {
    min-width: 180px;
  }

  .dropdown-item {
    padding: 0.6rem 0.8rem;
    font-size: 0.875rem;
  }
}
