/**
 * Delegate App - Native Mobile UI Overrides
 * iOS/Android-inspired styling
 */

* {
    -webkit-tap-highlight-color: transparent;
}

/* Safe areas & base */
.app-shell {
    min-height: 100vh;
    background: #f2f2f7;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Header - native app bar */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--theme-primary);
    color: white;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0));
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.app-header-left .app-brand {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.app-header-left .app-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
}
.app-menu-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    border-radius: 10px;
}
.app-menu-btn:active {
    background: rgba(255,255,255,0.2);
}

/* Hamburger menu overlay & panel */
.app-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}
.app-menu-overlay.open {
    opacity: 1;
    visibility: visible;
}
.app-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 260px;
    max-width: 85vw;
    background: #fff;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    padding: calc(16px + env(safe-area-inset-top, 0)) 0 env(safe-area-inset-bottom, 0);
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.app-menu.open {
    transform: translateX(0);
}
.app-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    color: #1d1d1f;
    text-decoration: none;
    font-weight: 500;
    font-size: 1rem;
}
.app-menu-item i {
    font-size: 1.25rem;
    color: #8e8e93;
}
.app-menu-item.active {
    color: var(--theme-primary);
}
.app-menu-item.active i {
    color: var(--theme-primary);
}
.app-menu-item:active {
    background: #f2f2f7;
}

/* Main content */
.app-main {
    padding: 16px;
    padding-top: 0 !important;
    padding-bottom: 100px;
    max-width: 480px;
    margin: 0 auto;
}
.app-main h4, .app-main .app-page-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

/* Native-style cards */
.app-card {
    background: #fff;
    border-radius: 12px;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}
.app-card .card-body {
    padding: 16px;
}
.app-card + .app-card {
    margin-top: 12px;
}

/* List items - iOS style */
.app-list-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.app-list-item:last-child {
    margin-bottom: 0;
}
.app-list-item .app-list-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f2f2f7;
    margin-right: 14px;
    flex-shrink: 0;
}
.app-list-item .app-list-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
}
.app-list-item .app-list-body {
    flex: 1;
    min-width: 0;
}
.app-list-item .app-list-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: #1d1d1f;
}
.app-list-item .app-list-subtitle {
    font-size: 0.8125rem;
    color: #8e8e93;
    margin-top: 2px;
}

/* Segmented control - iOS style tabs */
.app-segmented {
    display: flex;
    background: #e5e5ea;
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 16px;
}
.app-segmented .app-segmented-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #8e8e93;
    transition: all 0.2s;
}
.app-segmented .app-segmented-btn.active {
    background: #fff;
    color: var(--theme-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* Form inputs - native style */
.app-input {
    border-radius: 10px;
    border: 1px solid #e5e5ea;
    padding: 12px 16px;
    font-size: 1rem;
    background: #fff;
}
.app-input:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px rgba(40, 71, 150, 0.15);
}
.app-form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #8e8e93;
    margin-bottom: 6px;
}

/* Buttons */
.app-btn {
    border-radius: 12px;
    padding: 14px 24px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
}
.app-btn-primary {
    background: var(--theme-primary);
    color: white;
}
.app-btn-primary:active {
    opacity: 0.9;
}
.app-btn-icon {
    padding: 12px 16px;
    min-width: 48px;
}
.app-btn-icon i {
    font-size: 1.125rem;
}
.app-btn-secondary {
    background: #e5e5ea;
    color: #1d1d1f;
}
.app-chip {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    background: #e5e5ea;
    color: #1d1d1f;
    border: none;
}
.app-chip:active {
    background: #d1d1d6;
}

/* Bottom tab bar - native */
.app-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0,0,0,0.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.app-tabbar-inner {
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    max-width: 480px;
    margin: 0 auto;
}
.app-tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 12px;
    text-decoration: none;
    color: #8e8e93;
    font-size: 0.625rem;
    font-weight: 500;
    transition: color 0.2s;
}
.app-tabbar a i {
    font-size: 1.25rem;
    margin-bottom: 4px;
}
.app-tabbar a.active {
    color: var(--theme-primary);
}

/* Chat bubbles */
.app-chat-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.9375rem;
    line-height: 1.4;
}
.app-chat-bubble.me {
    background: var(--theme-primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
.app-chat-bubble.them {
    background: #e5e5ea;
    color: #1d1d1f;
    border-bottom-left-radius: 4px;
}
.app-chat-bubble .app-chat-time {
    font-size: 0.6875rem;
    opacity: 0.8;
    margin-top: 4px;
}

/* Schedule day headers */
.app-day-header {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #8e8e93;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 20px 0 8px 0;
}
.app-day-header:first-child {
    margin-top: 0;
}

/* Document row */
.app-doc-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    gap: 14px;
}
.app-doc-row .app-doc-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    background: #f2f2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-primary);
}
.app-doc-row .app-doc-title {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    font-size: 0.9375rem;
}
.app-doc-row .app-doc-dl {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    color: white;
    background: var(--theme-primary);
}

/* Profile avatar */
.app-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
}
.app-avatar-placeholder {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: #e5e5ea;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8e8e93;
    font-size: 2rem;
}

/* Spinner */
.app-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e5ea;
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    animation: app-spin 0.8s linear infinite;
}
@keyframes app-spin {
    to { transform: rotate(360deg); }
}

/* Event landing page */
.event-landing {
    margin: 0 -16px;
    max-width: none;
}
.event-hero {
    position: relative;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--theme-primary) 0%, #1e3570 100%);
    overflow: hidden;
}
.event-banner {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.event-banner.has-image {
    opacity: 0.9;
}
.event-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
}
.event-hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 24px 16px;
}
.event-logo-wrap {
    display: none;
    justify-content: center;
    margin-bottom: 12px;
}
.event-logo {
    max-width: 80px;
    max-height: 80px;
    object-fit: contain;
    border-radius: 12px;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}
.event-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    letter-spacing: -0.02em;
}
.event-body {
    padding: 20px 16px;
    background: #f2f2f7;
}
.event-description {
    display: none;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: #3a3a3c;
    margin: 0 0 20px 0;
}
.event-info-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.event-info-card {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    font-size: 0.9375rem;
    color: #1d1d1f;
}
.event-info-card i {
    font-size: 1.25rem;
    color: var(--theme-primary);
}
#eventSpinner {
    padding: 24px;
}

/* QR Scanner */
.scanner-frame {
    width: 220px;
    height: 220px;
    border: 3px solid rgba(255,255,255,0.8);
    border-radius: 16px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.4);
}
