/* Fonts */
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap");

:root {
  --primary: #205020; /* COOU Green */
  --primary-dark: #1a401a;
  --secondary: #e0d038; /* COOU Gold */
  --secondary-hover: #d4c42d;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --bg-color: #f3f4f6;
  --white: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.95);
  --glass-border: rgba(255, 255, 255, 0.2);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: "Outfit", sans-serif;
  background-color: var(--bg-color);
  background-image: radial-gradient(
      at 0% 0%,
      rgba(32, 80, 32, 0.1) 0px,
      transparent 50%
    ),
    radial-gradient(at 100% 100%, rgba(224, 208, 56, 0.15) 0px, transparent 50%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 4px 6px -1px rgba(32, 80, 32, 0.2);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid #e5e7eb;
  color: var(--text-main);
  margin-top: 12px;
}

.btn-outline:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid #e5e7eb;
}

.divider::before {
  margin-right: 12px;
}

.divider::after {
  margin-left: 12px;
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

/* Toast Notification Styles */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  min-width: 300px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--text-muted);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  border-left-color: #10b981;
}
.toast-success .toast-icon {
  color: #10b981;
}

.toast-error {
  border-left-color: #ef4444;
}
.toast-error .toast-icon {
  color: #ef4444;
}

.toast-info {
  border-left-color: var(--secondary);
}
.toast-info .toast-icon {
  color: var(--secondary);
}

.toast-icon {
  font-size: 24px;
}

.toast-message {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.2s;
}

.toast-close:hover {
  background: #f3f4f6;
  color: var(--text-main);
}

/* Post Link Styling */
.post-link {
  color: var(--primary); /* Green brand color */
  text-decoration: underline;
  font-weight: 500;
}
.post-link:hover {
  text-decoration: none;
  opacity: 0.8;
}

/* Textarea Styling */
.cp-input-area {
  position: relative; /* For absolute button positioning if needed, or flex */
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

textarea#postInput {
  width: 100%;
  padding: 12px;
  padding-right: 40px; /* Space for expand button */
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-family: inherit;
  font-size: 1rem;
  transition: all 0.2s;
  min-height: 50px;
  max-height: 120px; /* Limit widget height */
  overflow-y: hidden; /* Hide scrollbar in small widget */
}

.expand-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 4px;
  border-radius: 50%;
  position: absolute;
  right: 12px;
  top: 12px;
  transition: color 0.2s;
}

.expand-btn:hover {
  color: var(--primary);
  background: rgba(32, 80, 32, 0.1);
}

textarea#postInput:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(32, 80, 32, 0.1);
}

/* Post Text Styling */
.post-text {
  overflow-wrap: anywhere; /* Prevents long words/links from breaking layout */
  word-break: break-word;
  white-space: pre-wrap; /* Honoring newlines */
  line-height: 1.6; /* Improved readability */
}

/* Post Media Grid */
.post-media-grid {
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr;
  margin-top: 12px;
  border-radius: 12px;
  overflow: hidden;
}

.media-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.media-grid-3 {
  grid-template-columns: 1fr 1fr 1fr; /* Or 1fr 1fr and one wide? Simple numeric grid for now */
}
/* For 3 images, let's make it look cool: 1 big, 2 small stacked? 
   Or just 3 columns. Let's do 3 columns for simplicity and equal weight.
   Or: First one full width, next two 50%? 
   Let's do typical grid: 3 cols is fine. 
*/
.media-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.post-media-item {
  width: 100%;
  aspect-ratio: 16/9; /* Standardize shapes */
  object-fit: cover;
  cursor: zoom-in;
  transition: opacity 0.2s;
}
.post-media-item:hover {
  opacity: 0.9;
}

/* Post Modal Styling */
.post-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.post-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.post-modal-content {
  background: #fff;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

#postModalBody {
  overflow-y: auto;
  flex: 1;
  padding-right: 4px; /* Space for scrollbar */
}

/* Compose Modal Specifics */
#composeModal .post-modal-content {
  height: 80vh; /* Force large height */
  max-height: 80vh;
}

#composeInput {
  width: 100%;
  flex: 1; /* Fill remaining space */
  border: none;
  resize: none;
  outline: none;
  font-size: 1.1rem;
  padding: 8px;
  font-family: inherit;
  overflow-y: auto;
  margin-top: 10px;
}

.post-modal-overlay.show .post-modal-content {
  transform: translateY(0);
}

.post-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 20;
  background: #f3f4f6;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-muted);
  transition: all 0.2s;
}

.post-modal-close:hover {
  background: #e5e7eb;
  color: var(--text-main);
}

/* =========================================
   GLOBAL LAYOUT & NAVIGATION (Moved from feed.css)
   ========================================= */

/* --- Layout Grid --- */
.app-layout {
  display: grid;
  grid-template-columns: 1fr; /* Mobile Default */
  min-height: 100vh;
  background-color: var(--bg-color);
}

/* Sidebar & RightBar hidden on mobile */
.sidebar-nav,
.right-sidebar {
  display: none;
}

/* --- Mobile Header --- */
.mobile-header {
  position: sticky;
  top: 0;
  background: var(--glass-bg); /* Glass effect */
  padding: 12px 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mobile-logo {
  height: 32px;
  width: 32px;
  border-radius: 50%;
}

.header-actions {
  display: flex;
  gap: 16px;
  font-size: 24px;
  color: var(--text-main);
}

/* --- Mobile Bottom Nav --- */
.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom); /* iOS safe area */
}

.mobile-nav .nav-item {
  color: var(--text-muted);
  font-size: 24px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: all 0.2s;
  text-decoration: none;
}

.mobile-nav .nav-item.active {
  color: var(--primary);
}

/* Nav Badge */
.nav-badge {
  background: #ff3b30;
  color: white;
  font-size: 10px;
  font-weight: bold;
  height: 18px;
  min-width: 18px;
  padding: 0 4px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 5px;
  right: 10px; /* Adjust based on container */
  z-index: 10;
  border: 1px solid white;
}

/* Mobile Nav Badge adjustment */
.mobile-nav .nav-item {
  position: relative;
}
.mobile-nav .nav-badge {
  top: 5px;
  right: 20px; /* Center-ish relative to icon */
}

.create-fab {
  background: var(--primary);
  color: var(--white);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px; /* Pop out effect */
  transition: transform 0.2s;
}

.create-fab:active {
  transform: scale(0.95);
}

/* --- Utilities --- */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background-color: #d1d5db;
  background-image: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-weight: 600;
  font-size: 16px;
}
.user-avatar.sm {
  width: 32px;
  height: 32px;
}

.nav-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background-color: #d1d5db;
  background-image: linear-gradient(135deg, #e0e0e0 0%, #f5f5f5 100%);
  border: 2px solid transparent;
  transition: all 0.2s;
}

.nav-item.active .nav-avatar {
  border-color: var(--primary);
}

/* --- Desktop Styles --- */
@media (min-width: 992px) {
  .app-layout {
    grid-template-columns: 280px 1fr 350px; /* 3 Column Layout */
    max-width: 1400px;
    margin: 0 auto;
  }

  /* Show Sidebars */
  .sidebar-nav,
  .right-sidebar {
    display: block;
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 24px;
    overflow-y: auto;
  }

  .sidebar-nav {
    border-right: 1px solid #e5e7eb;
    background: var(
      --glass-bg
    ); /* Using glass bg for consistency/premium feel */
    display: flex;
    flex-direction: column;
  }

  .right-sidebar {
    border-left: 1px solid #e5e7eb;
  }

  /* Hide Mobile Elements */
  .mobile-header,
  .mobile-nav,
  .mobile-top-nav {
    /* Added mobile-top-nav here too just in case */
    display: none !important;
  }

  /* Nav Branding */
  .nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 0 12px;
  }
  .nav-brand img {
    height: 40px;
    width: 40px;
    border-radius: 8px;
  }
  .nav-brand span {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
  }

  /* Nav Links */
  .nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
  }

  .sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    border-radius: 12px;
    transition: background 0.2s, color 0.2s;
  }

  .sidebar-nav .nav-item:hover {
    background-color: #f3f4f6;
    color: var(--primary);
  }

  .sidebar-nav .nav-item.active {
    color: var(--primary);
    background-color: rgba(32, 80, 32, 0.1);
    font-weight: 600;
  }

  .sidebar-nav .nav-item i {
    font-size: 24px;
  }

  .nav-logout {
    margin-top: auto;
  }

  /* Widget Styles */
  .widget {
    background: var(--white);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
  }

  .widget h3 {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-weight: 600;
  }
}
