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

/* Material Symbols Configuration */
.material-symbols-outlined {
  font-variation-settings:
    'FILL' 0,
    'wght' 400,
    'GRAD' 0,
    'opsz' 24;
  font-size: inherit;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #faf8f5;
  color: #2d3748;
}

/* Loading Screen */

.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
  color: #ecfdf5;
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
}

.loading-icon {
  animation: bounce 1.5s ease-in-out infinite;
  margin-bottom: 1.5rem;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  margin: 0 auto 1rem;
  border: 4px solid rgba(236, 253, 245, 0.2);
  border-top-color: #ecfdf5;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0;
  opacity: 0.9;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Header */

.app-header {
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
  text-align: center;
}

.app-header-main {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-header h1 {
  margin: 0;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.login-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.5rem;
  color: #ffffff;
  font-size: 0.85rem;
  position: relative;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  pointer-events: none;
}

.status-icon {
  font-size: 1.1rem;
  line-height: 1;
  color: #6b7280;
}

.status-text {
  font-size: 0.8rem;
  white-space: nowrap;
  color: #4a5568;
}

.login-status.signed-in .status-icon {
  color: #10b981;
}

.login-status.signed-in .status-text {
  color: #059669;
}

.auth-button {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: 0.5rem;
  color: #4a5568;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1;
}

.auth-button .material-symbols-outlined {
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-button:hover {
  background: #ffffff;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.auth-button:active {
  transform: translateY(0);
}

.auth-button.signed-in {
  background: rgba(236, 253, 245, 0.95);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.3);
}

.home-link {
  color: #f9fafb;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  background: rgba(249, 250, 251, 0.1);
  transition: background 0.2s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1;
  box-sizing: border-box;
  font-weight: 500;
}

.home-link .material-symbols-outlined {
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.home-link:hover {
  background: rgba(249, 250, 251, 0.2);
}

/* Header view tabs */

.view-tabs {
  max-width: 800px;
  margin: 0.3rem auto 0;
  width: 100%;
  display: flex;
  gap: 0.5rem;
}

.view-tab {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1;
}

.view-tab .material-symbols-outlined {
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-tab.active {
  background: rgba(255, 255, 255, 0.95);
  color: #059669;
  font-weight: 500;
}

/* Layout */

.app-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Panels */

.panel {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.08);
}

.panel h2 {
  margin-top: 0;
  font-size: 1.3rem;
}

.panel h3 {
  font-size: 1.1rem;
}

/* Forms */

.field-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.field-row label {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

input[type='text'],
input[type='date'],
select,
textarea {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid #e2e0dd;
  background: #fefdfb;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type='text']:focus,
input[type='date']:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

textarea {
  resize: vertical;
}

button {
  font: inherit;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1.5px solid #d1d0cd;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #4a5568;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

button .material-symbols-outlined {
  font-size: 1.2em;
}

button.primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: transparent;
  font-weight: 600;
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: #4a5568;
  box-shadow: none;
}

button.danger {
  background: #ffffff;
  color: #dc2626;
  border-color: #dc2626;
  border-width: 2px;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

button.primary:hover {
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

button.danger:hover {
  background: #fef2f2;
  box-shadow: 0 4px 8px rgba(220, 38, 38, 0.15);
}

button.ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  box-shadow: none;
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* Strong hidden override so modals really disappear */
.hidden {
  display: none !important;
}

/* Lists & items */

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

.item-list li {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid #f0eeeb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s ease;
}

.item-list li:nth-child(even) {
  background: #faf8f5;
}

.item-list li:hover {
  background: #f3f0ed;
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 0.9rem;
  font-weight: 500;
}

.item-sub {
  font-size: 0.8rem;
  color: #6b7280;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #e5e7eb;
  margin-left: 0.25rem;
}

.badge.scheduled {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge.recommended {
  background: #dcfce7;
  color: #15803d;
}

.badge.hotTub {
  background: #fef3c7;
  color: #92400e;
}

.badge.plant {
  background: #dcfce7;
  color: #166534;
}

.date-group {
  margin-bottom: 0.75rem;
}

.date-group-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #4b5563;
  margin-bottom: 0.25rem;
}

.date-group ul {
  border-radius: 0.5rem;
  border: 1px solid #e2e0dd;
  background: #ffffff;
  overflow: hidden;
}

.date-group li {
  cursor: pointer;
}

.date-group li:nth-child(even) {
  background: #faf8f5;
}

.date-group li:hover {
  background: #f3f0ed;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.panel-actions.left {
  justify-content: flex-start;
}

.panel-actions.center {
  justify-content: center;
}

/* Plant actions */

.plant-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}

.icon-btn {
  padding: 0.5rem;
  border-radius: 0.5rem;
  font-size: 1.2rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.inline-btn {
  display: inline;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  margin-left: 0.4rem;
  border-radius: 0.375rem;
}

.item-actions {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  flex-shrink: 0;
}

.item-actions button {
  font-size: 1.2rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Empty states */

.item-list li.empty,
.empty-message {
  font-size: 0.85rem;
  color: #9ca3af;
  font-style: italic;
}

/* Modals */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 2000;
  overflow-y: auto;
}

.modal-panel {
  max-width: 480px;
  width: 100%;
  margin: auto;
}

.modal-instructions {
  font-size: 0.85rem;
  color: #6b7280;
  margin: -0.5rem 0 1rem 0;
  padding: 0.75rem;
  background: #fef3c7;
  border-radius: 0.5rem;
  border-left: 3px solid #f59e0b;
}

/* Editable notes in modals */

.editable-notes-container {
  margin: -0.5rem 0 1rem 0;
}

.editable-notes {
  font-size: 0.85rem;
  color: #6b7280;
  padding: 0.75rem;
  background: #fef3c7;
  border-radius: 0.5rem;
  border-left: 3px solid #f59e0b;
  cursor: pointer;
  transition: background 0.2s ease;
}

.editable-notes:hover {
  background: #fde68a;
}

.editable-notes:focus {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

.editable-notes-textarea {
  font-size: 0.85rem;
  color: #374151;
  padding: 0.75rem;
  background: #fffbeb;
  border: 2px solid #f59e0b;
  border-radius: 0.5rem;
  width: 100%;
  font-family: inherit;
  resize: vertical;
}

.editable-notes-textarea:focus {
  outline: none;
  border-color: #d97706;
  background: #fff;
}

/* Plant care modal extra sections */

.pc-fert-extra.hidden {
  display: none !important;
}

/* Toast notifications */

.error-toast,
.success-toast {
  position: fixed;
  top: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  max-width: 90%;
  text-align: center;
}

.error-toast.non-blocking,
.success-toast.non-blocking {
  top: 5rem;
  opacity: 0.9;
}

.error-toast {
  background: #dc2626;
  color: #ffffff;
}

.success-toast {
  background: #16a34a;
  color: #ffffff;
}

.error-toast.show,
.success-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.error-toast.non-blocking.show,
.success-toast.non-blocking.show {
  opacity: 0.9;
}

/* Mobile styles */
@media (max-width: 768px) {
  .app-header {
    position: relative;
  }

  .app-header-main {
    flex-direction: column;
    align-items: stretch;
  }

  .app-header h1 {
    text-align: center;
  }

  .header-actions,
  .panel-actions.center {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
  }

  .sync-indicator,
  .auth-button,
  .home-link,
  .panel-actions.center button {
    width: 100%;
    justify-content: center;
  }

  .view-tabs {
    flex-direction: column;
    gap: 0.5rem;
  }

  .view-tab {
    width: 100%;
    justify-content: center;
  }
}
