/* Токены @bitrix24/b24style v1.0.1 — ТЗ §6. Значения из preset-colors/fonts/border. */

:root {
    --b24-primary:           #2fc6f6;
    --b24-primary-hover:     #11a9d9;
    --b24-primary-bg-on:     #333333;
    --b24-link:              #2066b0;

    --b24-success:           #9dcf00;
    --b24-success-bg:        #f1fbd0;
    --b24-success-bg-on:     #7fa800;
    --b24-success-link:      #506900;

    --b24-alert:             #ff5752;
    --b24-alert-bg:          #ffe8e8;
    --b24-alert-bg-on:       #e92f2a;
    --b24-alert-link:        #9a0703;

    --b24-warning:           #ffa900;
    --b24-warning-bg:        #fff1d6;

    --b24-text:              #333333;
    --b24-text-secondary:    #525c69;
    --b24-text-muted:        #a8adb4;
    --b24-subtle:            #828b95;
    --b24-border:            #e6e8e9;
    --b24-surface-secondary: #edeef0;
    --b24-surface-tertiary:  #eef2f4;
    --b24-bg:                #ffffff;

    --b24-radius:            6px;
    --b24-radius-sm:         8px;
    --b24-radius-lg:         12px;
    --b24-radius-pill:       99rem;
    --b24-border-width:      1px;

    --b24-font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
                Roboto, Ubuntu, 'Helvetica Neue', Arial, sans-serif,
                'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';

    /* Главная кнопка тёмная — актуальный air-дизайн (ТЗ §6.1).
       Голубой вариант: --btn-primary-bg: var(--b24-primary). */
    --btn-primary-bg:  var(--b24-primary-bg-on);
    --btn-primary-fg:  #ffffff;

    --gap:      16px;
    --gap-lg:   24px;
    --tap:      48px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--b24-bg);
    color: var(--b24-text);
    font-family: var(--b24-font);
    font-size: 14px;
    line-height: 20px;
}

.shell {
    max-width: 450px;
    margin: 0 auto;
    padding: var(--gap);
    /* Кнопки не должны прятаться под жестовой полоской iPhone. */
    padding-bottom: calc(var(--gap) + env(safe-area-inset-bottom));
}

:focus-visible {
    outline: 2px solid var(--b24-link);
    outline-offset: 2px;
}

/* --- Шапка --- */

.screen__top {
    display: flex;
    align-items: center;
    min-height: 32px;
    margin-bottom: var(--gap);
}

.screen__top--split { justify-content: space-between; }

.link-back,
.link-button {
    color: var(--b24-link);
    font-size: 13px;
    text-decoration: none;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    font-family: inherit;
    cursor: pointer;
}

.operator {
    color: var(--b24-subtle);
    font-size: 13px;
}

.logout { margin: 0; }

/* --- Карточка --- */

.card {
    padding: var(--gap-lg) var(--gap);
    border: var(--b24-border-width) solid var(--b24-border);
    border-radius: var(--b24-radius-lg);
    background: var(--b24-bg);
}

.card--form { margin-top: 10vh; }

.card__heading {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    line-height: 24px;
}

.card__hint,
.card__note {
    margin: 0 0 var(--gap);
    color: var(--b24-text-secondary);
    font-size: 13px;
    line-height: 18px;
}

.card__note {
    margin: var(--gap) 0 0;
    color: var(--b24-subtle);
    font-size: 12px;
    line-height: 16px;
}

/* --- Участник --- */

.person { text-align: center; }

.person__name {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
    line-height: 24px;
    overflow-wrap: anywhere;
}

.person__company {
    margin: 0 0 4px;
    color: var(--b24-text-secondary);
    font-size: 13px;
    line-height: 16px;
}

.person__meta {
    margin: 0;
    color: var(--b24-text-muted);
    font-size: 12px;
    line-height: 16px;
}

/* --- Состояния экрана: показываем ровно одно --- */

.state { display: none; margin-top: var(--gap-lg); }

.screen[data-state='loading']   .state--loading,
.screen[data-state='ready']     .state--ready,
.screen[data-state='confirmed'] .state--confirmed,
.screen[data-state='already']   .state--already,
.screen[data-state='error']     .state--error,
.screen[data-state='cancelled'] .state--cancelled {
    display: block;
}

/* --- Скелетон --- */

.skeleton {
    background: var(--b24-surface-secondary);
    animation: pulse 1.4s ease-in-out infinite;
}

.skeleton--ring {
    width: 140px;
    height: 140px;
    margin: 0 auto var(--gap);
    border-radius: var(--b24-radius-pill);
}

.skeleton--line {
    height: var(--tap);
    border-radius: var(--b24-radius-sm);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .55; }
}

/* --- Кольцо таймера --- */

.ring {
    position: relative;
    display: block;
    width: 160px;
    height: 160px;
    margin: 0 auto var(--gap);
    padding: 0;
    border: 0;
    border-radius: var(--b24-radius-pill);
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.ring__svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring__track,
.ring__progress {
    fill: none;
    stroke-width: 8;
}

.ring__track { stroke: var(--b24-surface-secondary); }

.ring__progress {
    stroke: var(--b24-success);
    stroke-linecap: round;
    /* 2πr при r=54 */
    stroke-dasharray: 339.29;
    stroke-dashoffset: 0;
}

.ring__label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.ring__seconds {
    font-size: 40px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.ring__caption {
    color: var(--b24-subtle);
    font-size: 12px;
    line-height: 16px;
}

.ring:active { transform: scale(.98); }

/* --- Результат --- */

.result {
    padding: var(--gap-lg) var(--gap);
    border-radius: var(--b24-radius-lg);
    text-align: center;
}

.result--success {
    background: var(--b24-success-bg);
    color: var(--b24-success-link);
}

.result--alert {
    background: var(--b24-alert-bg);
    color: var(--b24-alert-link);
}

.result__icon {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
}

.result--success .result__icon { color: var(--b24-success-bg-on); }
.result--alert   .result__icon { color: var(--b24-alert); }

.result__title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
    line-height: 24px;
}

.result__note {
    margin: 0;
    font-size: 13px;
    line-height: 18px;
}

/* --- Кнопки --- */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--tap);
    margin-top: var(--gap);
    padding: 0 var(--gap);
    border: 0;
    border-radius: var(--b24-radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 500;
    line-height: 20px;
    text-decoration: none;
    cursor: pointer;
}

.btn--primary {
    background: var(--btn-primary-bg);
    color: var(--btn-primary-fg);
}

.btn--primary:hover { background: #1f1f1f; }

.btn--secondary {
    background: var(--b24-surface-secondary);
    color: var(--b24-text-secondary);
}

.btn--secondary:hover { background: #e2e4e7; }

.btn[disabled] {
    opacity: .6;
    cursor: default;
}

/* --- Формы --- */

.form { display: block; }

.field {
    display: block;
    margin-bottom: var(--gap);
}

.field__label {
    display: block;
    margin-bottom: 6px;
    color: var(--b24-text-secondary);
    font-size: 13px;
    line-height: 16px;
}

.field__input {
    width: 100%;
    min-height: var(--tap);
    padding: 0 12px;
    border: var(--b24-border-width) solid var(--b24-border);
    border-radius: var(--b24-radius-sm);
    background: var(--b24-bg);
    color: var(--b24-text);
    font-family: inherit;
    /* 16px, иначе iOS зумит страницу при фокусе. */
    font-size: 16px;
}

.field__input:focus {
    border-color: var(--b24-primary);
    outline: none;
}

.alert {
    margin: 0 0 var(--gap);
    padding: 10px 12px;
    border-radius: var(--b24-radius);
    background: var(--b24-alert-bg);
    color: var(--b24-alert-link);
    font-size: 13px;
    line-height: 18px;
}

/* --- Дашборд --- */

.counter {
    padding: var(--gap-lg) var(--gap);
    border-radius: var(--b24-radius-lg);
    background: var(--b24-surface-tertiary);
    text-align: center;
}

.counter__value {
    margin: 0;
    font-size: 48px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.counter__caption {
    margin: 6px 0 0;
    color: var(--b24-text-secondary);
    font-size: 13px;
    line-height: 16px;
}

.counter__total {
    margin: 4px 0 0;
    color: var(--b24-text-muted);
    font-size: 12px;
    line-height: 16px;
}

.search { margin-top: var(--gap-lg); }

.search__hint {
    margin: -8px 0 8px;
    color: var(--b24-text-muted);
    font-size: 12px;
    line-height: 16px;
}

.manual-badge { margin-top: var(--gap-lg); }

.manual-badge__form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.manual-badge__field {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.manual-badge__submit {
    flex: none;
    width: auto;
    margin-top: 0;
    white-space: nowrap;
}

.feed { margin-top: var(--gap-lg); }

.feed__heading {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    line-height: 24px;
}

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

.list__empty,
.list__item {
    padding: 12px 0;
    border-bottom: var(--b24-border-width) solid var(--b24-border);
}

.list__empty {
    color: var(--b24-text-muted);
    font-size: 13px;
}

.list__item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.list__body {
    flex: 1;
    min-width: 0;
}

.list__link {
    display: block;
    color: inherit;
    font-weight: 500;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.list__meta {
    margin: 2px 0 0;
    color: var(--b24-subtle);
    font-size: 12px;
    line-height: 16px;
}

.badge {
    flex: none;
    padding: 3px 8px;
    border-radius: var(--b24-radius-pill);
    font-size: 12px;
    line-height: 16px;
    white-space: nowrap;
}

.badge--attended {
    background: var(--b24-success-bg);
    color: var(--b24-success-link);
}

.badge--new {
    background: var(--b24-surface-secondary);
    color: var(--b24-text-secondary);
}

.undo-btn {
    flex: none;
    min-height: 32px;
    padding: 0 10px;
    border: var(--b24-border-width) solid var(--b24-border);
    border-radius: var(--b24-radius);
    background: var(--b24-bg);
    color: var(--b24-alert-link);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.undo-btn[disabled] { opacity: .5; cursor: default; }

.list__actions {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.print-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    border: var(--b24-border-width) solid var(--b24-border);
    border-radius: var(--b24-radius);
    background: var(--b24-bg);
    color: var(--b24-text);
    font-size: 12px;
    text-decoration: none;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
    .ring:active { transform: none; }
}
