/* ===== Dashboard Layout ===== */
.dashboard-root {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #171a1f;
  background-color: #f9fafb;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .dashboard-root {
    flex-direction: row;
  }
}

.dashboard-root h1,
.dashboard-root h2,
.dashboard-root h3,
.dashboard-root h4,
.dashboard-root h5,
.dashboard-root h6 {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: #171a1f;
}

/* ===== Scrollbar ===== */
.dashboard-root ::-webkit-scrollbar { width: 5px; height: 5px; }
.dashboard-root ::-webkit-scrollbar-track { background: transparent; }
.dashboard-root ::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }
.dashboard-root ::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

/* ===== Sidebar ===== */
.dash-sidebar {
  display: none;
  flex-direction: column;
  width: 256px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  height: 100vh;
  position: sticky;
  top: 0;
}

@media (min-width: 1024px) {
  .dash-sidebar { display: flex; }
}

.dash-sidebar-brand {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-sidebar-brand-icon {
  width: 32px;
  height: 32px;
  background: #22C365;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dash-sidebar-brand-icon img { width: 20px; height: 20px; }

.dash-sidebar-brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.dash-sidebar-nav {
  flex: 1;
  padding: 0 1rem;
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dash-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}

.dash-nav-link:hover { background: #f9fafb; color: #374151; text-decoration: none; }

.dash-nav-link.active {
  background: #ecfdf5;
  color: #22C365;
  font-weight: 600;
}

.dash-nav-link .nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 9999px;
  line-height: 1;
}

.dash-sidebar-footer {
  padding: 1rem;
  border-top: 1px solid #f3f4f6;
}

.dash-sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
}

.dash-sidebar-user img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.dash-sidebar-user-info { flex: 1; min-width: 0; }
.dash-sidebar-user-info p { margin: 0; }
.dash-sidebar-user-name { font-size: 0.875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-sidebar-user-plan { font-size: 0.75rem; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dash-sidebar-settings { color: #9ca3af; cursor: pointer; background: none; border: none; padding: 0.25rem; }
.dash-sidebar-settings:hover { color: #6b7280; }

/* ===== Main Content ===== */
.dash-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* ===== Mobile Header ===== */
.dash-mobile-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #f3f4f6;
}

@media (min-width: 1024px) {
  .dash-mobile-header { display: none; }
}

.dash-mobile-toolbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

@media (min-width: 640px) {
  .dash-mobile-toolbar { padding: 0 1.5rem; }
}

.dash-mobile-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-mobile-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.dash-mobile-actions button {
  padding: 0.5rem;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
}

.dash-mobile-actions button:hover { background: #f3f4f6; }
.dash-mobile-actions img { width: 20px; height: 20px; opacity: 0.8; }

.dash-mobile-avatar {
  margin-left: 0.5rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #dcfce7;
}

.dash-mobile-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ===== Desktop Header ===== */
.dash-desktop-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

@media (min-width: 1024px) {
  .dash-desktop-header { display: flex; }
}

.dash-desktop-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
}

.dash-desktop-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: #9ca3af;
  flex: 1;
  max-width: 320px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dash-search-box:focus-within {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.1);
}

.dash-search-box img { width: 16px; height: 16px; opacity: 0.5; flex-shrink: 0; }

.dash-search-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 1rem;
  color: #1a1a1a;
  width: 100%;
  font-family: "Inter", sans-serif;
}

.dash-search-input::placeholder {
  color: #9ca3af;
}

.dash-search-clear {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s;
}

.dash-search-clear:hover {
  color: #DC2626;
}

/* Mobile search bar */
.dash-mobile-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 1rem 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 0.875rem;
}

.dash-mobile-search:focus-within {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.1);
}

.dash-mobile-search img { width: 16px; height: 16px; opacity: 0.5; flex-shrink: 0; }

.dash-mobile-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 1rem;
  color: #1a1a1a;
  width: 100%;
  font-family: "Inter", sans-serif;
}

.dash-mobile-search input::placeholder { color: #9ca3af; }

@media (min-width: 1024px) {
  .dash-mobile-search { display: none; }
}

/* Search toggle button (desktop) */
.dash-search-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: #9ca3af;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  transition: border-color 0.2s, background 0.2s;
}

.dash-search-toggle:hover {
  border-color: #22c55e;
  background: #f0fdf4;
}

.dash-search-toggle img { width: 16px; height: 16px; opacity: 0.5; }

/* Search box open animation */
.dash-search-open {
  animation: searchSlideIn 0.2s ease-out;
}

@keyframes searchSlideIn {
  from { opacity: 0; max-width: 0; padding: 0; }
  to { opacity: 1; max-width: 320px; }
}

/* Close button inside search */
.dash-search-close {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.125rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s;
}

.dash-search-close:hover {
  color: #1a1a1a;
}

.dash-logout-btn {
  padding: 0.5rem 1.25rem;
  background: #fff;
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 0.5rem;
  color: #DC2626;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

.dash-logout-btn:hover { background: #fef2f2; }

/* ===== Filters ===== */
.dash-filters {
  background: #fafafb;
  border-bottom: 1px solid #e5e7eb;
  padding: 1rem;
}

@media (min-width: 640px) { .dash-filters { padding: 1rem 1.5rem; } }
@media (min-width: 1024px) { .dash-filters { padding: 1rem 2rem; } }

.dash-filters-inner { max-width: 80rem; margin: 0 auto; }

.dash-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.dash-filters-header h2 { font-size: 0.875rem; font-weight: 600; margin: 0; }

.dash-filters-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #22C365;
  background: none;
  border: none;
  cursor: pointer;
}

.dash-filters-toggle img { width: 14px; height: 14px; }

.dash-status-label { font-size: 12px; color: #6b7280; margin-bottom: 0.75rem; }

.dash-status-pills {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding-bottom: 0.25rem;
}

.dash-status-pills::-webkit-scrollbar { display: none; }

.dash-pill {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  white-space: nowrap;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s;
  background: #fff;
}

.dash-pill.active { background: #22C365; color: #171a1f; border-color: transparent; }
.dash-pill.active img { filter: brightness(0); }
.dash-pill.healthy { border-color: #1DB440; color: #1DB440; }
.dash-pill.healthy:hover { background: #ecfdf5; }
.dash-pill.warning { border-color: #F59F0A; color: #F59F0A; }
.dash-pill.warning:hover { background: #fffbeb; }
.dash-pill.critical { border-color: #fecaca; color: #ef4444; background: #fef2f2; }
.dash-pill.critical:hover { background: #fee2e2; }

/* ===== Plant Cards Grid ===== */
.dash-grid-section { padding: 1rem; flex: 1; }
@media (min-width: 640px) { .dash-grid-section { padding: 1.5rem; } }
@media (min-width: 1024px) { .dash-grid-section { padding: 2rem; } }

.dash-grid {
  max-width: 80rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 768px) { .dash-grid { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; } }
@media (min-width: 1280px) { .dash-grid { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; } }

/* ===== Plant Card ===== */
.plant-card {
  background: #fff;
  border-radius: 20px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s;
}

.plant-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.plant-card-img {
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
  background: #f3f4f6;
}

.plant-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
}

.plant-card:hover .plant-card-img img { transform: scale(1.05); }

.plant-card-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  border: 1px solid #e5e7eb;
}

.plant-card-badge.mature { background: #22C365; color: #171a1f; border-color: transparent; }
.plant-card-badge.sprout { background: #1FD6C7; color: #fff; border-color: transparent; }

.plant-card-critical-overlay {
  position: absolute;
  inset: 0;
  background: rgba(239, 68, 68, 0.1);
}

.plant-card-body { padding: 0.75rem; flex: 1; display: flex; flex-direction: column; }
@media (min-width: 640px) { .plant-card-body { padding: 1rem; } }

.plant-card-body h3 { font-size: 0.875rem; font-weight: 600; margin: 0 0 0.5rem; }

.plant-card-stats { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }

.plant-card-stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 11px;
  color: #6b7280;
}

.plant-card-stat img { width: 10px; height: 10px; }

.plant-card-stat.critical { color: #ef4444; font-weight: 500; }

.plant-card-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }

.plant-card-time {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 10px;
  color: #9ca3af;
}

.plant-card-time img { width: 10px; height: 10px; opacity: 0.7; }

.plant-status-dot-wrapper {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(229,231,235,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.plant-status-dot-wrapper.critical-border { border-color: rgba(254,202,202,0.5); }

.plant-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  opacity: 0.7;
  position: relative;
}

.plant-status-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: dash-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  background-color: currentColor;
  opacity: 0.4;
}

@keyframes dash-pulse {
  0% { transform: scale(0.8); opacity: 0.5; }
  100% { transform: scale(2.4); opacity: 0; }
}

.dot-green { background: #1DB440; color: #1DB440; }
.dot-warning { background: #F59F0A; color: #F59F0A; }
.dot-critical { background: #EF4343; color: #EF4343; }

.plant-card-critical-bar {
  height: 2px;
  background: #ef4444;
}

/* ===== FAB ===== */
.dash-fab {
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  background: #22C365;
  color: #171a1f;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(34,195,101,0.3);
  border: none;
  cursor: pointer;
  z-index: 40;
  transition: transform 0.2s;
}

@media (min-width: 640px) { .dash-fab { bottom: 2rem; right: 2rem; } }

.dash-fab:hover { transform: scale(1.1); }
.dash-fab:active { transform: scale(0.95); }
.dash-fab img { width: 28px; height: 28px; }

/* ===== Bottom Nav (Mobile) ===== */
.dash-bottom-nav {
  position: sticky;
  bottom: 0;
  width: 100%;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}

@media (min-width: 1024px) { .dash-bottom-nav { display: none; } }

.dash-bottom-nav-inner { display: flex; height: 64px; }

.dash-bottom-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  color: #6b7280;
  text-decoration: none;
  position: relative;
}

.dash-bottom-nav-link:hover { text-decoration: none; }
.dash-bottom-nav-link.active { color: #22C365; }
.dash-bottom-nav-link img { width: 24px; height: 24px; }
.dash-bottom-nav-link span { font-size: 10px; font-weight: 500; }
.dash-bottom-nav-link.active span { font-weight: 700; }

.dash-bottom-nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 18px);
  background: #ef4444;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #fff;
}

/* ===== Profile Popup ===== */
.profile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 999;
  animation: fadeIn 0.15s ease-out;
}

.profile-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: #fff;
  border-radius: 1rem;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: popupSlideIn 0.2s ease-out;
  overflow: hidden;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popupSlideIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.profile-popup-header {
  background: linear-gradient(135deg, #166534, #22c55e);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.profile-popup-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid #fff;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.profile-popup-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  font-size: 1.25rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.profile-popup-close:hover {
  background: rgba(255, 255, 255, 0.35);
}

.profile-popup-body {
  padding: 1.25rem 1.5rem 1.5rem;
}

.profile-popup-name {
  font-family: "Alegreya", serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #164e33;
  margin: 0;
  text-align: center;
}

.profile-popup-email {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0.25rem 0 0;
  text-align: center;
}

.profile-popup-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 1rem 0;
}

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

.profile-popup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.profile-popup-label {
  font-size: 0.8rem;
  color: #9ca3af;
  font-weight: 500;
}

.profile-popup-value {
  font-size: 0.875rem;
  color: #1a1a1a;
  font-weight: 600;
}

.profile-popup-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 0.5rem;
  color: #DC2626;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  transition: background 0.2s;
}

.profile-popup-logout:hover {
  background: #FEE2E2;
}

.profile-popup-logout svg {
  flex-shrink: 0;
}

/* ===== Mic Button ===== */
.dash-mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  color: #6B7280;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.dash-mic-btn:hover {
  color: #22C365;
  background: rgba(34, 195, 101, 0.1);
}

.dash-mic-btn.listening {
  color: #DC2626;
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
