
/* Shared row-level leading icon (used in rows with no thumbnail background).
   Sits flex-aligned with row text; intended for .row and similar flex containers. */
.row-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    color: #666;
}

/* Popin - in-slot modal pattern (mirrors popup hierarchy) */
/* Structure: .popin > .mask + .modal > .header + .content */

.popin {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    .mask {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: -1;
    }

    .modal {
        display: flex;
        flex-direction: column;
        flex: 1;
        overflow: hidden;
        background: #fff;

        .header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 14px var(--tight-pad-x);
            min-height: 77.5px;
            box-sizing: border-box;
            flex-shrink: 0;
            gap: 10px;
            flex-wrap: wrap;

            > .text {
                flex-basis: 100%;
                margin: 0;
                padding: 0;
                font-size: 1rem;
                color: #666;
                line-height: 1.5;

                p {
                    margin: 0 0 4px 0;
                    &:last-child { margin-bottom: 0; }
                }
            }

            .thumb {
                width: 36px;
                height: 36px;
                border-radius: 6px;
                overflow: hidden;
                flex-shrink: 0;

                svg, img {
                    width: 100%;
                    height: 100%;
                    object-fit: cover;
                    display: block;
                }

                &.circle {
                    border-radius: 50%;
                    background-color: var(--secondary-color);
                    display: flex;
                    align-items: center;
                    justify-content: center;

                    svg {
                        width: 24px;
                        height: 24px;
                        color: #fff;
                    }
                }
            }

            h2 {
                margin: 0;
                font-size: 1.125rem;
                font-weight: 600;
                color: #333;
            }

            .close {
                margin-left: auto;
                display: flex;
                align-items: center;
                justify-content: center;
                width: 28px;
                height: 28px;
                border-radius: 50%;
                background-color: #f0f0f0;
                font-size: 1.25rem;
                line-height: 1;
                padding-bottom: 2px;
                color: #999;
                cursor: pointer;
                transition: background-color 0.15s, color 0.15s;

                &:hover {
                    background-color: #e0e0e0;
                    color: #333;
                }
            }

            .action {
                flex-shrink: 0;
                padding: 6px 14px;
                border-radius: 6px;
                font-size: 0.8125rem;
                font-weight: 500;
                cursor: pointer;
                background-color: transparent;
                color: #999;
                border: 1px solid #ddd;
                margin-left: 15px;

                &:hover {
                    color: #333;
                    border-color: #999;
                }

                &.danger {
                    color: #dc3545;
                    border-color: #dc3545;

                    &:hover {
                        background-color: #dc3545;
                        color: #fff;
                    }
                }
            }

            &.gradient {
                background: linear-gradient(90deg, #fefefe 0%, #f7f7f7 50%, #fefefe 100%);
            }

            &.with-text {
                min-height: 120px;
                gap: 15px;
                padding: 25px var(--tight-pad-x);
            }

            &.loading {
                background: linear-gradient(90deg, #f8f8f8 25%, #efefef 50%, #f8f8f8 75%);
                background-size: 200% 100%;
                animation: popinLoader 2.5s ease-in-out infinite;
            }
        }

        .content {
            flex: 1;
            overflow-y: auto;
            padding: 0;
            container-type: inline-size;
        }
    }

    /* ─── Row items ─────────────────────────────────────────── */

    .row {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px var(--tight-pad-x);
        cursor: pointer;
        border-bottom: 1px solid #f0f0f0;
        border-top: 1px solid #f0f0f0;
        margin-bottom: -1px;

        &:hover {
            background-color: #f8f8f8;
        }

        &.disabled {
            cursor: default;
            opacity: 0.5;

            &:hover {
                background-color: transparent;
            }
        }

        .thumb {
            width: 40px;
            height: 40px;
            border-radius: 6px;
            overflow: hidden;
            flex-shrink: 0;

            svg, img {
                width: 100%;
                height: 100%;
                object-fit: cover;
                display: block;
            }

            &.icon {
                display: flex;
                align-items: center;
                justify-content: center;
                background: #f8f8f8;
                color: #999;


                svg {
                    width: 20px;
                    height: 20px;
                    color: #b6b6b6;
                }

                &.danger {
                    color: #dc3545;
                }
            }
        }

        .info {
            flex: 1;
            min-width: 0;
            min-height: 40px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .name {
            font-size: 1rem;
            font-weight: 600;
            color: #333;

            &.danger {
                color: #dc3545;
            }
            &.light{
                font-weight: 400;
            }
        }

        .detail {
            font-size: 0.8125rem;
            color: #999;
            font-family: monospace;
        }

        .faint {
            font-size: 0.8125rem;
            color: #bbb;
            flex-shrink: 0;
        }

        .action {
            flex-shrink: 0;
            padding: 6px 14px;
            border-radius: 6px;
            font-size: 0.8125rem;
            font-weight: 500;
            cursor: pointer;
            background-color: transparent;
            color: #505050;
            border: 1px solid #9b9b9b;

            &:hover {
                color: #333;
                border-color: #999;
            }

            &.danger {
                color: #dc3545;
                border-color: #dc3545;

                &:hover {
                    background-color: #dc3545;
                    color: #fff;
                }
            }
        }
    }

    /* ─── Row arrow (right chevron for drill-down rows) ───── */

    .row .arrow {
        flex-shrink: 0;
        width: 20px;
        height: 20px;
        color: #ccc;
    }

    .row:hover .arrow {
        color: #999;
    }

    /* ─── Section gap (between account groups) ────────────── */

    .section-gap {
        height: 60px;
    }

    /* ─── Other account header ──────────────────────────────── */

    .other-account-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 30px var(--tight-pad-x) 5px;
        background: linear-gradient(180deg, #ffffff 0%, #f9f9f9 100%);
        min-height: 40px;

        .name {
            font-size: 1rem;
            font-weight: 600;
            color: #333;
        }

        .action {
            flex-shrink: 0;
            padding: 6px 14px;
            border-radius: 6px;
            font-size: 0.8125rem;
            font-weight: 500;
            cursor: pointer;
            background-color: transparent;
            color: #505050;
            border: 1px solid #9b9b9b;
            margin-left: 15px;

            &:hover {
                color: #333;
                border-color: #999;
            }
        }
    }

    /* ─── Text content blocks ───────────────────────────────── */

    .text {
        padding: 14px var(--tight-pad-x);
        margin: 10px 0;
        
        p {
            font-size: 1rem;
            color: #666;
            line-height: 1.5;
            margin: 0 0 14px 0;

            &:last-child {
                margin-bottom: 0;
            }
        }

        strong {
            color: #333;
        }
    }

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

    .buttons {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 14px var(--tight-pad-x);
    }

    .button {
        display: block;
        padding: 12px;
        text-align: center;
        background-color: #404499;
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 1rem;
        font-weight: 500;
        cursor: pointer;
        transition: background-color 0.2s;

        &:hover {
            background-color: #0056b3;
        }

        &.secondary {
            background-color: #f0f0f0;
            color: #333;

            &:hover {
                background-color: #e5e5e5;
            }
        }

        &.disabled {
            opacity: 0.4;
            cursor: default;
            pointer-events: none;
        }
    }

    /* ─── Form inputs ────────────────────────────────────────── */

    .input {
        width: calc(100% - var(--tight-pad-x) * 2);
        margin: 0 var(--tight-pad-x);
        padding: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        font-size: 1rem;
        box-sizing: border-box;

        &:focus {
            outline: none;
            border-color: #007bff;
            box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
        }

        &::placeholder {
            color: #999;
        }
    }

}

/* Wide layout - inline buttons when popin > 300px */
@container (min-width: 500px) {
    .popin .buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* Ensure mask covers dashboard-right when a popin is open */
.dashboard:has(.popin) .dashboard-right {
    z-index: -1;
}

@keyframes popinLoader {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
