/* ========================================
   FERSO Therapy — Dashboard Styles
   Спокойная, тёплая гамма (зелёный)
   Минимализм, чистота, адаптивность
   ======================================== */

:root {
  --bg: #FAF8F5;
  --bg-alt: #F0EDE8;
  --primary: #5B7F6B;
  --primary-dark: #3D5A45;
  --primary-light: #7BA98A;
  --accent: #C4A882;
  --accent-light: #E8DCC8;
  --text: #2C2C2C;
  --text-light: #6B6B6B;
  --text-muted: #9B9B9B;
  --white: #FFFFFF;
  --success: #7BA98A;
  --warning: #E5B95F;
  --danger: #D4736A;
  --heart: #D4736A;
  --border: #E5E0DA;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --radius-btn: 50px;
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
  --shadow-md: 0 8px 40px rgba(0,0,0,0.10);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w: 260px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, .serif {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 600;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== Layout ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand a {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 8px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--bg-alt);
  color: var(--primary-dark);
}

.sidebar-link.active {
  background: var(--primary);
  color: var(--white);
}

.sidebar-link-icon {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--danger);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.sidebar-user {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--success));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

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

.sidebar-user-name {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.sidebar-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  transition: color var(--transition);
}

.sidebar-logout:hover { color: var(--danger); }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 0.95rem;
  color: var(--text-light);
}

/* ===== Cards ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition);
}

.stat-card:hover { transform: translateY(-2px); }

.stat-card-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.stat-card-value {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-card-change {
  font-size: 0.8rem;
  font-weight: 600;
}

.stat-card-change.up { color: var(--success); }
.stat-card-change.down { color: var(--danger); }
.stat-card-change.neutral { color: var(--text-muted); }

/* ===== Grid Layouts ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,127,107,0.1);
  background: var(--white);
}

.form-input::placeholder,
.form-textarea::placeholder { color: #B0A89E; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B6B6B' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}

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

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  padding: 12px 16px;
  background: #FDE8E8;
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

.form-error.visible { display: block; }

.form-success {
  padding: 12px 16px;
  background: #EDF7F0;
  border-radius: var(--radius-sm);
  color: var(--primary-dark);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

.form-success.visible { display: block; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius-btn);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(91,127,107,0.3);
}

.btn-outline {
  background: transparent;
  color: var(--primary-dark);
  border: 2px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: var(--white);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover {
  background: #c06058;
  transform: translateY(-1px);
}

.btn-sm { padding: 6px 16px; font-size: 0.82rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-block { width: 100%; }

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-alt);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition);
}

.btn-icon:hover { background: var(--border); }

/* ===== Tables ===== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--bg); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #EDF7F0; color: var(--primary-dark); }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FDE8E8; color: var(--danger); }
.badge-neutral { background: var(--bg-alt); color: var(--text-muted); }

/* ===== Progress Mini Chart ===== */
.progress-mini {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 32px;
}

.progress-mini-bar {
  width: 6px;
  border-radius: 3px 3px 0 0;
  background: var(--primary-light);
  transition: height 0.5s ease;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 12px 24px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Charts Container ===== */
.chart-container {
  width: 100%;
  height: 300px;
  position: relative;
}

.chart-container svg {
  width: 100%;
  height: 100%;
}

/* ===== Journal Entry ===== */
.journal-entry {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.journal-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.journal-entry-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.journal-entry-mood {
  font-size: 1.5rem;
}

.journal-entry-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.6;
}

/* ===== Mood Selector ===== */
.mood-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mood-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 3px solid var(--border);
  background: var(--white);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.mood-btn:hover {
  border-color: var(--primary-light);
  transform: scale(1.1);
}

.mood-btn.selected {
  border-color: var(--primary);
  background: var(--bg);
  transform: scale(1.15);
}

/* ===== Client Card ===== */
.client-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
}

.client-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}

.client-card-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

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

.client-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.client-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.client-card-progress {
  flex-shrink: 0;
  text-align: right;
}

.client-card-trend {
  font-size: 0.85rem;
  font-weight: 600;
}

.client-card-trend.up { color: var(--success); }
.client-card-trend.down { color: var(--danger); }
.client-card-trend.stable { color: var(--text-muted); }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-alt) 100%);
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--success));
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 12px;
}

.login-logo h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  color: var(--primary-dark);
}

.login-form .btn { margin-top: 8px; }

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.login-footer a {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

/* ===== Invite Section ===== */
.invite-link-box {
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  margin-top: 16px;
}

.invite-link {
  font-size: 0.85rem;
  color: var(--primary-dark);
  word-break: break-all;
  font-family: monospace;
  background: var(--white);
  padding: 10px 16px;
  border-radius: var(--radius-xs);
  display: inline-block;
  margin-bottom: 8px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.9rem;
  max-width: 360px;
  margin: 0 auto;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ===== Loading ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast-success { background: #EDF7F0; color: var(--primary-dark); border: 1px solid var(--success); }
.toast-error { background: #FDE8E8; color: var(--danger); border: 1px solid var(--danger); }
.toast-info { background: #E0E7FF; color: #3730A3; border: 1px solid #A5B4FC; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Retention Chart ===== */
.retention-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.retention-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}

.retention-track {
  flex: 1;
  height: 24px;
  background: var(--bg-alt);
  border-radius: 12px;
  overflow: hidden;
}

.retention-fill {
  height: 100%;
  border-radius: 12px;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width 0.8s ease;
  display: flex;
  align-items: center;
  padding-left: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--white);
  min-width: 40px;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
  }

  .mobile-menu-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
  }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .form-row { grid-template-columns: 1fr; }

  .login-card { padding: 32px 24px; }

  .page-title { font-size: 1.4rem; }

  .tabs { overflow-x: auto; }

  .tab { padding: 10px 16px; font-size: 0.82rem; white-space: nowrap; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 45;
  }

  .sidebar-overlay.open { display: block; }
}

@media (min-width: 769px) {
  .mobile-header { display: none; }
  .sidebar-overlay { display: none; }
}

@media (max-width: 480px) {
  .main-content { padding: 16px; }

  .stats-grid { grid-template-columns: 1fr; }

  .card { padding: 16px; }

  .page-header { margin-bottom: 20px; }
}

/* ===== Utility ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-small { font-size: 0.85rem; }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mt-5 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.gap-4 { gap: 24px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.hidden { display: none !important; }
