/*
 * CozyOS — User Dashboard shell styling
 * File Reference: core/shell/user-dashboard.css
 * Dashboard Prompt 1 — mobile-first, targets a small-Android-class
 * device first (Prompt 1 §19), scales up without a second layout.
 * Additive only: no existing CozyOS stylesheet rule is modified here;
 * no prior stylesheet for #cozy-ud-* selectors existed before this
 * file (confirmed by repository-wide search before writing it).
 */

#cozy-user-dashboard {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100vh;
    box-sizing: border-box;
}

#cozy-ud-surfaces {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px;
    padding-bottom: 84px; /* keep content clear of the fixed bottom nav */
}

.cozy-ud-surface[hidden] { display: none; }

.cozy-ud-surface h3 {
    margin: 4px 0 12px;
    font-size: 1.1rem;
}

.cozy-ud-state-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    border: 1px solid currentColor;
    opacity: 0.8;
}

/* Bottom navigation — five equal, large touch targets. */
#cozy-ud-bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    z-index: 20;
}

.cozy-ud-navtab {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px; /* Prompt 1 §31 — large touch target */
    background: transparent;
    border: none;
    cursor: pointer;
    font: inherit;
}

.cozy-ud-navtab:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

.cozy-ud-navtab-icon { font-size: 1.25rem; line-height: 1; }
.cozy-ud-navtab-label { font-size: 0.7rem; line-height: 1; }

.cozy-ud-navtab[aria-current="page"] {
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    #cozy-ud-surfaces, .cozy-ud-navtab { transition: none !important; }
}

/* Tablet/desktop: same architecture, more breathing room — no second layout. */
@media (min-width: 900px) {
    #cozy-ud-surfaces { padding: 24px 48px 96px; }
}

/*
 * Level 1 master drawer (small-phone) — reuses the exact concept
 * already proven live in admin-workspace.html's own
 * .cozy-shell.cozy-sidebar-mobile-open off-canvas overlay pattern
 * (confirmed by reading that file directly before writing this): a
 * fixed-position slide-in panel plus a dimming backdrop, toggled by one
 * class on the shell root. Because both are position:fixed, neither
 * consumes layout space in #cozy-user-dashboard's flex column, so the
 * existing surfaces/bottom nav already occupy the full available width
 * whenever the drawer is closed — no separate "full width" rule is
 * needed. The <600px breakpoint matches the one other real, live
 * implementation exactly (no canonical CozyOS breakpoint token exists
 * to reuse instead — confirmed by search).
 */
#cozy-ud-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid currentColor;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
    order: -1;
}

#cozy-ud-drawer-overlay {
    display: none;
}

#cozy-ud-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 260px;
    max-width: 80vw;
    overflow-y: auto;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--cozy-surface, #0f1f18);
    color: inherit;
    box-sizing: border-box;
    padding: 16px 12px;
}

.cozy-ud-drawer-heading {
    margin: 8px 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

.cozy-ud-drawer-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
}

.cozy-ud-drawer-link:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

.cozy-ud-drawer-link[aria-current="page"] {
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
}

#cozy-workspace-root:empty {
    display: none;
}

/*
 * Level 2 — application-specific expandable navigation. Pure local
 * disclosure styling; no positioning/animation concept beyond
 * show/hide, since expand/collapse never touches the running
 * application (ApplicationLauncher is only ever called from the real
 * Open/Close sub-links inside the panel, not by expanding the row).
 */
.cozy-ud-drawer-app-toggle .cozy-ud-drawer-app-arrow {
    margin-left: auto;
    transition: transform 0.15s ease;
}

.cozy-ud-drawer-app-toggle[aria-expanded="true"] .cozy-ud-drawer-app-arrow {
    transform: rotate(90deg);
}

.cozy-ud-drawer-app-panel[hidden] { display: none; }

.cozy-ud-drawer-app-panel {
    display: flex;
    gap: 6px;
    padding: 4px 12px 8px 34px;
}

.cozy-ud-drawer-sublink {
    padding: 6px 10px;
    border: 1px solid currentColor;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.8rem;
    cursor: pointer;
}

.cozy-ud-drawer-sublink[hidden] { display: none; }

@media (max-width: 599px) {
    #cozy-ud-menu-btn { display: inline-flex; align-items: center; justify-content: center; }

    #cozy-ud-drawer-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 25;
    }

    #cozy-user-dashboard.cozy-ud-drawer-open #cozy-ud-drawer { transform: translateX(0); }
    #cozy-user-dashboard.cozy-ud-drawer-open #cozy-ud-drawer-overlay { display: block; }
}

@media (prefers-reduced-motion: reduce) {
    #cozy-ud-drawer { transition: none !important; }
}

/*
 * User Profile Phase 1 — Profile surface. Additive, scoped to
 * #cozy-ud-surface-profile; reuses the existing .cozy-living-input /
 * .cozy-btn classes and --cozy-* tokens — no new design system.
 * Mobile-first: single column, every control width:100% with
 * border-box sizing, long text wraps, so nothing can force horizontal
 * scroll on a ~360px Android screen.
 */
#cozy-ud-profile-card {
    max-width: 480px;
    min-width: 0;
    box-sizing: border-box;
    padding-bottom: 96px; /* keep the last controls clear of the fixed bottom navigation */
}

#cozy-ud-profile-card [hidden] { display: none !important; }

.cozy-ud-profile-block {
    margin-bottom: 20px;
    min-width: 0;
}

.cozy-ud-profile-block h4 { margin: 4px 0 10px; }

.cozy-ud-avatar-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.cozy-ud-avatar {
    flex: 0 0 auto;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 600;
    border: 1px solid currentColor;
    box-sizing: border-box;
}

.cozy-ud-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cozy-ud-avatar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.cozy-ud-avatar-actions .cozy-btn { min-height: 44px; }

.cozy-ud-field-label {
    display: block;
    margin: 12px 0 4px;
    font-size: 0.9rem;
}

#cozy-ud-profile-card input[type="text"],
#cozy-ud-profile-card select {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 44px; /* large touch target, matches the bottom-nav rule */
    box-sizing: border-box;
    padding: 8px 12px;
    font: inherit;
    color: inherit;
    background: transparent;
    border: 1px solid var(--cozy-border, rgba(255, 255, 255, 0.35));
    border-radius: 8px;
}

#cozy-ud-profile-card select option { color: #000; background: #fff; }

#cozy-ud-profile-save {
    width: 100%;
    min-height: 44px;
    margin-top: 16px;
}

#cozy-ud-profile-card .cozy-disclosure-note,
.cozy-ud-field-error {
    overflow-wrap: anywhere;
}

.cozy-ud-field-error {
    margin: 4px 0 0;
    min-height: 0;
    font-size: 0.8rem;
    color: var(--cozy-error, #ef4444);
}
.cozy-ud-field-error:empty { display: none; }
