/* ============================================================
   Melloman – Mobile-First Vereinsverwaltung
   ============================================================ */

:root {
    --primary:      #3b82f6;
    --primary-dark: #1d4ed8;
    --accent:       #f59e0b;
    --success:      #10b981;
    --danger:       #ef4444;
    --warning:      #f59e0b;
    --bg:           #f3f4f6;
    --surface:      #ffffff;
    --border:       #e5e7eb;
    --text:         #111827;
    --text-muted:   #6b7280;
    --nav-h:        64px;
    --safe-b:       env(safe-area-inset-bottom, 0px);
    --radius:       12px;
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    padding-bottom: calc(var(--nav-h) + var(--safe-b));
    -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────── */

.app-shell { display: flex; min-height: 100dvh; }

.main-content { flex: 1; min-width: 0; }

/* ── Page-Header ────────────────────────────────────────── */

.page-header {
    background: var(--surface);
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 12px;
}

.page-header h1 {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
}

/* ── Content wrapper ────────────────────────────────────── */

.page-content {
    padding: 16px;
    max-width: 680px;
}

/* ── Cards ──────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    margin-bottom: 12px;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 18px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .15s, transform .1s;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); opacity: .9; }

.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-danger   { background: #fee2e2; color: #991b1b; }
.btn-ghost    { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-block    { width: 100%; }
.btn-sm       { padding: 7px 13px; font-size: 13px; min-height: 36px; border-radius: 8px; }
.btn-icon     { padding: 0; width: 40px; height: 40px; border-radius: 50%; }

/* ── Forms ──────────────────────────────────────────────── */

.form-group  { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-control {
    width: 100%;
    padding: 13px 14px;
    font-size: 16px;          /* prevents iOS zoom */
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color .15s;
    -webkit-appearance: none;
}
.form-control:focus  { border-color: var(--primary); }
.form-control.error  { border-color: var(--danger); }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
    cursor: pointer;
}

.input-wrap          { position: relative; }
.input-wrap .toggle-pw {
    position: absolute;
    right: 13px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; }

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row label { font-size: 15px; font-weight: 500; cursor: pointer; }

.switch { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { display: none; }
.switch-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 14px;
    transition: background .2s;
    cursor: pointer;
}
.switch-slider::before {
    content: '';
    position: absolute;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #fff;
    top: 3px; left: 3px;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .switch-slider            { background: var(--primary); }
.switch input:checked + .switch-slider::before    { transform: translateX(22px); }

/* ── Alerts ─────────────────────────────────────────────── */

.alert {
    padding: 13px 15px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #dbeafe; color: #1e40af; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ── Badges ─────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.badge-superadmin { background: #fef3c7; color: #92400e; }
.badge-admin      { background: #dbeafe; color: #1e40af; }
.badge-member     { background: #f3f4f6; color: #374151; }
.badge-active     { background: #d1fae5; color: #065f46; }
.badge-inactive   { background: #fee2e2; color: #991b1b; }

/* ── User list items ────────────────────────────────────── */

.user-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 14px;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1.5px solid var(--border);
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s;
}
.user-item:active { border-color: var(--primary); }

.avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.user-info        { flex: 1; min-width: 0; }
.user-name        { font-weight: 600; font-size: 15px; }
.user-meta        { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Search bar ─────────────────────────────────────────── */

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 12px;
}
.search-bar i   { color: var(--text-muted); flex-shrink: 0; }
.search-bar input {
    flex: 1; border: none; outline: none;
    font-size: 16px; background: transparent; color: var(--text);
}

/* ── Filter chips ───────────────────────────────────────── */

.chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Stats grid ─────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
}
.stat-value { font-size: 34px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 5px; font-weight: 500; }

/* ── FAB ────────────────────────────────────────────────── */

.fab {
    position: fixed;
    bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(59,130,246,.45);
    text-decoration: none;
    z-index: 150;
    transition: transform .15s;
    -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.92); }
.fab i {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    pointer-events: none;
}

/* ── Bottom Navigation ──────────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--nav-h) + var(--safe-b));
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    padding-bottom: var(--safe-b);
    z-index: 200;
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    gap: 4px;
    -webkit-tap-highlight-color: transparent;
    transition: color .15s;
    min-width: 0;
}
.bottom-nav a i   { font-size: 22px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a:active { opacity: .7; }

/* ── Tenant Switcher ────────────────────────────────────── */

.tenant-switcher {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: #f8faff;
}
.tenant-switcher-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    margin-bottom: 5px;
}
.tenant-select {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 600;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
}
.tenant-select:focus { border-color: var(--primary); }

/* Mobile Tenant Bar */
.tenant-bar-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #f0f7ff;
    border-bottom: 1px solid #bfdbfe;
}
.tenant-select-mobile {
    flex: 1;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 600;
    border: 1.5px solid #bfdbfe;
    border-radius: 8px;
    background: white;
    color: var(--text);
    cursor: pointer;
    outline: none;
    -webkit-appearance: none;
}

/* ── Sidebar (Desktop) ──────────────────────────────────── */

.sidebar {
    display: none;
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px;
    font-weight: 800;
    font-size: 17px;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav      { flex: 1; padding: 10px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 9px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: background .12s, color .12s;
    margin-bottom: 2px;
}
.sidebar-nav a:hover  { background: var(--bg);    color: var(--text); }
.sidebar-nav a.active { background: #eff6ff;       color: var(--primary); font-weight: 600; }
.sidebar-nav a i      { width: 18px; text-align: center; font-size: 15px; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 11px;
}
.sidebar-user .avatar { width: 36px; height: 36px; font-size: 12px; }
.user-details         { flex: 1; min-width: 0; }
.user-details .name   { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details .role   { font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

/* ── Auth layout ────────────────────────────────────────── */

.auth-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    background: linear-gradient(145deg, #1e3a8a 0%, #3b82f6 100%);
    padding: 24px;
    padding-bottom: 0 !important;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 20px;
    padding: 30px 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.22);
    margin-bottom: 24px;
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo img { height: 54px; object-fit: contain; }
.auth-logo h1  { font-size: 22px; font-weight: 800; color: #1e3a8a; margin-top: 10px; }
.auth-logo p   { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

.tenant-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 9px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
}
.tenant-card:active  { border-color: var(--primary); background: #eff6ff; }
.tenant-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

/* ── Card section label ─────────────────────────────────── */

.card-section-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* ── Divider ────────────────────────────────────────────── */

.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ── Empty state ────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state i      { font-size: 48px; margin-bottom: 14px; display: block; opacity: .4; }
.empty-state h3     { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-state p      { font-size: 14px; }

/* ── Confirm dialog ─────────────────────────────────────── */

.confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 0 calc(var(--nav-h) + var(--safe-b)) 0;
}
.confirm-sheet {
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 24px;
    width: 100%;
    max-width: 480px;
}
.confirm-sheet h3     { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.confirm-sheet p      { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }
.confirm-sheet .btns  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Desktop breakpoint ─────────────────────────────────── */

@media (min-width: 768px) {
    body            { padding-bottom: 0; }
    .bottom-nav     { display: none; }
    .sidebar        { display: flex; }
    .main-content   { margin-left: 240px; }
    .page-content   { padding: 24px; max-width: 800px; }
    .page-header    { padding: 16px 24px; }
    .stats-grid     { grid-template-columns: repeat(3, 1fr); }
    .fab            { bottom: 24px; right: 24px; }
    .auth-body      { padding-bottom: 24px !important; }
}
