/* ═══════════════════════════════════════════════════════
   PROGRESS TAXI — Dual Theme System (v10.0)
   Mobile-first | CSS Grid + Flexbox | Cross-browser
   ═══════════════════════════════════════════════════════ */

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

/* ─── THEME VARIABLES ─── */
:root, [data-theme="light"] {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --secondary: #10B981;
    --success: #22C55E;
    --error: #EF4444;
    --warning: #F59E0B;
    --yellow: #F59E0B;
    --green: #22C55E;
    --red: #EF4444;
    --bg: #F3F4F6;
    --bg-secondary: #E5E7EB;
    --paper: #FFFFFF;
    --text: #111827;
    --text-secondary: #4B5563;
    --text-muted: #6B7280;
    --border: #E5E7EB;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
}

[data-theme="dark"] {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --secondary: #8B5CF6;
    --success: #22C55E;
    --error: #EF4444;
    --warning: #F59E0B;
    --yellow: #F59E0B;
    --green: #22C55E;
    --red: #EF4444;
    --bg: #111827;
    --bg-secondary: #1F2937;
    --paper: #1F2937;
    --text: #F9FAFB;
    --text-secondary: #D1D5DB;
    --text-muted: #9CA3AF;
    --border: #374151;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* ─── CSS RESET ─── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
}

/* Hide default scrollbars cross-browser (we'll use custom ones) */
::-webkit-scrollbar { width: 0; height: 0; }
* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Custom scrollbar for chat areas */
.custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}
.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
    opacity: 0.7;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--text);
}

/* Form elements inherit styles */
input, button, textarea, select {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    border: none;
    outline: none;
    background: none;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

button { cursor: pointer; }

/* Images responsive by default */
img, svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ─── APP LAYOUT (Flexbox Structure) ─── */
.app-wrapper {
    display: none;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
    overflow: hidden;
}

.app-wrapper.active {
    display: flex;
}

.app-header {
    flex-shrink: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* iOS notch / Dynamic Island: безопасная зона сверху */
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 10px;
    /* iOS safe area — с увеличенным минимумом для standalone PWA */
    padding-top: max(14px, env(safe-area-inset-top, 14px));
    /* Высота = safe-area + 50px для контента */
    min-height: calc(50px + max(14px, env(safe-area-inset-top, 14px)));
    z-index: 100;
}

/* PWA standalone на iPhone — safe-area-inset-top может быть 0 при black-translucent */
@supports (-webkit-touch-callout: none) {
    /* iOS only */
    .app-header {
        padding-top: max(env(safe-area-inset-top, 48px), 48px);
        min-height: calc(50px + max(env(safe-area-inset-top, 48px), 48px));
    }
}

/* Если safe-area работает и возвращает нормальное значение — используем его */
@supports (padding-top: env(safe-area-inset-top)) {
    @supports (-webkit-touch-callout: none) {
        .app-header {
            padding-top: max(env(safe-area-inset-top), 48px);
            min-height: calc(50px + max(env(safe-area-inset-top), 48px));
        }
    }
}

.app-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
    min-height: 0;
}

.app-footer {
    flex-shrink: 0;
    background: var(--paper);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
    z-index: 100;
}

.app-nav {
    flex-shrink: 0;
    display: flex;
    background: var(--paper);
    border-top: 1px solid var(--border);
    /* Базовая высота 60px + safe area снизу (для iPhone home indicator) */
    height: auto;
    min-height: 60px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    padding-top: 6px;
    z-index: 100;
}

/* ─── CHAT / TAB HEADERS (вложенные в tab-view) ─── */
/* Эти хедеры НЕ нужен safe-area-top — они внутри уже смещённого app-wrapper */
.chat-header {
    flex-shrink: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    min-height: 50px;
    z-index: 50;
}

/* ─── VIEWS & TABS ─── */
.view {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    background: var(--bg);
    will-change: opacity;
}
.view.active { display: flex; }

.view-center {
    justify-content: center;
    align-items: center;
    padding: 24px;
}
.view-center > .card {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.tab-view {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.tab-view.active { display: flex; }

/* Bottom nav items */
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 2px;
    padding: 4px 0;
    transition: color 0.2s ease;
    -webkit-user-select: none;
    user-select: none;
}
.nav-item.active { color: var(--primary); }
.nav-item span {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* ─── COMPONENTS ─── */
.card {
    background: var(--paper);
    border-radius: var(--radius-lg);
    padding: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 700;
    gap: 8px;
    transition: transform 0.15s ease, background-color 0.2s ease;
    width: 100%;
    -webkit-user-select: none;
    user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-green { background: var(--success); color: #fff; }
.btn-red { background: var(--error); color: #fff; }

.btn-premium-blue {
    background: linear-gradient(135deg, #1D4ED8 0%, #3B82F6 60%, #60A5FA 100%);
    color: #fff;
    border: none;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
}
.btn-premium-green {
    background: linear-gradient(135deg, #065f46 0%, #059669 60%, #34D399 100%);
    color: #fff;
    border: none;
    box-shadow: 0 8px 20px rgba(5, 150, 105, 0.3);
}
.btn-premium-purple {
    background: linear-gradient(135deg, #7C3AED 0%, #8B5CF6 60%, #A855F7 100%);
    color: #fff;
    border: none;
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

/* ─── INPUT BLOCKS & PREMIUM INPUTS ─── */
.premium-input {
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    border: none;
    outline: none;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 16px;
    padding: 18px 20px;
    color: var(--text);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
.premium-input:focus {
    border-color: var(--primary);
    background: var(--paper);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15), inset 0 0 0 1px var(--primary);
    transform: translateY(-2px);
}
.premium-input::placeholder {
    color: var(--text-muted);
    font-weight: 500;
    opacity: 0.7;
}

.input-block {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
.input-block:focus-within {
    border-color: var(--primary);
    background: var(--paper);
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.15);
    transform: translateY(-2px);
}
.input-block span {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.input-block input,
.input-block textarea {
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    border: none;
    padding: 8px 0;
}
.input-block input::placeholder,
.input-block textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}
.input-block input:focus,
.input-block textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

[data-theme="dark"] .input-block input:focus,
[data-theme="dark"] .input-block textarea:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.row-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
}
.row-inputs input {
    width: 100%;
    height: 52px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 0 16px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    border: 2px solid transparent;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}
.row-inputs input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}
.row-inputs input:focus {
    border-color: var(--primary);
    background: var(--paper);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ─── DARK THEME: inputs must stand out ─── */
[data-theme="dark"] .row-inputs input {
    background: #2D3748;
    border-color: #4B5563;
    color: #F9FAFB;
}
[data-theme="dark"] .row-inputs input::placeholder {
    color: #9CA3AF;
    opacity: 1;
}
[data-theme="dark"] .row-inputs input:focus {
    border-color: var(--primary);
    background: #374151;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}
[data-theme="dark"] .app-footer {
    background: #1a2235;
    border-top: 1px solid #374151;
}
[data-theme="dark"] #active-order-box {
    background: #2a2000 !important;
    border-color: #b45309 !important;
}

/* ─── TYPOGRAPHY ─── */
.title { font-size: 24px; font-weight: 800; line-height: 1.2; }
.subtitle { font-size: 18px; font-weight: 800; line-height: 1.3; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-muted); }
.text-yellow { color: var(--yellow); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.center { text-align: center; }
.fw-800 { font-weight: 800; }

/* ─── CHAT BUBBLES (Telegram Style) ─── */
.chat-feed {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 100%;
}
.msg-row { display: flex; margin-bottom: 6px; padding: 0 8px; }
.msg-incoming { justify-content: flex-start; }
.msg-outgoing { justify-content: flex-end; }

.bubble {
    max-width: 75%;
    padding: 8px 12px 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.35;
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Incoming: white bubble, dark text */
.msg-incoming .bubble {
    background: #FFFFFF;
    color: #222222;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Outgoing: blue bubble, white text */
.msg-outgoing .bubble {
    background: #5C7BEF;
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.bubble-name {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #6599FF;
}
.msg-outgoing .bubble-name { color: rgba(255,255,255,0.8); }

.bubble-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 2px;
}
.msg-outgoing .bubble-time { text-align: right; }

/* Chat action buttons */
.bubble button svg {
    stroke: #fff !important;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4)) !important;
}

/* Status bubble — adaptive text colors */
.status-bubble {
    background: var(--paper) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
}
.status-bubble span {
    color: var(--text) !important;
}
.status-bubble .bubble-time {
    color: var(--text-muted) !important;
}

/* Dark theme overrides */
[data-theme="dark"] .msg-incoming .bubble {
    background: var(--paper);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
[data-theme="dark"] .bubble-name { color: var(--primary); }

/* ─── STICKERS ─── */
.sticker-card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-width: 280px;
    margin: 24px auto;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sticker-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.16);
}
.sticker-card img {
    width: 100%;
    height: auto;
    min-height: 200px;
    object-fit: contain;
    background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
    padding: 12px;
}
.sticker-card .s-body { padding: 16px 12px; }
.sticker-card .s-car { font-size: 16px; font-weight: 900; margin-bottom: 4px; }
.sticker-card .s-plate {
    display: inline-block;
    padding: 6px 12px;
    background: var(--bg-secondary);
    color: var(--text);
    font-weight: 800;
    border-radius: 8px;
    font-size: 12px;
    margin: 8px 0;
    font-family: monospace;
}
.sticker-card .s-status {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 8px 16px;
    border-radius: 20px;
    color: #fff;
    margin-top: 8px;
}

/* ─── ICONS (CSS Mask) ─── */
.icon {
    display: inline-block;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    flex-shrink: 0;
    background-color: currentColor;
    mask-repeat: no-repeat;
    mask-position: center;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    -webkit-mask-size: contain;
    transition: transform 0.15s ease;
}
.icon:hover {
    transform: scale(1.1);
}

.nav-item .icon {
    filter: none;
}
.nav-item.active .icon {
    filter: none;
}

/* Icon SVG masks */
.i-chat { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E"); }
.i-taxi { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h2'/%3E%3Ccircle cx='7.5' cy='17' r='2.5'/%3E%3Ccircle cx='17.5' cy='17' r='2.5'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h2'/%3E%3Ccircle cx='7.5' cy='17' r='2.5'/%3E%3Ccircle cx='17.5' cy='17' r='2.5'/%3E%3C/svg%3E"); }
.i-user { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3C/svg%3E"); }
.i-send { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='22' y1='2' x2='11' y2='13'/%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='22' y1='2' x2='11' y2='13'/%3E%3Cpolygon points='22 2 15 22 11 13 2 9 22 2'/%3E%3C/svg%3E"); }
.i-sos { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E"); }
.i-bell { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9'/%3E%3Cpath d='M13.73 21a2 2 0 0 1-3.46 0'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9'/%3E%3Cpath d='M13.73 21a2 2 0 0 1-3.46 0'/%3E%3C/svg%3E"); }
.i-set { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0-1.51 1z'/%3E%3C/svg%3E"); }

/* ─── ANIMATIONS ─── */
@keyframes bell-ring {
    0%, 100% { transform: rotate(0); }
    10%, 30% { transform: rotate(12deg); }
    20%, 40% { transform: rotate(-12deg); }
    50% { transform: rotate(0); }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.i-sos:hover { animation: bell-ring 1s ease-in-out infinite; }
.i-bell:hover { animation: bell-ring 0.6s ease-in-out; }

.icon-sos:hover,
.i-chat[data-new="true"]:hover {
    animation: pulse 1.5s ease-in-out infinite;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.3));
}

#sos-badge, #apps-badge {
    animation: badge-pulse 2s ease-in-out infinite;
}

/* ─── PWA INSTALL BANNER ─── */
#install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #111827;
    padding: 14px 16px;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    border-top: 1px solid rgba(255,255,255,0.1);
    font-family: system-ui, -apple-system, sans-serif;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
}

/* ─── SCROLL TO BOTTOM BUTTON ─── */
.scroll-to-top {
    position: fixed;
    right: 10px;
    bottom: 140px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.scroll-to-top.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}
.scroll-to-top svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* ─── UTILITIES ─── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.w-full { width: 100%; }
.m-0 { margin: 0; }
.mt-4 { margin-top: 16px; }

/* ─── RESPONSIVE: TABLET+ ─── */
@media (min-width: 768px) {
    .app-wrapper {
        max-width: 480px;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    .bubble { max-width: 65%; }
    .card { padding: 20px; }
}

/* ─── RESPONSIVE: DESKTOP ─── */
@media (min-width: 1024px) {
    .app-wrapper {
        max-width: 420px;
        box-shadow: var(--shadow-lg);
    }
}

/* ─── REDUCED MOTION ─── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── HIGH CONTRAST ─── */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --text-muted: #555555;
    }
    [data-theme="dark"] {
        --border: #FFFFFF;
        --text-muted: #AAAAAA;
    }
}
