/* Feature Flags -- phone-first, big bold cards, FAB, full-screen overlays */

* { box-sizing: border-box; }
body {
    background: #F2F2F4;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    color: #1A1A1A;
}

.ff-shell {
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ====================================================================== */
/* HEADER + TOOLBAR                                                       */
/* ====================================================================== */

.ff-header {
    background: #3C3C3C; color: #fff;
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.ff-header h1 {
    margin: 0; flex: 1;
    font-size: 17pt; font-weight: 600; letter-spacing: -0.2px;
}
.ff-back {
    color: #fff; text-decoration: none;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20pt; font-weight: 300;
    border-radius: 50%;
}
.ff-back:hover { background: rgba(255,255,255,0.10); }
.ff-icon-btn {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: inherit;
    border: none; border-radius: 50%;
    cursor: pointer; padding: 0;
}
.ff-icon-btn:hover { background: rgba(0,0,0,0.08); }
.ff-header .ff-icon-btn { color: #fff; }
.ff-header .ff-icon-btn:hover { background: rgba(255,255,255,0.10); }

.ff-toolbar {
    background: #fff; border-bottom: 1px solid #E5E5E8;
    padding: 12px 16px;
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 4;
}
.ff-toolbar input[type="search"] {
    flex: 1;
    padding: 10px 14px;
    font-size: 12pt; font: inherit; font-size: 12pt;
    border: 1px solid #D5D5D9; border-radius: 22px;
    background: #F5F5F7;
    -webkit-appearance: none;
}
.ff-toolbar input[type="search"]:focus {
    outline: none; border-color: #1A73E8;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.18);
}
.ff-stats {
    flex: 0 0 auto;
    font-size: 10.5pt; color: #6A6A6E; font-weight: 500;
    white-space: nowrap;
}

/* ====================================================================== */
/* CARD LIST                                                              */
/* ====================================================================== */

.ff-list {
    flex: 1;
    padding: 12px 14px 90px 14px;       /* bottom clears the FAB */
}

.ff-empty {
    color: #888; font-style: italic;
    padding: 64px 24px; text-align: center;
    font-size: 12pt;
}

.ff-group {
    margin: 22px 4px 10px 4px;
    font-size: 10pt; font-weight: 700;
    color: #888; text-transform: uppercase;
    letter-spacing: 0.7px;
}
.ff-group:first-child { margin-top: 4px; }

/* Story 5757: every category band and every card folds, remembered; Fold All in the toolbar. */
.ff-band:not(:first-child) > .ff-group { margin-top: 22px; }
.ff-group { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.ff-group:hover .ff-chev { color: #1A73E8; }
.ff-chev { width: 12px; font-size: 10pt; color: #888; }
.ff-group-n { font-weight: 600; color: #AAA; letter-spacing: 0; }
.ff-band.collapsed > .ff-band-body { display: none; }
.ff-card-fold {
    flex: 0 0 auto; align-self: flex-start;
    border: none; background: none; padding: 2px 4px; margin: 0 -6px 0 -8px;
    font-size: 12pt; line-height: 1.25; color: #888; cursor: pointer;
}
.ff-card-fold:hover { color: #1A73E8; }
.ff-card.collapsed .ff-card-meta,
.ff-card.collapsed .ff-card-desc { display: none; }
.ff-card.collapsed { padding-top: 12px; padding-bottom: 12px; }
.ff-foldall {
    flex: 0 0 auto;
    border: 1px solid #D3D3D9; background: #fff; border-radius: 6px;
    padding: 6px 10px; font-size: 11pt; color: #444; cursor: pointer;
}
.ff-foldall[hidden] { display: none; }

/* The card itself --------------------------------------------------- */

.ff-card {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 16px 16px 16px 22px;
    position: relative; overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.ff-card:active {
    transform: scale(0.995);
    box-shadow: 0 1px 1px rgba(0,0,0,0.10);
}
.ff-card::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 7px;
    background: var(--ff-risk-color, #14A08C);
}
.ff-card[data-risk="0"] { --ff-risk-color: #14A08C; --ff-risk-tint: rgba(20,160,140,0.13); }
.ff-card[data-risk="1"] { --ff-risk-color: #E89A1F; --ff-risk-tint: rgba(232,154,31,0.14); }
.ff-card[data-risk="2"] { --ff-risk-color: #D93A3A; --ff-risk-tint: rgba(217,58,58,0.13); }

.ff-card-row {
    display: flex; align-items: flex-start; gap: 14px;
}
.ff-card-text { flex: 1; min-width: 0; }

.ff-card-title {
    font-size: 14pt; font-weight: 600; color: #1A1A1A;
    line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.ff-card-meta {
    margin-top: 6px;
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.ff-chip {
    display: inline-flex; align-items: center;
    padding: 2px 10px;
    font-size: 9.5pt; font-weight: 600;
    border-radius: 10px;
    background: #F0F0F2; color: #555;
    border: 1px solid #E0E0E4;
}
.ff-chip.code {
    font-family: "Consolas","SF Mono","Menlo",monospace;
    font-weight: 500; font-size: 9pt;
    color: #444; background: #F5F5F7; border-color: #E5E5E8;
}
.ff-chip.risk {
    background: var(--ff-risk-tint, rgba(20,160,140,0.13));
    color: var(--ff-risk-color, #14A08C);
    border-color: var(--ff-risk-color, #14A08C);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.ff-card-desc {
    margin-top: 10px;
    font-size: 11pt; color: #5A5A5E; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis;
}

/* Toggle pill ------------------------------------------------------ */

.ff-toggle {
    flex: 0 0 auto;
    width: 60px; height: 32px;
    border-radius: 16px; position: relative;
    background: #C9C9CE; border: none;
    cursor: pointer; padding: 0;
    transition: background 0.18s ease;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.18);
}
.ff-toggle::after {
    content: "";
    position: absolute; top: 3px; left: 3px;
    width: 26px; height: 26px;
    background: #fff; border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.30);
    transition: left 0.18s ease;
}
.ff-toggle[data-on="true"]         { background: #1A73E8; }
.ff-toggle[data-on="true"]::after  { left: 31px; }

/* ====================================================================== */
/* FAB (Add button)                                                       */
/* ====================================================================== */

.ff-fab {
    position: fixed;
    right: 22px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    width: 60px; height: 60px;
    border-radius: 50%; border: none;
    background: #1A7A3C; color: #fff;
    font-size: 32pt; font-weight: 300; line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.28), 0 2px 4px rgba(0,0,0,0.18);
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
    z-index: 20;
}
.ff-fab:hover  { background: #226B40; box-shadow: 0 6px 16px rgba(0,0,0,0.32), 0 3px 6px rgba(0,0,0,0.20); }
.ff-fab:active { transform: scale(0.96); }

/* ====================================================================== */
/* OVERLAYS (detail + edit)                                              */
/* ====================================================================== */

.ff-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 100;
    display: flex; flex-direction: column;
    animation: ff-fade 0.18s ease;
}
@keyframes ff-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ff-overlay-sheet {
    background: #F5F5F7;
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: ff-slide-up 0.22s ease;
}
@keyframes ff-slide-up {
    from { transform: translateY(20px); opacity: 0.6; }
    to   { transform: translateY(0);    opacity: 1;   }
}

/* Phone: full-screen sheet */
.ff-overlay-sheet {
    width: 100%; height: 100%;
    border-radius: 0;
}

.ff-overlay-header {
    background: #3C3C3C; color: #fff;
    padding: 12px 14px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    display: flex; align-items: center; gap: 10px;
    flex: 0 0 auto;
}
.ff-overlay-header .ff-icon-btn { color: #fff; }
.ff-overlay-header .ff-icon-btn:hover { background: rgba(255,255,255,0.10); }
.ff-overlay-title {
    flex: 1; min-width: 0;
    font-size: 14pt; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ff-text-btn {
    background: transparent; color: inherit;
    border: 1px solid rgba(255,255,255,0.35); border-radius: 4px;
    padding: 7px 16px;
    font: inherit; font-size: 11pt; font-weight: 600;
    cursor: pointer;
}
.ff-text-btn:hover { background: rgba(255,255,255,0.12); }
.ff-text-btn.primary {
    background: #1A7A3C; border-color: #1A7A3C; color: #fff;
}
.ff-text-btn.primary:hover { background: #226B40; }

.ff-overlay-body {
    flex: 1; overflow-y: auto;
    padding: 24px 22px calc(40px + env(safe-area-inset-bottom, 0px)) 22px;
}

/* ---- Detail body --------------------------------------------------- */

.ff-detail-hero {
    background: #fff;
    border-radius: 14px;
    padding: 22px 22px 24px 22px;
    position: relative; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 18px;
}
.ff-detail-hero::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 8px;
    background: var(--ff-risk-color, #14A08C);
}
.ff-detail-hero[data-risk="0"] { --ff-risk-color: #14A08C; --ff-risk-tint: rgba(20,160,140,0.13); }
.ff-detail-hero[data-risk="1"] { --ff-risk-color: #E89A1F; --ff-risk-tint: rgba(232,154,31,0.14); }
.ff-detail-hero[data-risk="2"] { --ff-risk-color: #D93A3A; --ff-risk-tint: rgba(217,58,58,0.13); }

.ff-detail-name {
    font-size: 20pt; font-weight: 700;
    color: #111; line-height: 1.2;
    margin: 0 0 10px 0;
    padding-left: 6px;
}
.ff-detail-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding-left: 6px;
    margin-bottom: 18px;
}
.ff-detail-desc {
    font-size: 12pt; color: #333; line-height: 1.55;
    padding-left: 6px;
    margin: 0 0 22px 0;
    white-space: pre-wrap;
}
.ff-detail-toggle-row {
    background: var(--ff-risk-tint, rgba(20,160,140,0.13));
    margin: -4px -8px 0 -8px;
    padding: 16px 14px;
    border-radius: 10px;
    display: flex; align-items: center; gap: 16px;
}
.ff-detail-toggle-label {
    flex: 1;
    font-size: 12pt; font-weight: 600;
    color: #1A1A1A;
}
.ff-detail-toggle-label .state {
    display: block;
    font-size: 10pt; color: #555; font-weight: 500; margin-top: 2px;
}
.ff-detail-toggle {
    /* Same .ff-toggle, larger for the detail view */
    width: 76px; height: 40px; border-radius: 20px;
}
.ff-detail-toggle::after {
    width: 34px; height: 34px;
}
.ff-detail-toggle[data-on="true"]::after { left: 39px; }

.ff-detail-actions {
    display: flex; gap: 10px;
    margin-bottom: 18px;
}
.ff-action-btn {
    flex: 1;
    padding: 13px 14px;
    background: #fff; color: #1A73E8;
    border: 1px solid #D5D5D9; border-radius: 10px;
    font: inherit; font-size: 11.5pt; font-weight: 600;
    cursor: pointer;
}
.ff-action-btn:hover { background: #F5F5F7; }
.ff-action-btn.danger { color: #C00000; }
.ff-action-btn.danger:hover { background: #FFF0F0; }

.ff-meta-card {
    background: #fff;
    border-radius: 14px;
    padding: 18px 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.ff-meta-row {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 8px 0;
    border-top: 1px solid #F0F0F2;
    gap: 16px;
}
.ff-meta-row:first-child { border-top: none; }
.ff-meta-row .k { color: #888; font-size: 11pt; flex: 0 0 auto; }
.ff-meta-row .v { color: #1A1A1A; font-size: 11pt; text-align: right; word-break: break-word; }

/* ---- Edit modal body --------------------------------------------- */

.ff-field { margin-bottom: 18px; }
.ff-field > label {
    display: block;
    font-size: 11pt; font-weight: 600; color: #333;
    margin-bottom: 6px;
}
.ff-field input[type="text"],
.ff-field textarea,
.ff-field select {
    width: 100%;
    padding: 11px 13px;
    font: inherit; font-size: 12pt;
    border: 1px solid #D5D5D9; border-radius: 8px;
    background: #fff;
    -webkit-appearance: none;
}
.ff-field textarea { resize: vertical; min-height: 100px; }
.ff-field input[type="text"]:focus,
.ff-field textarea:focus,
.ff-field select:focus {
    outline: none; border-color: #1A73E8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.18);
}
.ff-hint {
    font-size: 10pt; color: #888; margin-top: 6px;
    line-height: 1.4;
}
.ff-hint code {
    font-family: "Consolas","SF Mono","Menlo",monospace;
    background: #F0F0F2; padding: 1px 6px; border-radius: 3px;
    font-size: 9.5pt; color: #555;
}

/* ====================================================================== */
/* DESKTOP / LARGE SCREEN                                                */
/* ====================================================================== */

@media (min-width: 720px) {
    .ff-list {
        max-width: 920px; margin: 0 auto;
        padding: 20px 24px 110px 24px;
    }
    .ff-toolbar {
        padding: 14px 24px;
    }
    .ff-toolbar input[type="search"] { max-width: 480px; }

    .ff-card {
        padding: 20px 22px 20px 28px;
    }
    .ff-card-title { font-size: 15pt; }

    /* Overlays become dialogs centered on screen */
    .ff-overlay {
        align-items: center; justify-content: center;
        padding: 32px;
    }
    .ff-overlay-sheet {
        width: 100%;
        max-width: 720px;
        max-height: calc(100vh - 64px);
        border-radius: 14px;
        box-shadow: 0 24px 60px rgba(0,0,0,0.30);
    }
    .ff-overlay-header { padding-top: 12px; }
    .ff-overlay-body { padding: 26px 28px 28px 28px; }
}

@media (min-width: 1100px) {
    .ff-list { max-width: 1080px; }
}
