/* ==========================================================================
   AtomFive Global Topbar Cart Component
   Design Language: .gmb-glass + Standard themes.css & template.css variables
   Multi-Item Architecture with Project Root Grouping
   ========================================================================== */

.topbar-cart-container {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 100;
}

/* Collapsed Topbar Cart Capsule */
.topbar-cart-capsule {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px 0 10px;
    border-radius: var(--radius) !important;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box !important;
    position: relative;
    overflow: visible;

    background: var(--color-surface-alt) !important;
    border: 1px solid var(--border-soft) !important;
    color: var(--color-text) !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.topbar-cart-capsule.is-entering {
    animation: topbar-cart-enter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.topbar-cart-capsule.is-exiting {
    animation: topbar-cart-exit 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.topbar-cart-capsule.is-bump {
    animation: topbar-cart-bump 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.topbar-cart-capsule:hover {
    background: color-mix(in srgb, var(--color-surface-alt) 80%, var(--color-text) 10%) !important;
    border-color: color-mix(in srgb, var(--border-soft) 60%, var(--color-text) 20%) !important;
    color: var(--color-text) !important;
    box-shadow: none !important;
    transform: none !important;
}

.topbar-cart-capsule:active {
    background: color-mix(in srgb, var(--color-surface-alt) 65%, var(--color-text) 18%) !important;
    transform: scale(0.98) !important;
}

.topbar-cart-capsule.is-active {
    background: color-mix(in srgb, var(--color-surface-alt) 85%, var(--color-brand) 15%) !important;
    border-color: var(--color-brand) !important;
    box-shadow: 0 0 10px color-mix(in srgb, var(--color-brand) 25%, transparent) !important;
}

/* Keyframe Animations */
@keyframes topbar-cart-enter {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-6px);
        filter: blur(4px);
    }
    60% {
        transform: scale(1.05) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

@keyframes topbar-cart-exit {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) translateY(-6px);
        filter: blur(4px);
    }
}

@keyframes topbar-cart-bump {
    0% {
        transform: scale(1);
    }
    45% {
        transform: scale(1.06);
        box-shadow: 0 0 18px color-mix(in srgb, var(--color-brand), transparent 40%);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes topbar-badge-pop {
    0% {
        transform: scale(0.5);
        opacity: 0.5;
    }
    60% {
        transform: scale(1.35);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Icon Box & Badge */
.topbar-cart-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 20px;
    height: 20px;
    color: var(--color-text);
    flex-shrink: 0;
}

.topbar-cart-icon-box svg {
    width: 17px;
    height: 17px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
}

.topbar-cart-count-badge {
    position: absolute;
    top: -5px;
    right: -7px;
    background: var(--color-brand);
    color: #ffffff;
    font-size: var(--fs-legal, 9.5px);
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 1.5px solid var(--color-surface-alt, #1d202e);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
    animation: topbar-badge-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Cart Summary Text: "R$ 380,00 • 20 dias" */
.topbar-cart-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.topbar-cart-price {
    font-size: var(--fs-body, 13px);
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.topbar-cart-divider {
    color: var(--color-text-muted);
    opacity: 0.5;
    font-size: 11px;
}

.topbar-cart-timeline {
    font-size: var(--fs-caption, 12px);
    color: var(--color-text-muted);
    font-weight: 500;
}

.topbar-cart-timeline.is-express {
    color: var(--color-brand);
    font-weight: 600;
}

/* Dropdown Floating Cart Panel */
.topbar-cart-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 380px;
    max-width: 92vw;
    border-radius: var(--radius-lg, 16px);
    padding: 18px 20px;
    box-sizing: border-box;
    z-index: 1000;
    box-shadow: var(--shadow-elevation, 0 20px 50px rgba(0, 0, 0, 0.5));
    border: 1px solid var(--border-soft);
    background: color-mix(in srgb, var(--color-surface-block, #151821), transparent 15%);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    display: none;
    flex-direction: column;
    gap: 14px;
    animation: topbar-cart-pop 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar-cart-dropdown.open {
    display: flex;
}

@keyframes topbar-cart-pop {
    0% { opacity: 0; transform: translateY(-8px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Dropdown Header */
.topbar-cart-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 12px;
}

.topbar-cart-dropdown-title {
    font-size: var(--fs-title-nav, 14.5px);
    font-weight: 600;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.topbar-cart-clear-all-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 11.5px;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: var(--radius-sm, 4px);
    transition: all 0.2s ease;
    opacity: 0.75;
}

.topbar-cart-clear-all-btn:hover {
    color: #ef4444;
    opacity: 1;
    background: rgba(239, 68, 68, 0.1);
}

.topbar-cart-close-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm, 4px);
    transition: all 0.2s ease;
}

.topbar-cart-close-btn:hover {
    background: var(--overlay-hover, rgba(255, 255, 255, 0.1));
    color: var(--color-text);
}

/* Items List */
.topbar-cart-items-list {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

/* ==========================================================================
   Project Card (Root Item Architecture)
   ========================================================================== */
.topbar-cart-project-card {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 40%, rgba(12, 16, 26, 0.85) 100%), rgba(10, 14, 22, 0.9);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md, 12px);
    padding: 14px 14px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.25s ease;
}

.topbar-cart-project-card:hover {
    border-color: rgba(56, 189, 248, 0.35);
}

.topbar-cart-project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar-cart-project-badge-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar-cart-project-badge {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 2px 7px;
    border-radius: 9999px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-cart-project-time {
    font-size: 11px;
    color: var(--color-text-muted);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.topbar-cart-project-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.topbar-cart-project-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-cart-project-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.18) 0%, rgba(56, 189, 248, 0.04) 100%);
    border: 1px solid rgba(56, 189, 248, 0.25);
    color: var(--color-brand, #38bdf8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topbar-cart-project-icon svg {
    width: 17px;
    height: 17px;
}

.topbar-cart-project-main-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.topbar-cart-project-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.topbar-cart-project-category {
    font-size: 11px;
    color: var(--color-text-muted);
}

.topbar-cart-project-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.topbar-cart-project-price-label {
    font-size: 11.5px;
    color: var(--color-text-muted);
}

.topbar-cart-project-price-val {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--color-text);
}

/* Scope Drawer Toggle & Sub-items */
.topbar-cart-scope-toggle-wrap {
    display: flex;
    justify-content: flex-start;
}

.topbar-cart-scope-toggle-btn {
    background: transparent;
    border: none;
    color: var(--color-brand, #38bdf8);
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    opacity: 0.85;
    transition: all 0.2s ease;
}

.topbar-cart-scope-toggle-btn:hover {
    opacity: 1;
    text-decoration: underline;
}

.topbar-cart-scope-toggle-btn svg {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar-cart-scope-toggle-btn svg.is-rotated {
    transform: rotate(180deg);
}

.topbar-cart-scope-drawer {
    display: none;
    margin-top: 4px;
}

.topbar-cart-scope-drawer.is-open {
    display: block;
    animation: topbar-drawer-in 0.25s ease forwards;
}

@keyframes topbar-drawer-in {
    0% { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 1; transform: translateY(0); }
}

.topbar-cart-scope-drawer-inner {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
}

.topbar-cart-subitem-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11.5px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.topbar-cart-subitem-row:last-child {
    border-bottom: none;
}

.topbar-cart-subitem-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-width: 70%;
}

.topbar-cart-subitem-name {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    line-height: 1.2;
}

.topbar-cart-subitem-phase {
    font-size: 10px;
    color: var(--color-text-muted);
}

.topbar-cart-subitem-price {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
}

/* Standalone Product Row */
.topbar-cart-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--color-surface-alt, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--border-faint);
    border-radius: var(--radius-sm, 8px);
    padding: 8px 12px;
    font-size: var(--fs-meta, 13px);
}

.topbar-cart-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 70%;
}

.topbar-cart-item-name {
    color: var(--color-text);
    font-weight: 500;
    line-height: 1.3;
}

.topbar-cart-item-meta {
    font-size: var(--fs-caption, 11px);
    color: var(--color-text-muted);
}

.topbar-cart-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-cart-item-price {
    font-weight: 600;
    color: var(--color-text);
    font-size: var(--fs-meta, 13px);
}

.topbar-cart-item-remove {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: var(--radius-sm, 4px);
    transition: all 0.2s ease;
    opacity: 0.7;
}

.topbar-cart-item-remove:hover {
    color: #ef4444;
    opacity: 1;
    background: rgba(239, 68, 68, 0.1);
}

/* Dropdown Footer & Summary */
.topbar-cart-dropdown-footer {
    border-top: 1px solid var(--border-soft);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.topbar-cart-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--fs-meta, 13px);
}

.topbar-cart-footer-total {
    font-size: var(--fs-title-sub, 16.5px);
    font-weight: 700;
    color: var(--color-text);
}

.topbar-cart-footer-timeline {
    color: var(--color-brand);
    font-size: var(--fs-caption, 12px);
    font-weight: 500;
}

.topbar-cart-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.topbar-cart-btn-primary {
    flex: 1;
    background: var(--color-brand);
    color: #ffffff;
    border: 1px solid var(--color-brand);
    padding: 10px 14px;
    border-radius: var(--radius-md, 8px);
    font-size: var(--fs-meta, 13px);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px color-mix(in srgb, var(--color-brand), transparent 60%);
}

.topbar-cart-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--color-brand), transparent 45%);
}

/* Mobile Adjustments */
@media (max-width: 640px) {
    .topbar-cart-capsule {
        padding: 0 10px;
    }
    .topbar-cart-timeline {
        display: none;
    }
    .topbar-cart-divider {
        display: none;
    }
    .topbar-cart-dropdown {
        position: fixed;
        top: 60px;
        left: 16px;
        right: 16px;
        width: auto;
    }
}
