/*
 * FocusFrog application styles
 * Green palette: bright, fresh, fun
 */

@font-face {
  font-family: "Rock Salt";
  src: url("/assets/RockSalt-Regular-6a5464e4.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --green-50:  #f0fdf4;
  --green-100: #dcfce7;
  --green-200: #bbf7d0;
  --green-300: #86efac;
  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-800: #166534;
  --green-900: #14532d;
  --white:     #ffffff;
  --gray-100:  #f3f4f6;
  --gray-200:  #e5e7eb;
  --gray-300:  #d1d5db;
  --gray-500:  #6b7280;
  --gray-700:  #374151;
  --gray-900:  #111827;
  --danger:    #ef4444;
  --danger-light: #fef2f2;
}

/* ── Reset & Base ── */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--green-50);
  color: var(--gray-700);
  line-height: 1.6;
  display: grid;
  grid-template-areas:
    "header header"
    "sidebar main";
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── App Header ── */

.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 3.25rem;
  background: var(--white);
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-200);
  z-index: 100;
}

.header-brand {
  flex-shrink: 0;
  width: 208px; /* 240px sidebar - 2*1.5rem padding alignment */
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Rock Salt", cursive;
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--green-800);
  text-decoration: none;
}

.header-logo:hover {
  color: var(--green-700);
}

.header-logo-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.header-search {
  flex: 1;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 0.375rem;
  font-size: 0.85rem;
  background: var(--gray-100);
  color: var(--gray-700);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.search-input::placeholder {
  color: var(--gray-500);
  opacity: 0.6;
}

.search-input:focus {
  border-color: var(--green-400);
  background: var(--white);
  color: var(--gray-900);
}

.header-user {
  margin-left: auto;
  position: relative;
}

/* ── User Menu Dropdown (details/summary) ── */

.user-menu {
  position: relative;
}

.user-menu-trigger {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0.25rem;
  border-radius: 50%;
  transition: background 0.15s;
}

.user-menu-trigger::-webkit-details-marker {
  display: none;
}

.user-menu-trigger::marker {
  display: none;
  content: "";
}

.user-menu-trigger:hover {
  background: var(--gray-100);
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  background: var(--white);
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
  min-width: 200px;
  padding: 0.35rem 0;
  z-index: 200;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-700);
  text-decoration: none;
  transition: background 0.1s;
  cursor: pointer;
  width: 100%;
  border: none;
  background: none;
  font-family: inherit;
  line-height: 1.4;
}

.user-menu-item:hover {
  background: var(--green-50);
  color: var(--green-800);
}

.user-menu-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--gray-500);
}

.user-menu-item:hover .user-menu-icon {
  color: var(--green-700);
}

.user-menu-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 0.25rem 0;
}

/* Sign out uses button_to which wraps in a form — style the form and inner button */
form.user-menu-sign-out {
  display: block;
  padding: 0;
  border: none;
  background: none;
  width: 100%;
}

form.user-menu-sign-out button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--danger);
  text-decoration: none;
  transition: background 0.1s;
  cursor: pointer;
  width: 100%;
  border: none;
  background: none;
  font-family: inherit;
  line-height: 1.4;
  text-align: left;
}

form.user-menu-sign-out button:hover {
  background: var(--danger-light);
}

form.user-menu-sign-out .user-menu-icon {
  color: var(--danger);
}

/* ── Sidebar (nav) ── */

.sidebar {
  grid-area: sidebar;
  background: var(--white);
  color: var(--gray-700);
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 0.75rem 0;
}

.sidebar-nav-top,
.sidebar-nav-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-nav-bottom {
  border-top: 1px solid var(--gray-200);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.5rem;
  color: var(--gray-700);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: var(--green-50);
  color: var(--green-800);
}

.sidebar-link.active {
  background: var(--green-100);
  color: var(--green-800);
  font-weight: 600;
}

/* Applied directly to the SVG element by the icon helper */
.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Content Area ── */

.content-area {
  grid-area: main;
  min-height: 0;
  overflow-y: auto;
}

/* ── Main Content ── */

.main-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Typography ── */

h1 {
  color: var(--gray-900);
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

h2 {
  color: var(--green-900);
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

a {
  color: var(--green-700);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  color: var(--green-600);
}

/* ── Flash Messages ── */

.flash-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.flash {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  opacity: 1;
  transition: opacity 0.6s ease-out;
}

.flash-fade-out {
  opacity: 0;
}

.flash-notice {
  background: rgba(220, 252, 231, 0.85);
  color: var(--green-800);
  border: 1px solid var(--green-200);
}

.flash-alert {
  background: rgba(254, 242, 242, 0.85);
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* ── Quick Add ── */

.quick-add {
  margin-bottom: 1.5rem;
}

.quick-add input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--green-200);
  border-radius: 0.5rem;
  font-size: 1rem;
  background: var(--white);
  color: var(--gray-700);
  outline: none;
  transition: border-color 0.15s;
}

.quick-add input[type="text"]:focus {
  border-color: var(--green-400);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

.quick-add input[type="text"]::placeholder {
  color: var(--gray-300);
}

/* ── Inbox Item Cards ── */

.inbox-item-card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--green-400);
  transition: box-shadow 0.15s;
  display: block;
  color: inherit;
  text-decoration: none;
  font-weight: normal;
}

.inbox-item-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  color: inherit;
}

.inbox-item-card .card-title {
  color: var(--gray-900);
  font-weight: 600;
  font-size: 0.95rem;
}

.inbox-item-card .card-body {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.inbox-item-card .card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn-small {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

/* ── Buttons ── */

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.4;
}

.btn-primary {
  background: var(--green-500);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--green-600);
  color: var(--white);
}

.btn-secondary {
  background: var(--white);
  color: var(--green-700);
  border: 2px solid var(--green-200);
}

.btn-secondary:hover {
  border-color: var(--green-400);
  background: var(--green-50);
}

.btn-danger {
  background: var(--white);
  color: var(--danger);
  border: 2px solid #fecaca;
}

.btn-danger:hover {
  background: var(--danger-light);
}

.actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ── Forms ── */

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.25rem;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--gray-200);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  color: var(--gray-700);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group input[type="date"]:focus,
.form-group textarea:focus {
  border-color: var(--green-400);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

/* ── Error Messages ── */

.form-errors {
  background: var(--danger-light);
  color: var(--danger);
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid #fecaca;
}

.form-errors h2 {
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.form-errors ul {
  padding-left: 1.25rem;
  margin: 0;
}

/* ── Show Page ── */

.inbox-item-detail {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--green-400);
}

.inbox-item-detail .detail-title {
  color: var(--gray-900);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.inbox-item-detail .detail-body {
  color: var(--gray-700);
  font-size: 0.95rem;
  line-height: 1.7;
}

.inbox-item-detail .detail-body.empty {
  color: var(--gray-300);
  font-style: italic;
}

/* ── Due Date ── */

.due-date {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--gray-500);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

.due-date-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Calendar Accounts ── */

.calendar-account-card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.account-name {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.95rem;
}

.account-detail {
  color: var(--gray-500);
  font-size: 0.8rem;
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-small {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
}

/* ── Calendar List (under accounts) ── */

.calendar-list {
  margin: -0.25rem 0 0.75rem 0;
  padding: 0.5rem 1.25rem;
  background: var(--green-50);
  border-radius: 0 0 0.75rem 0.75rem;
  border-top: 1px solid var(--green-100);
}

.calendar-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.85rem;
}

.calendar-color-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.calendar-name {
  flex: 1;
  color: var(--gray-700);
}

.calendar-color-form {
  display: inline;
  flex-shrink: 0;
}

.calendar-color-picker {
  width: 1.4rem;
  height: 1.4rem;
  padding: 0;
  border: 2px solid var(--gray-200);
  border-radius: 50%;
  cursor: pointer;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}

.calendar-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.calendar-color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.calendar-color-picker::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.calendar-toggle-form {
  display: inline;
}

.calendar-toggle {
  accent-color: var(--green-600);
  cursor: pointer;
}

/* ── Calendar Month View ── */

/* When the calendar view is shown, allow the content to be wider */
.main-content:has(.cal-grid) {
  max-width: 1100px;
}

.cal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.cal-nav {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.cal-nav-icon {
  width: 16px;
  height: 16px;
}

.cal-title {
  font-size: 1.5rem;
  margin-bottom: 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--gray-200);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--gray-200);
  gap: 1px;
}

.cal-weekday-header {
  background: var(--green-50);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  padding: 0.5rem 0.25rem;
}

.cal-day {
  background: var(--white);
  min-height: 6.5rem;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.cal-day-outside {
  background: var(--gray-100);
}

.cal-day-outside .cal-day-number {
  color: var(--gray-300);
}

.cal-day-number {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  line-height: 1;
  padding: 0.15rem 0.25rem;
  align-self: flex-end;
}

.cal-today-badge {
  background: var(--green-500);
  color: var(--white);
  border-radius: 50%;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.cal-day-events {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  flex: 1;
}

.cal-event-pill {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.1rem 0.3rem;
  font-size: 0.7rem;
  line-height: 1.3;
  border-radius: 0.2rem;
  border-left: 3px solid var(--green-500);
  background: var(--green-50);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: default;
}

.cal-event-pill:hover {
  background: var(--green-100);
}

.cal-event-all-day {
  background: var(--green-100);
  font-weight: 600;
}

.cal-event-all-day:hover {
  background: var(--green-200);
}

.cal-event-time {
  color: var(--gray-500);
  font-size: 0.65rem;
  flex-shrink: 0;
}

.cal-event-summary {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--gray-900);
}

/* ── Poll / Waiting Page ── */

.poll-container {
  max-width: 500px;
  margin: 2rem auto;
}

.poll-card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.poll-card h2 {
  color: var(--gray-900);
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.poll-card p {
  color: var(--gray-600);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.poll-actions {
  margin-bottom: 1.5rem;
}

.poll-status {
  color: var(--gray-500);
  font-size: 0.85rem;
  font-style: italic;
}

/* ── Empty States ── */

.empty-state {
  text-align: center;
  color: var(--gray-500);
  font-size: 1rem;
  padding: 3rem 1rem;
}

/* ── Auth Layout ── */

.auth-body {
  display: flex;
  grid-template-areas: none;
  grid-template-columns: none;
  grid-template-rows: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--green-50);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 2rem 1.5rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo-image {
  display: block;
  margin: 0 auto 0.5rem;
  height: 80px;
  width: auto;
}

.auth-logo-text {
  font-family: "Rock Salt", cursive;
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--green-800);
}

.form-card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.form-card h2 {
  color: var(--gray-900);
  font-size: 1.25rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.form-card .form-group input[type="email"],
.form-card .form-group input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--gray-200);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  color: var(--gray-700);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

.form-card .form-group input[type="email"]:focus,
.form-card .form-group input[type="password"]:focus {
  border-color: var(--green-400);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2);
}

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

.form-check label {
  display: inline;
  font-weight: normal;
  font-size: 0.85rem;
}

.form-check input[type="checkbox"] {
  accent-color: var(--green-600);
}

.form-hint {
  color: var(--gray-500);
  font-size: 0.8rem;
  margin: 0.15rem 0 0.25rem;
}

.form-actions {
  margin-top: 1.25rem;
}

.btn-full {
  width: 100%;
  text-align: center;
}

.auth-links {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.85rem;
}

.auth-links p {
  margin-bottom: 0.35rem;
}

/* ── Avatars ── */

.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.avatar-sm, .avatar-sm svg {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.avatar-lg, .avatar-lg svg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
}

/* ── Profile Page ── */

.profile-card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.profile-details {
  flex: 1;
  min-width: 0;
}

.profile-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900);
}

.profile-email {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-top: 0.15rem;
}

.profile-avatar-edit {
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: center;
}

/* ── User Management (Admin) ── */

.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-card {
  background: var(--white);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.user-email {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.95rem;
}

.user-role {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-admin {
  background: var(--green-100);
  color: var(--green-800);
}

.badge-user {
  background: var(--gray-100);
  color: var(--gray-500);
}

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

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

.form-value {
  font-size: 0.9rem;
  color: var(--gray-700);
  padding: 0.4rem 0;
}

