/**
 * FQPedidos — Cart Drawer (Sprint 5.1)
 */

.fq-drawer-root {
    position: fixed;
    inset: 0;
    z-index: 300;
    pointer-events: none;
    visibility: hidden;
}

.fq-drawer-root.is-open {
    pointer-events: auto;
    visibility: visible;
}

.fq-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: var(--color-text);
    opacity: 0;
    transition: opacity 0.28s ease;
}

.fq-drawer-root.is-open .fq-drawer-backdrop {
    opacity: 0.45;
}

.fq-drawer {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 100%;
    max-width: 100%;
    background: var(--color-surface);
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--color-border);
    box-shadow: none;
    transform: translateX(100%);
    transition: transform 0.28s ease;
}

.fq-drawer-root.is-open .fq-drawer {
    transform: translateX(0);
}

.fq-drawer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1.125rem 1.25rem 1rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.fq-drawer__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.fq-drawer__subtitle {
    margin: 0.25rem 0 0;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.35;
}

.fq-drawer__subtitle.is-hidden {
    display: none;
}

#fq-drawer-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.fq-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--fq-radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.fq-drawer__close svg {
    width: 20px;
    height: 20px;
}

.fq-drawer__close:hover {
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
}

.fq-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.fq-drawer__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.fq-drawer-item {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: 0.75rem;
    align-items: start;
    padding-bottom: 0.875rem;
    border-bottom: 1px solid var(--color-border-light);
}

.fq-drawer-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.fq-drawer-item__photo {
    width: 64px;
    height: 64px;
    border-radius: var(--fq-radius);
    overflow: hidden;
    background: var(--color-primary-soft);
    flex-shrink: 0;
}

.fq-drawer-item__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.fq-drawer-item__name {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

.fq-drawer .product-description {
    display: none;
}

.fq-drawer-item__unit {
    margin: 0.1875rem 0 0.5rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.fq-drawer-item__controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.fq-drawer-qty {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--fq-radius);
    overflow: hidden;
}

.fq-drawer-qty__btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.fq-drawer-qty__btn:hover:not(:disabled) {
    background: var(--color-background);
    color: var(--color-primary-dark);
}

.fq-drawer-qty__btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.fq-drawer-qty__value {
    min-width: 2rem;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    padding: 0 0.25rem;
}

.fq-drawer-item__subtotal {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
}

.fq-drawer-item__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-delete);
    cursor: pointer;
    border-radius: var(--fq-radius);
    transition: color 0.2s ease;
}

.fq-drawer-item__remove svg {
    width: 18px;
    height: 18px;
}

.fq-drawer-item__remove:hover:not(:disabled) {
    color: var(--color-delete-hover);
}

.fq-drawer-item__remove:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Observaciones por línea (Sprint 6.5) */
.fq-cart-obs {
    margin-top: 0.625rem;
}

.fq-cart-obs__toggle {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.375rem;
    padding: 0;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-primary-dark);
    cursor: pointer;
    text-align: left;
    line-height: 1.4;
    max-width: 100%;
}

.fq-cart-obs__toggle:hover {
    color: var(--color-primary);
}

.fq-cart-obs__icon {
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: var(--color-text-muted);
}

.fq-cart-obs__preview {
    display: block;
    color: var(--color-text);
    font-weight: 500;
    word-break: break-word;
}

.fq-cart-obs__empty-label {
    display: block;
    color: var(--color-text-muted);
    font-weight: 600;
}

.fq-cart-obs__empty-hint {
    display: block;
    color: var(--color-primary-dark);
    font-weight: 500;
}

.fq-cart-obs__editor {
    margin-top: 0.5rem;
}

.fq-cart-obs__editor.is-hidden {
    display: none;
}

.fq-cart-obs__input {
    width: 100%;
    min-height: 64px;
    padding: 0.5rem 0.625rem;
    font-family: inherit;
    font-size: 0.8125rem;
    line-height: 1.45;
    border: 1px solid var(--color-border);
    border-radius: var(--fq-radius-sm);
    resize: vertical;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 0.2s ease;
}

.fq-cart-obs__input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.fq-cart-obs__input::placeholder {
    color: var(--color-text-light);
}

.fq-cart-obs__counter {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    text-align: right;
}

.fq-cart-obs.is-saving {
    opacity: 0.7;
    pointer-events: none;
}

.fq-drawer__footer {
    flex-shrink: 0;
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.fq-drawer-summary {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.fq-drawer-summary__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.fq-drawer-summary__row span:last-child {
    color: var(--color-text);
    font-weight: 600;
}

.fq-drawer-summary__row--total {
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--color-border-light);
    font-size: 0.9375rem;
    color: var(--color-text);
}

.fq-drawer-summary__row--total span:last-child {
    font-size: 1.0625rem;
    font-weight: 700;
    color: var(--color-primary-dark);
}

.fq-drawer__actions {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.fq-drawer__actions .fq-btn {
    width: 100%;
    min-height: 46px;
}

.fq-drawer__empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1.5rem 2.5rem;
}

.fq-drawer__empty-icon {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    margin-bottom: 1.25rem;
}

.fq-drawer__empty-icon svg {
    width: 36px;
    height: 36px;
}

.fq-drawer__empty-title {
    margin: 0 0 0.375rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.fq-drawer__empty-desc {
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.45;
    max-width: 240px;
}

.fq-drawer__btn-explore {
    min-width: 180px;
}

.fq-drawer-root.is-busy {
    pointer-events: none;
}

.fq-header__cart {
    cursor: pointer;
    border: none;
    background: transparent;
    font: inherit;
    text-align: left;
    padding: 0;
}

.fq-header__cart:focus-visible {
    outline: 2px solid var(--color-on-primary);
    outline-offset: 2px;
    border-radius: var(--fq-radius-sm);
}

body.fq-drawer-open {
    overflow: hidden;
}

@media (min-width: 768px) {
    .fq-drawer {
        width: 380px;
        max-width: 380px;
    }
}
