/* ==========================================
   Wellcom Living PWA — Stili mobile globali
   ========================================== */

:root {
    /* Brand palette PWA — Wellcom Silver Living */
    --app-primary: #0F332D;
    --app-primary-dark: #0A2520;
    --app-primary-light: #1A4F46;
    --app-primary-container: #E0F2EF;

    /* Surface */
    --app-bg: #F5F5F5;
    --app-surface: #FFFFFF;
    --app-surface-variant: #F1F8F1;
    --app-border: #E0E0E0;

    /* Text */
    --app-text: #1C1C1E;
    --app-text-secondary: #6B7280;
    --app-text-disabled: #BDBDBD;

    /* Status */
    --app-success: #22C55E;
    --app-success-light: #F0FDF4;
    --app-danger: #EF4444;
    --app-danger-light: #FEF2F2;
    --app-warning: #F59E0B;
    --app-warning-light: #FFFBEB;
    --app-info: #3B82F6;
    --app-info-light: #EFF6FF;

    /* Layout */
    --tab-bar-height: 64px;
    --header-height: 56px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-top: env(safe-area-inset-top, 0px);
}

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

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--app-bg);
    overflow: hidden;
    overscroll-behavior: none;
}

/* ---- Mobile app wrapper ---- */
.mobile-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    background: var(--app-bg);
    padding-top: var(--safe-area-top);
}

/* ---- Page Content ---- */
.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    padding-top: 16px;
    padding-bottom: calc(var(--tab-bar-height) + var(--safe-area-bottom) + 8px);
    -webkit-overflow-scrolling: touch;
}

/* ---- Badge Bar (barra scorrevole orizzontale) ---- */
.badge-bar-container {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    gap: 8px;
    padding: 4px 0 8px;
    margin-bottom: 16px;
}

.badge-bar-container::-webkit-scrollbar {
    display: none;
}

.badge-bar-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.badge-bar-container .mud-chip {
    flex-shrink: 0;
    min-width: fit-content;
    cursor: pointer;
}

/* ---- Bottom Tab Bar ---- */
.tab-bar {
    height: calc(var(--tab-bar-height) + var(--safe-area-bottom));
    background: var(--app-primary);
    border-top: none;
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    padding-bottom: var(--safe-area-bottom);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
    font-weight: 500;
    transition: color 0.15s ease;
    border: none;
    background: none;
    padding: 6px 2px;
    -webkit-tap-highlight-color: transparent;
}

.tab-item.active {
    color: #ffffff;
}

.tab-item .tab-icon {
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-item .tab-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* ---- App Header ---- */
.app-header {
    height: var(--header-height);
    background: var(--app-primary);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding-top: var(--safe-area-top);
    height: calc(var(--header-height) + var(--safe-area-top));
}

.app-header h1 {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    letter-spacing: -0.3px;
}

.app-header .header-back {
    position: absolute;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    color: white;
    cursor: pointer;
    text-decoration: none;
}

.app-header .header-action {
    position: absolute;
    right: 16px;
    font-size: 22px;
    cursor: pointer;
    color: white;
}

/* ---- Role Selector (schermata profilo) ---- */
.role-selector {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 32px 24px;
    background: var(--app-surface);
}

.role-selector-logo {
    text-align: center;
    margin-bottom: 40px;
}

.role-selector-logo .logo-text {
    font-size: 34px;
    font-weight: 800;
    color: var(--app-primary);
    letter-spacing: -0.5px;
}

.role-selector-logo .logo-sub {
    font-size: 15px;
    color: var(--app-text-secondary);
    margin-top: 4px;
}

.role-selector h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--app-text);
    margin-bottom: 8px;
}

.role-selector p {
    font-size: 14px;
    color: var(--app-text-secondary);
    margin-bottom: 24px;
}

.role-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    border: 1.5px solid var(--app-border);
    border-radius: 14px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--app-surface);
    text-align: left;
    width: 100%;
    text-decoration: none;
    font-family: inherit;
}

.role-option:hover,
.role-option:active {
    border-color: var(--app-primary);
    background: var(--app-primary-container);
}

.role-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.role-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--app-text);
    margin-bottom: 2px;
}

.role-desc {
    font-size: 13px;
    color: var(--app-text-secondary);
}

/* ---- Cards ---- */
.app-card {
    background: var(--app-surface);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.app-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--app-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 12px;
}

/* ---- Stat cards ---- */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    background: var(--app-surface);
    border-radius: 14px;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.stat-card .stat-icon { font-size: 24px; }

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--app-text);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--app-text-secondary);
}

/* ---- List items ---- */
.list-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--app-border);
    gap: 12px;
}

.list-item:last-child { border-bottom: none; }

.list-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.list-item-icon.green  { background: var(--app-success-light); }
.list-item-icon.blue   { background: var(--app-info-light); }
.list-item-icon.orange { background: var(--app-warning-light); }
.list-item-icon.red    { background: var(--app-danger-light); }
.list-item-icon.purple { background: #FAF5FF; }

.list-item-body { flex: 1; min-width: 0; }

.list-item-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--app-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--app-text-secondary);
    margin-top: 2px;
}

.list-item-right {
    font-size: 13px;
    color: var(--app-text-secondary);
    flex-shrink: 0;
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green  { background: var(--app-success-light); color: var(--app-success); }
.badge-blue   { background: var(--app-info-light);    color: var(--app-info); }
.badge-red    { background: var(--app-danger-light);  color: var(--app-danger); }
.badge-orange { background: var(--app-warning-light); color: var(--app-warning); }
.badge-gray   { background: #F3F4F6; color: #6B7280; }

/* ---- Buttons ---- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--app-primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: background 0.15s;
    font-family: inherit;
}

.btn-primary:active { background: var(--app-primary-dark); }

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--app-primary);
    border: 1.5px solid var(--app-primary);
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
}

/* ---- Section header ---- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.section-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--app-text);
}

.section-action {
    font-size: 14px;
    color: var(--app-primary);
    cursor: pointer;
    text-decoration: none;
}

/* ---- Greeting ---- */
.greeting { margin-bottom: 20px; }

.greeting-sub {
    font-size: 14px;
    color: var(--app-text-secondary);
    margin-top: 4px;
}

.greeting-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--app-text);
}

/* ---- Alert card ---- */
.alert-card {
    background: var(--app-danger-light);
    border: 1px solid #FECACA;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.alert-card.warning {
    background: var(--app-warning-light);
    border-color: #FDE68A;
}

.alert-card.info {
    background: var(--app-info-light);
    border-color: #BFDBFE;
}

.alert-card .alert-icon { font-size: 20px; flex-shrink: 0; }
.alert-card .alert-text { font-size: 14px; color: var(--app-text); }
.alert-card .alert-title { font-size: 14px; font-weight: 600; margin-bottom: 2px; }

/* ---- Profilo ---- */
.profilo-header {
    text-align: center;
    padding: 24px 16px 16px;
}

.profilo-avatar {
    width: 80px;
    height: 80px;
    border-radius: 40px;
    background: var(--app-primary);
    color: white;
    font-size: 32px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.profilo-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--app-text);
}

.profilo-role {
    font-size: 14px;
    color: var(--app-text-secondary);
    margin-top: 4px;
}

/* ---- Content without tab bar (welcome, auth pages) ---- */
.app-content.no-tab-bar {
    padding-bottom: 16px;
}

.app-content.no-header {
    padding-top: 16px;
}

.app-content.no-tab-bar.no-header {
    padding-top: 16px;
    padding-bottom: 16px;
}

/* ---- Welcome Page ---- */
.welcome-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 24px;
    background: linear-gradient(180deg, var(--app-surface) 0%, #E0F2EF 100%);
}

.welcome-content {
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.welcome-logo {
    text-align: center;
    margin-bottom: 36px;
}

.welcome-icon-circle {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--app-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 4px 16px rgba(15, 51, 45, 0.25);
}

.welcome-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.welcome-logo .logo-text {
    font-size: 28px;
    font-weight: 800;
    color: var(--app-primary);
    letter-spacing: 3px;
}

.welcome-logo .logo-sub {
    font-size: 13px;
    font-weight: 600;
    color: var(--app-text-secondary);
    letter-spacing: 4px;
    margin-top: 2px;
}

.welcome-hero h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--app-text);
    line-height: 1.2;
    margin-bottom: 12px;
    text-align: center;
}

.welcome-description {
    font-size: 15px;
    color: var(--app-text-secondary);
    line-height: 1.6;
    margin-bottom: 32px;
    text-align: center;
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 36px;
}

.welcome-feature {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--app-surface);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.feature-icon-box {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-icon-box.green { background: var(--app-primary-container); }
.feature-icon-box.blue { background: var(--app-info-light); }
.feature-icon-box.purple { background: #FAF5FF; }

.feature-text { flex: 1; min-width: 0; }

.feature-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--app-text);
}

.feature-desc {
    font-size: 13px;
    color: var(--app-text-secondary);
    margin-top: 2px;
}

.welcome-actions {
    margin-bottom: 24px;
}

.welcome-footer {
    text-align: center;
}

.welcome-footer p {
    font-size: 12px;
    color: var(--app-text-disabled);
}

/* ---- MudBlazor icon sizing overrides ---- */
.tab-icon .mud-icon-root { font-size: 22px !important; }
.role-icon .mud-icon-root { font-size: 28px !important; }
.list-item-icon .mud-icon-root { font-size: 20px !important; }
.stat-card .stat-icon .mud-icon-root { font-size: 24px !important; }
.app-header .mud-icon-root { font-size: 22px !important; }

/* ---- Profile resolution ---- */
.profile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.profile-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border-radius: 12px !important;
}

.profile-card:hover,
.profile-card:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}
