/*
 * Path: TD/m/css/tidiria-webapp.css
 * Version: 0.1.6.1
 * Description: 1:1 Stylesheet für die Tidiria Mobile WebApp / iOS & Android PWA (m.tidiria.com).
 *              Identisches Dark/Light-Design zur Tidiria Android-App inkl. iOS Safari Safe-Area & 100dvh Support.
 */
:root {
    --bg: #0f141c;
    --surface: #161b24;
    --surface-2: #1f2735;
    --bg-card: #1b2230;
    --border: #2c3648;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --accent: #f97316;
    --accent-dark: #ea580c;
    --success: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
    --radius: 14px;
}

[data-theme="light"] {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #e2e8f0;
    --bg-card: #f8fafc;
    --border: #cbd5e1;
    --text: #0f172a;
    --muted: #475569;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg); color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior-y: none;
}

body { display: flex; flex-direction: column; }

.hidden { display: none !important; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.fw-bold { font-weight: 700; }
.small { font-size: 0.82rem; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }

/* Header */
.app-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 8px;
}
.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-logo { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.header-title { font-weight: 800; font-size: 1.05rem; letter-spacing: 0.04em; color: var(--accent); }
.header-sub { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.net-badge {
    font-size: 0.7rem; font-weight: 700; padding: 4px 8px; border-radius: 999px;
    background: rgba(34, 197, 94, 0.16); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.35);
    white-space: nowrap;
}
.net-badge.offline {
    background: rgba(245, 158, 11, 0.16); color: var(--warn); border-color: rgba(245, 158, 11, 0.35);
}

.lang-select {
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 10px; height: 36px; padding: 0 6px; font-size: 0.78rem; font-weight: 700;
    cursor: pointer; font-family: inherit;
}

.icon-btn {
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 10px; width: 36px; height: 36px; font-size: 1rem; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* iOS Home-Screen Install Banner */
.ios-install-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: linear-gradient(90deg, rgba(249, 115, 22, 0.16), rgba(249, 115, 22, 0.07));
    border-bottom: 1px solid rgba(249, 115, 22, 0.35);
    padding: 10px 14px;
    flex-shrink: 0;
}
.ios-install-content { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ios-install-ico { font-size: 1.4rem; flex-shrink: 0; }
.ios-install-title { font-size: 0.82rem; font-weight: 700; color: var(--accent); }
.ios-install-sub { font-size: 0.74rem; color: var(--text); line-height: 1.3; margin-top: 2px; }
.ios-close-btn { width: 30px; height: 30px; font-size: 0.85rem; }

/* Main */
.app-main {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 16px 16px calc(115px + env(safe-area-inset-bottom));
    box-sizing: border-box;
    width: 100%;
    max-width: 680px;
    margin: 0 auto;
}

.tab-view { display: none; }
.tab-view.active { display: block; }

.section-head {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px;
}
.section-head h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }

.pill-count {
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    font-weight: 700; font-size: 0.8rem; padding: 3px 10px; border-radius: 999px;
}
.pill-count.warn { background: rgba(245, 158, 11, 0.2); color: var(--warn); border-color: var(--warn); }

/* Cards */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px;
}
.card-title { font-weight: 700; font-size: 0.98rem; }
.card-sub { font-size: 0.8rem; color: var(--muted); }

.entry-card { display: flex; gap: 12px; cursor: pointer; align-items: flex-start; }
.entry-thumb {
    width: 74px; height: 74px; border-radius: 10px; object-fit: cover;
    background: var(--surface-2); flex-shrink: 0;
}
.entry-thumb-placeholder {
    width: 74px; height: 74px; border-radius: 10px; background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem; flex-shrink: 0;
}
.entry-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.badge {
    font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
    background: var(--surface-2); color: var(--muted);
}
.badge.synced { background: rgba(34, 197, 94, 0.16); color: var(--success); }
.badge.pending { background: rgba(245, 158, 11, 0.18); color: var(--warn); }

/* Forms (min 16px font-size prevents iOS Safari auto-zoom!) */
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 6px; min-width: 0; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 12px; font-size: 16px; font-family: inherit;
    width: 100%; max-width: 100%; min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--accent);
}
.field-row { display: flex; gap: 10px; width: 100%; }
.field-row > .field { flex: 1 1 0; min-width: 0; }

.photo-box { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 12px; }
.photo-buttons { display: flex; gap: 10px; }
.photo-preview-wrap { position: relative; margin-bottom: 10px; }
.photo-preview-wrap img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; display: block; }
.btn-photo-clear {
    position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%;
    border: none; background: rgba(0,0,0,0.7); color: #fff; font-size: 1.2rem; cursor: pointer;
}

.gps-card {
    background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
    border-radius: 10px; padding: 10px 12px;
}
.gps-label { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.gps-value { font-size: 0.88rem; font-weight: 700; margin-top: 2px; }

.toggle-card {
    display: flex; align-items: flex-start; gap: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; cursor: pointer;
}
.toggle-card input { width: 20px; height: 20px; accent-color: var(--accent); margin-top: 2px; flex-shrink: 0; }
.toggle-title { font-weight: 700; font-size: 0.9rem; }
.toggle-sub { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }

/* Buttons */
.btn-primary, .btn-secondary, .btn-chip, .btn-danger {
    border: none; border-radius: 12px; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-family: inherit;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; padding: 10px 16px; font-size: 0.92rem; }
.btn-primary:active { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 10px 14px; font-size: 0.9rem; }
.btn-danger { background: rgba(239, 68, 68, 0.16); color: var(--danger); padding: 8px 12px; font-size: 0.82rem; }
.btn-big { padding: 14px 16px; font-size: 0.96rem; }
.btn-chip { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 6px 12px; font-size: 0.78rem; border-radius: 999px; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }

/* Sync */
.sync-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sync-log { margin-top: 10px; font-size: 0.78rem; color: var(--muted); white-space: pre-line; }

/* Bottom Nav */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; background: var(--surface); border-top: 1px solid var(--border);
    padding: 8px 6px max(16px, calc(8px + env(safe-area-inset-bottom)));
    min-height: 70px; box-sizing: border-box; z-index: 50;
}
.nav-btn {
    flex: 1; background: none; border: none; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 0.72rem; font-weight: 600; padding: 4px 2px; cursor: pointer; position: relative;
    font-family: inherit;
}
.nav-btn .nav-ico { font-size: 1.25rem; }
.nav-btn.active { color: var(--accent); }
.nav-btn-accent { margin-top: -18px; }
.nav-btn-accent .nav-ico {
    background: var(--accent); color: #fff; width: 52px; height: 52px;
    border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.7rem; font-weight: 800; box-shadow: 0 6px 18px rgba(249, 115, 22, 0.45);
    border: 3px solid var(--surface);
}
.nav-dot {
    position: absolute; top: 4px; right: 24%; width: 9px; height: 9px;
    border-radius: 50%; background: var(--warn);
}

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.72); z-index: 100;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
    background: var(--surface); width: 100%; max-width: 600px; max-height: 88vh;
    border-radius: 20px 20px 0 0; padding: 16px 16px max(20px, env(safe-area-inset-bottom));
    display: flex; flex-direction: column;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.modal-head h3 { margin: 0; font-size: 1.08rem; }
.modal-body { overflow-y: auto; font-size: 0.92rem; line-height: 1.5; }
.modal-body img { width: 100%; border-radius: 12px; margin-bottom: 12px; max-height: 280px; object-fit: cover; }

/* Toast */
.toast {
    position: fixed; bottom: calc(82px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 999px;
    font-size: 0.85rem; font-weight: 600; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    max-width: 90vw; text-align: center;
}

.empty-state {
    text-align: center; padding: 36px 16px; color: var(--muted);
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* Entry Type Selection Modal */
.entry-type-sheet { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.entry-type-buttons { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 12px; }
.entry-type-btn {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; padding: 14px 16px; text-align: left; color: var(--text);
    cursor: pointer; transition: all 0.15s ease; font-family: inherit; width: 100%;
}
.entry-type-btn:active {
    background: rgba(249, 115, 22, 0.16); border-color: var(--accent); transform: scale(0.99);
}
.entry-type-ico {
    font-size: 1.8rem; flex-shrink: 0; width: 46px; height: 46px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface); border-radius: 12px; border: 1px solid var(--border);
}
.entry-type-info { flex: 1; min-width: 0; }
.entry-type-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.entry-type-sub {
    font-size: 0.76rem; color: var(--muted); margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entry-type-arrow { font-size: 1.5rem; color: var(--muted); font-weight: 300; }

/* Specific Badge Types */
.badge.badge-insider { background: rgba(249, 115, 22, 0.16); color: var(--accent); }
.badge.badge-biz { background: rgba(59, 130, 246, 0.16); color: #3b82f6; }
.badge.badge-event { background: rgba(168, 85, 247, 0.16); color: #a855f7; }

/* Form Step Tabs (Sub-Reiter) */
.form-step-nav {
    display: flex; gap: 4px; background: var(--surface); padding: 4px;
    border-radius: 12px; margin-bottom: 14px; border: 1px solid var(--border);
    overflow-x: auto;
}
.step-tab {
    flex: 1; min-width: 68px; border: none; background: transparent; color: var(--muted);
    font-size: 0.72rem; font-weight: 700; padding: 8px 4px; border-radius: 8px;
    cursor: pointer; text-align: center; font-family: inherit; white-space: nowrap;
    transition: all 0.15s ease;
}
.step-tab.active {
    background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}
.step-pane { display: none; }
.step-pane.active { display: block; }

.step-nav-footer {
    display: flex; justify-content: space-between; gap: 10px;
    margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border);
}

/* Detailed Opening Hours Widget */
.app-oh-container {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 12px; margin-bottom: 14px;
}
.app-oh-day-row {
    padding: 8px 0; border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 6px;
}
.app-oh-day-row:last-child { border-bottom: none; }
.app-oh-day-head { display: flex; justify-content: space-between; align-items: center; }
.app-oh-status-select {
    padding: 5px 8px; font-size: 0.82rem; font-weight: 600; border-radius: 6px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}
.app-oh-times-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.8rem;
}
.app-oh-time-input {
    width: 92px; padding: 5px 6px; font-size: 0.82rem; border-radius: 6px;
    border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.app-oh-appt-badge {
    display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem;
    color: var(--accent); background: rgba(249, 115, 22, 0.12); padding: 3px 8px; border-radius: 6px;
}

.fav-bucket-card { transition: transform 0.1s ease; }

/* Desktop centering for Bottom Nav */
@media (min-width: 720px) {
    .bottom-nav {
        max-width: 680px;
        left: 50%;
        transform: translateX(-50%);
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        border-radius: 18px 18px 0 0;
    }
}
