/*
  Atlas Day UI Kit 1.0
  Стиль: Medical Medium / Clinical Tech.
  Этот файл подключается поверх основного app.css, чтобы внедрить дизайн-токены
  без рискованного редактирования минифицированной сборки.

  Шрифты хранятся локально на сервере Atlas: браузер не отправляет
  IP-адрес и технические данны Google Fonts, а PWA сохраняет типографику офлайн.
*/

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/inter-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/montserrat-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Montserrat";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/montserrat-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191,
    U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Typography */
  --font-heading: "Montserrat", "Avenir Next", Avenir, "Segoe UI", Arial, sans-serif;
  --font-body: "Inter", "Avenir Next", Avenir, "Segoe UI", Arial, sans-serif;

  --text-display-h1-size: 1.75rem;
  --text-display-h1-line: 1.2;
  --text-heading-h2-size: 1.25rem;
  --text-heading-h2-line: 1.3;
  --text-heading-h3-size: 1rem;
  --text-heading-h3-line: 1.35;
  --text-body-large-size: .938rem;
  --text-body-regular-size: .875rem;
  --text-caption-size: .75rem;
  --text-label-size: .688rem;

  /* Core colors */
  --color-bg-main: #F8FAFC;
  --color-bg-header: #0F172A;
  --color-card-bg: #FFFFFF;
  --color-card-border: #E2E8F0;

  --color-text-primary: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-muted: #94A3B8;
  --color-text-on-dark: #FFFFFF;

  --color-accent-cyan: #00B4DB;
  --color-accent-blue: #0083B0;
  --gradient-brand: linear-gradient(135deg, #00B4DB 0%, #0083B0 100%);

  /* Categories */
  --color-cat-budget: #00B4DB;
  --color-cat-patients: #2563EB;
  --color-cat-tasks: #D97706;
  --color-cat-schedule: #7C3AED;

  /* Statuses */
  --color-status-success: #10B981;
  --color-status-warning: #F59E0B;
  --color-status-error: #EF4444;

  /* Backward-compatible aliases used by the current bundle */
  --ink: var(--color-text-primary);
  --ink-2: #1E293B;
  --muted: var(--color-text-secondary);
  --paper: var(--color-bg-main);
  --white: var(--color-card-bg);
  --line: var(--color-card-border);
  --mint: #ECFDF5;
  --blue: #EFF6FF;
  --sand: #FFF7ED;
  --rose: #FEF2F2;
  --coral: var(--color-cat-tasks);
  --teal: var(--color-accent-blue);

  --radius-atlas: 16px;
  --shadow-card: 0 2px 8px rgba(15, 23, 42, .04);
  --shadow-panel: 0 18px 44px rgba(15, 23, 42, .08);
}

html {
  background: var(--color-bg-main);
}

body {
  background:
    radial-gradient(circle at 86% 6%, rgba(0, 180, 219, .12), transparent 30rem),
    radial-gradient(circle at 8% 90%, rgba(16, 185, 129, .10), transparent 26rem),
    var(--color-bg-main);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-body-regular-size);
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font-family: var(--font-body);
}

h1,
h2,
h3,
.brand strong,
.auth-brand strong,
.panel-title h2,
.loan-card > strong,
.kpi strong,
.record header strong,
.patient-route-grid strong,
.patient-bot-hero h1,
.patient-bot-brand strong {
  font-family: var(--font-heading);
}

h1 {
  font-size: clamp(1.75rem, 3.4vw, 3.05rem);
  line-height: 1.12;
}

h2 {
  font-size: var(--text-heading-h2-size);
  line-height: var(--text-heading-h2-line);
}

h3 {
  font-size: var(--text-heading-h3-size);
  line-height: var(--text-heading-h3-line);
}

.eyebrow,
.tag,
.local-badge,
.patient-status,
.account-switcher label,
th {
  font-family: var(--font-heading);
  font-size: var(--text-label-size);
  letter-spacing: .08em;
}

.sidebar,
.patient-bot-header {
  background: var(--color-bg-header);
}

.brand-mark,
.patient-bot-brand > span,
.auth-loading .brand-mark,
.member-avatar {
  background: var(--gradient-brand);
  color: var(--color-text-on-dark);
  font-family: var(--font-heading);
  box-shadow: 0 10px 24px rgba(0, 131, 176, .26);
}

.sidebar nav button.active {
  box-shadow: inset 3px 0 0 var(--color-accent-cyan);
}

.sidebar nav button:hover,
.sidebar nav button.active {
  background: rgba(255, 255, 255, .12);
}

.panel,
.form-card,
.survey,
.backup-card,
.chat-panel,
.patient-card,
.loan-card,
.record,
.stats-panel,
.calendar-scroll,
.patient-prep-card,
.patient-booking,
.patient-faq,
.patient-chat,
.secure-dialog,
.auth-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-atlas);
  box-shadow: var(--shadow-card);
}

.primary,
.file-button {
  background: var(--gradient-brand);
  box-shadow: 0 10px 22px rgba(0, 131, 176, .22);
}

.primary:hover,
.file-button:hover {
  background: linear-gradient(135deg, #04C7F2 0%, #006F99 100%);
}

input,
select,
textarea {
  border-color: #CBD5E1;
  color: var(--color-text-primary);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 180, 219, .18);
}

.local-badge,
.tag.income {
  color: #047857;
  background: #ECFDF5;
  border-color: rgba(16, 185, 129, .28);
}

.auth-error,
.warning,
.tag.urgent,
.tag.expense {
  background: #FEF2F2;
  color: #991B1B;
}

.tag.pale,
.reply-draft,
.reply-quote {
  background: #EFF6FF;
  color: #1E3A8A;
}

.kpi {
  background: var(--color-card-bg);
  border: 1px solid var(--color-card-border);
  border-left: 4px solid var(--color-accent-cyan);
  border-radius: var(--radius-atlas);
  box-shadow: var(--shadow-card);
}

.kpi.mint {
  border-left-color: var(--color-cat-budget);
}

.kpi.blue {
  border-left-color: var(--color-cat-patients);
}

.kpi.sand {
  border-left-color: var(--color-cat-tasks);
}

.kpi.rose {
  border-left-color: var(--color-cat-schedule);
}

.chat-panel {
  background: #0F172A;
  color: #E2E8F0;
  box-shadow: var(--shadow-panel);
}

.chat-messages {
  background:
    radial-gradient(circle at 12% 10%, rgba(0, 180, 219, .14), transparent 18rem),
    radial-gradient(circle at 80% 80%, rgba(65, 88, 208, .16), transparent 24rem),
    #0F172A;
}

.chat-message {
  width: fit-content;
  max-width: min(58%, 620px);
  padding: 9px 12px;
  background: rgba(24, 27, 38, .92);
  border-color: rgba(96, 239, 255, .16);
  border-radius: 8px 16px 16px 16px;
  color: #F8FAFC;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}

.chat-message.own {
  margin-left: auto;
  background: linear-gradient(135deg, rgba(37, 99, 235, .92), rgba(0, 131, 176, .90));
  border-color: rgba(96, 239, 255, .28);
  border-radius: 16px 8px 16px 16px;
}

.chat-message header {
  color: rgba(226, 232, 240, .76);
}

.chat-message header strong {
  color: #60EFFF;
}

.chat-message p {
  margin-top: 5px;
  font-size: .875rem;
  line-height: 1.42;
}

.chat-reactions {
  margin-top: 7px;
  gap: 3px;
}

.chat-reactions button {
  min-width: 28px;
  padding: 3px 6px;
  background: rgba(255, 255, 255, .10);
  color: #F8FAFC;
}

.chat-actions {
  margin-top: 5px;
}

.chat-compose {
  background: rgba(15, 23, 42, .96);
  border-top-color: rgba(226, 232, 240, .12);
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.chat-compose textarea {
  min-height: 48px;
  max-height: 160px;
  border-radius: 18px;
}

.compose-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.compose-tools button,
.emoji-toggle {
  border: 1px solid rgba(226, 232, 240, .14);
  background: rgba(255, 255, 255, .08);
  color: #F8FAFC;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .75rem;
}

.chat-audio,
.pending-media audio {
  width: min(100%, 280px);
  height: 36px;
}

.chat-video-circle {
  width: 168px;
  height: 168px;
  max-width: 52vw;
  max-height: 52vw;
  border: 3px solid rgba(96, 239, 255, .36);
  box-shadow: 0 12px 28px rgba(0, 180, 219, .18);
}

.pending-media {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .08);
  color: #E2E8F0;
}

.kap-widget {
  bottom: max(18px, env(safe-area-inset-bottom));
}

/* 4.8.3: minimum comfortable touch target on sign-in and registration screens. */
.auth-card input,
.auth-card select,
.auth-card textarea,
.auth-card .primary,
.auth-switch button {
  min-height: 44px;
}

@media (width <= 760px) {
  .content {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .chat-panel {
    margin-inline: -8px;
    border-radius: 18px;
  }

  .chat-messages {
    min-height: 52vh;
    max-height: 58dvh;
    padding: 14px 10px;
  }

  .chat-message {
    max-width: 78%;
    padding: 8px 10px;
  }

  .chat-message p {
    font-size: .85rem;
  }

  .chat-compose {
    position: sticky;
    bottom: 0;
    z-index: 15;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .chat-compose textarea {
    min-height: 44px;
  }

  .chat-video-circle {
    width: 148px;
    height: 148px;
    max-width: 46vw;
    max-height: 46vw;
  }

  .kap-widget {
    right: max(6px, env(safe-area-inset-right));
    bottom: calc(82px + env(safe-area-inset-bottom));
    transform: scale(.78);
    transform-origin: right bottom;
  }

  body:has(.neo-chat) .kap-widget {
    top: calc(74px + env(safe-area-inset-top));
    right: max(2px, env(safe-area-inset-right));
    bottom: auto;
    opacity: .88;
    transform: scale(.58);
    transform-origin: right top;
  }

  body:has(.neo-chat) .kap-main {
    width: 72px;
    min-height: 76px;
    padding: 2px;
    font-size: 0;
  }

  body:has(.chat-panel) .kap-popover {
    display: none;
  }

  body:has(.chat-compose textarea:focus) .kap-widget {
    opacity: .28;
    pointer-events: none;
  }
}

@media (width <= 520px) {
  .chat-compose {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .compose-tools {
    grid-column: 1 / -1;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .compose-tools button {
    flex: 0 0 auto;
  }
}
