:root {
  --primary-color: #006400;
  --accent-color: #FF8C00;
  --bg-color: #f5f5f5;
  --text-color: #333;
  --border-color: #ddd;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--bg-color);
}

#app-container {
  display: flex;
  height: 100dvh;
  width: 100%;
}

/* Sidebar */
#sidebar {
  width: 300px;
  background: white;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

/* Desktop: Always show sidebar, hide hamburger */
@media (min-width: 769px) {
  #sidebar {
    position: static;
    transform: translateX(0) !important;
  }
  
  #mobile-menu-toggle {
    display: none !important;
  }
}

/* Hamburger Menu Button */
#mobile-menu-toggle {
  color: var(--primary-color);
  font-size: 1.5rem;
  padding: 0.5rem;
  border: none;
  background: transparent;
}

#mobile-menu-toggle:hover {
  color: #004d00;
}

/* Cart Button */
#cart-btn {
  color: var(--primary-color);
  font-size: 1.5rem;
  padding: 0.5rem;
  border: none;
  background: transparent;
}

#cart-btn:hover {
  color: #004d00;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary-color);
  color: white;
}

.sidebar-header h3 {
  font-size: 1.25rem;
  margin: 0;
}

/* Sidebar Search */
.sidebar-search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: white;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: #999;
  font-size: 0.9rem;
  pointer-events: none;
}

#contact-search {
  width: 100%;
  padding: 0.5rem 2.5rem 0.5rem 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

#contact-search:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 100, 0, 0.1);
}

#clear-search {
  position: absolute;
  right: 4px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  color: #999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

#clear-search:hover {
  background: var(--bg-color);
  color: var(--text-color);
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 1rem;
  right: 1rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 0.5rem;
}

.search-section {
  padding: 0.5rem 0;
}

.search-section-title {
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.search-result-item:hover {
  background: var(--bg-color);
}

.search-result-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  flex-shrink: 0;
  font-size: 1rem;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-desc {
  font-size: 0.8rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #999;
}

.search-empty i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.conversation-item:hover {
  background: var(--bg-color);
}

.conversation-item.active {
  background: #e8f5e9;
  border-left: 4px solid var(--primary-color);
}

.conversation-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.conversation-info {
  flex: 1;
  min-width: 0;
}

.conversation-name {
  font-weight: 600;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-preview {
  font-size: 0.875rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-badge {
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-color);
}

/* User Auth Section */
#user-auth-section {
  width: 100%;
}

#login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-weight: 600;
}

#logged-in-state .user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: white;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

#logged-in-state .user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

#logged-in-state .user-details {
  flex: 1;
  min-width: 0;
}

#logged-in-state .user-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#logged-in-state .user-email {
  font-size: 0.8rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
}

/* Main Content */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

#top-header {
  height: 60px;
  background: white;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#content-wrapper {
  flex: 1;
  overflow: hidden;
  height: calc(100dvh - 60px);
  max-height: calc(100dvh - 60px);
}

/* Buttons */
.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background-color: #004d00;
  border-color: #004d00;
}

.btn-success {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
}

.btn-success:hover {
  background-color: #cc7000;
  border-color: #cc7000;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}