/* =====================================================================
   Jana Adamdar — app.css
   Глобальные стили поверх Tailwind CDN
   Подключается в includes/header.php
   ===================================================================== */

/* ── Переменные ──────────────────────────────────────────────────── */
:root {
    --brand:  #4c008d;
    --accent: #ffa400;
    --radius: 16px;
}

/* ── Сброс и базовые ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: #111827;
    background: #f8fafc;
    /* Safe area для iOS PWA */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* ── Шрифт ───────────────────────────────────────────────────────── */
@supports (font-variation-settings: normal) {
    body { font-optical-sizing: auto; }
}

/* ── Утилиты бренда ──────────────────────────────────────────────── */
.text-brand   { color: var(--brand); }
.bg-brand     { background-color: var(--brand); }
.border-brand { border-color: var(--brand); }
.text-accent  { color: var(--accent); }
.bg-accent    { background-color: var(--accent); }

/* ── Кнопки ──────────────────────────────────────────────────────── */
.btn-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: background 0.18s, transform 0.1s, box-shadow 0.18s;
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn-brand:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 16px color-mix(in srgb, var(--brand) 30%, transparent);
}

.btn-brand:active { transform: scale(0.97); }

.btn-brand:disabled,
.btn-brand[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Карточки ────────────────────────────────────────────────────── */
.shadow-card {
    box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}

.shadow-card-hover {
    transition: box-shadow 0.2s, transform 0.2s;
}

.shadow-card-hover:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,.10);
    transform: translateY(-2px);
}

/* ── Формы ───────────────────────────────────────────────────────── */
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.form-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    color: #111827;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
}

.form-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent);
}

.form-input::placeholder { color: #9ca3af; }
.form-input:disabled     { background: #f9fafb; color: #6b7280; cursor: not-allowed; }

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

/* ── Event status badges ─────────────────────────────────────────── */
.badge-planned   { background: #dbeafe; color: #1d4ed8; }
.badge-ongoing   { background: #d1fae5; color: #065f46; }
.badge-completed { background: #e0e7ff; color: #3730a3; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-draft     { background: #f3f4f6; color: #6b7280; }

/* ── Уведомления (toast) ─────────────────────────────────────────── */
#ja-toast-container {
    position: fixed;
    bottom: calc(80px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: calc(100% - 32px);
    max-width: 400px;
}

.ja-toast {
    background: #111827;
    color: #fff;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    animation: toastIn 0.25s ease-out forwards;
    pointer-events: all;
}

.ja-toast.success { background: #065f46; }
.ja-toast.error   { background: #991b1b; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Навигация (мобильный таббар) ───────────────────────────────── */
.tab-bar {
    height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
}

/* ── Drawer анимация ─────────────────────────────────────────────── */
#drawer {
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
}

#drawer.open { transform: translateX(0) !important; }

/* ── Скролл ──────────────────────────────────────────────────────── */
::-webkit-scrollbar             { width: 4px; height: 4px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── QR страница ─────────────────────────────────────────────────── */
.qr-fullscreen {
    position: fixed;
    inset: 0;
    background: var(--brand);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}

/* ── Анимации ────────────────────────────────────────────────────── */
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp  { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
@keyframes pulse    { 0%,100%{opacity:1;} 50%{opacity:.5;} }
@keyframes spin     { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.animate-fade-in    { animation: fadeIn  0.3s ease-out both; }
.animate-slide-up   { animation: slideUp 0.35s ease-out both; }
.animate-spin       { animation: spin    1s linear infinite; }

/* ── Pull-to-refresh индикатор ───────────────────────────────────── */
#ptr-spinner {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    background: #fff;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    opacity: 0;
    transition: opacity 0.2s;
}

/* ── Утилиты ─────────────────────────────────────────────────────── */
.line-clamp-1 { display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical; overflow:hidden; }
.line-clamp-2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.line-clamp-3 { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }

.select-all { user-select: all; -webkit-user-select: all; }

/* ── Prose (описания мероприятий) ───────────────────────────────── */
.prose p     { margin-bottom: 0.75em; }
.prose a     { color: var(--brand); text-decoration: underline; }
.prose ul    { padding-left: 1.25em; list-style: disc; }
.prose ol    { padding-left: 1.25em; list-style: decimal; }
.prose li    { margin-bottom: 0.25em; }
.prose strong{ font-weight: 700; }
.prose h2,
.prose h3    { font-weight: 800; margin: 1em 0 0.4em; }

/* ── Таблицы ─────────────────────────────────────────────────────── */
.table-auto th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; color: #6b7280; padding: 8px 16px; }
.table-auto td { padding: 12px 16px; font-size: 14px; }

/* ── Skeleton-загрузка ───────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-wave 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes skeleton-wave {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Переключатель (toggle) ──────────────────────────────────────── */
.toggle-track {
    width: 44px; height: 24px;
    border-radius: 12px;
    background: #e5e7eb;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle-track.on     { background: var(--brand); }
.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: transform 0.2s;
}

.toggle-track.on::after { transform: translateX(20px); }

/* ── Адаптация для ≥1024px (боковое меню) ───────────────────────── */
@media (min-width: 1024px) {
    .has-sidebar main,
    .has-sidebar .main-content {
        padding-left: 256px;
    }
}

/* ── Печать ──────────────────────────────────────────────────────── */
@media print {
    .no-print, nav, footer, .tab-bar, #drawer, .fab-sos { display: none !important; }
    body { background: #fff; }
    .shadow-card { box-shadow: none; border: 1px solid #e5e7eb; }
}
