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

@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-2: #f1f5f9;
  --bg-sidebar: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.08);
  --calendar-day-hover-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  --text: #374151;
  --text-bright: #0f172a;
  --text-muted: #94a3b8;
  --primary: #059669;
  --primary-hover: #047857;
  --accent: #2563eb;
  --warning: #d97706;
  --danger: #dc2626;
  --positive: #059669;
  --negative: #dc2626;
  --family-bg: #dbeafe;
  --family-text: #1e40af;
  --business-bg: #fef3c7;
  --business-text: #92400e;
  --space-accent: #10b981;
  --space-accent-bg: rgba(16, 185, 129, 0.08);
  --space-accent-border: rgba(16, 185, 129, 0.25);
}

.dark {
  --bg: #070c18;
  --bg-card: #0d1525;
  --bg-sidebar: #0a0f1e;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #cbd5e1;
  --text-bright: #f1f5f9;
  --text-muted: #475569;
  --primary: #10b981;
  --primary-hover: #34d399;
  --accent: #3b82f6;
  --warning: #f59e0b;
  --danger: #ef4444;
  --positive: #10b981;
  --negative: #ef4444;
  --family-bg: #1e3a5f;
  --family-text: #93c5fd;
  --business-bg: #451a03;
  --business-text: #fcd34d;
  --shadow-card: none;
  --shadow-hover: none;
  --calendar-day-hover-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

body[data-space="family"] {
  --space-accent: #3b82f6;
  --space-accent-bg: rgba(59, 130, 246, 0.08);
  --space-accent-border: rgba(59, 130, 246, 0.25);
}

body[data-space="business"] {
  --space-accent: #f59e0b;
  --space-accent-bg: rgba(245, 158, 11, 0.08);
  --space-accent-border: rgba(245, 158, 11, 0.25);
}

body[data-space="all"] {
  --space-accent: #10b981;
  --space-accent-bg: rgba(16, 185, 129, 0.08);
  --space-accent-border: rgba(16, 185, 129, 0.25);
}

.space-indicator {
  height: 3px;
  background: var(--space-accent);
  transition: background 0.3s ease;
}

/* Иконка темы: в тёмной теме показываем солнце (переключить на светлую), в светлой — луну */
.theme-toggle-icon {
  align-items: center;
  justify-content: center;
}
.theme-toggle-icon--sun {
  display: none;
}
html.dark .theme-toggle-icon--sun {
  display: inline-flex;
}
.theme-toggle-icon--moon {
  display: inline-flex;
}
html.dark .theme-toggle-icon--moon {
  display: none;
}

[data-theme="light"] [style*="background: var(--bg-card)"],
[data-theme-user-value="light"] [style*="background: var(--bg-card)"] {
  box-shadow: var(--shadow-card);
}

@media (max-width: 900px) {
  .dashboard-main-grid {
    grid-template-columns: 1fr !important;
  }
}

@layer base {
  * {
    box-sizing: border-box;
  }

  /* Интерактивные кнопки: лёгкое осветление при наведении */
  button:not(:disabled):hover,
  input[type="submit"]:not(:disabled):hover,
  input[type="button"]:not(:disabled):hover,
  input[type="reset"]:not(:disabled):hover {
    filter: brightness(1.07);
  }

  .dark button:not(:disabled):hover,
  .dark input[type="submit"]:not(:disabled):hover,
  .dark input[type="button"]:not(:disabled):hover,
  .dark input[type="reset"]:not(:disabled):hover {
    filter: brightness(1.14);
  }

  body {
    font-family: "Inter", system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
  }

  ::-webkit-scrollbar {
    width: 4px;
    height: 4px;
  }

  ::-webkit-scrollbar-track {
    background: transparent;
  }

  ::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 2px;
  }
}

@layer components {
  .nav-active {
    @apply bg-[color-mix(in_oklch,var(--primary)_12%,transparent)] text-[var(--primary)];
  }

  .nav-idle {
    @apply text-[var(--text-muted)] hover:bg-[color-mix(in_oklch,var(--border)_50%,transparent)] hover:text-[var(--text)];
  }

  .space-active {
    @apply bg-[color-mix(in_oklch,var(--primary)_12%,transparent)] text-[var(--primary)];
  }

  .space-idle {
    @apply text-[var(--text-muted)] hover:text-[var(--text)];
  }

  .badge-urgent {
    @apply bg-red-500/20 text-red-400;
  }

  .badge-warning {
    @apply bg-amber-500/20 text-amber-400;
  }

  /* Desktop sidebar: expanded (icon + label) vs collapsed (icon only) */
  .sidebar-nav {
    @apply flex flex-col border-r border-[var(--border)] bg-[var(--bg-sidebar)] py-4 transition-[width] duration-200 ease-out;
  }

  .sidebar-nav--expanded {
    @apply w-52 px-2;
  }

  .sidebar-nav--collapsed {
    @apply w-16 items-center px-1.5;
  }

  .sidebar-nav--collapsed .sidebar-brand-text,
  .sidebar-nav--collapsed .sidebar-label {
    @apply hidden;
  }

  .sidebar-nav--collapsed .sidebar-link {
    @apply justify-center gap-0 px-0;
  }

  .sidebar-nav--collapsed .sidebar-brand-row {
    @apply flex-col items-center gap-2 px-0;
  }

  .sidebar-nav--collapsed .sidebar-brand-inner {
    @apply w-full flex-none flex-col items-center gap-2;
  }

  .sidebar-nav--collapsed .sidebar-scroll {
    @apply items-center px-0;
  }

  .sidebar-nav--collapsed .sidebar-footer {
    @apply px-0;
  }

  .sidebar-nav--collapsed .sidebar-toggle-wrap {
    @apply w-full justify-center;
  }

  .badge-ok {
    @apply bg-emerald-500/20 text-emerald-400;
  }

  /* Нативные поля в настройках: фон/текст как у карточек, без «белого» select в тёмной теме */
  .account-field-control {
    width: 100%;
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-bright);
    font-size: 13px;
    line-height: 1.25;
    outline: none;
    box-sizing: border-box;
    color-scheme: light;
  }

  .dark .account-field-control {
    color-scheme: dark;
  }

  .account-field-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--space-accent-border);
  }

  select.account-field-control {
    padding-top: 8px;
    padding-bottom: 8px;
    padding-right: 32px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    -webkit-appearance: none;
    appearance: none;
  }

  .dark select.account-field-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  }

  /* Календарь: ячейка дня */
  button.calendar-day-btn {
    transition:
      box-shadow 0.2s ease,
      transform 0.18s ease,
      border-color 0.2s ease,
      filter 0.2s ease;
  }

  button.calendar-day-btn:hover:not(:disabled) {
    box-shadow: var(--calendar-day-hover-shadow);
    transform: translateY(-2px);
    filter: brightness(1.06);
  }

  .dark button.calendar-day-btn:hover:not(:disabled) {
    filter: brightness(1.1);
  }

  /* Стрелки месяца календаря */
  a.calendar-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    border-radius: 10px;
    transition:
      background-color 0.2s ease,
      color 0.2s ease,
      transform 0.15s ease;
  }

  a.calendar-nav-link:hover {
    background: color-mix(in oklch, var(--border) 55%, transparent);
    color: var(--text-bright);
    transform: scale(1.06);
  }
}
.transfer-action-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.transfer-action-btn:hover {
  filter: brightness(0.95);
}

.amount-cell {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.description-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-select {
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-bright);
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}

.category-select:focus {
  border-color: var(--primary);
}

.category-select.empty {
  border-color: rgba(239, 68, 68, 0.4);
}

.merchant-group-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.merchant-row {
  display: grid;
  grid-template-columns: 80px 1fr 200px 90px 32px;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  transition: background 0.1s;
}

.merchant-row:hover {
  background: rgba(255, 255, 255, 0.02);
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

.goal-contribute-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.pagy {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pagy a,
.pagy span {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.pagy .current {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pagy a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

@media (max-width: 960px) {
  .calendar-main-grid {
    grid-template-columns: 1fr !important;
  }
}
