/* ============================================================
   Demo Services — Services toolbar, dropdown, barcode scanner
   ============================================================ */

/* ============================================================
   SERVICES TOOLBAR — Gemini-style services button
   ============================================================ */

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.services-toolbar-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0 0.25rem 0.1rem;
    position: relative;
}

.services-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.6rem;
    height: 28px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-full);
    background: var(--c-bg-card);
    color: var(--c-text-secondary);
    font-size: 0.78rem;
    font-family: var(--f-body);
    cursor: pointer;
    transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
    white-space: nowrap;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.services-btn:hover {
    background: var(--c-bg-warm);
    color: var(--c-primary);
    border-color: var(--c-primary);
}

.services-btn-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.service-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.5rem 0.22rem 0.65rem;
    height: 28px;
    border-radius: var(--r-full);
    background: var(--c-primary);
    color: var(--c-bg-card);
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    animation: fadeInScale var(--dur-normal) var(--ease-out);
}

.service-active-badge-icon {
    font-size: 0.85rem;
    line-height: 1;
}

.service-active-badge-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    color: var(--c-bg-card);
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--dur-fast), background var(--dur-fast);
    padding: 0;
    line-height: 1;
    border-radius: 50%;
}

.service-active-badge-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.18);
}

/* Services Dropdown */
.services-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--c-bg-elevated);
    border: 1px solid var(--c-border-light);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-height: 340px;
    overflow-y: auto;
    z-index: 100;
    padding: 4px;
    animation: fadeInScale var(--dur-normal) var(--ease-out);
}

.services-dropdown-title {
    padding: 0.6rem 0.8rem 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.services-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.7rem;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--f-body);
    font-size: 0.88rem;
    color: var(--c-text);
    border-radius: var(--r-sm);
    transition: background var(--dur-fast);
    min-height: 44px;
}

.services-dropdown-item:hover {
    background: var(--c-bg-warm);
}

.services-dropdown-item:first-of-type {
    border-radius: var(--r-sm);
}

.services-dropdown-item:last-child {
    border-radius: var(--r-sm);
}

.services-dropdown-item-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.services-dropdown-item-name {
    font-weight: 500;
}

@media (max-width: 767px) {
    .services-toolbar-row {
        padding: 0 0.15rem 0.05rem;
    }
    .services-dropdown {
        min-width: 0;
        left: -0.25rem;
        right: -0.25rem;
        max-height: 240px;
    }
}

@media (max-width: 479px) {
    .services-btn {
        font-size: 0.72rem;
        padding: 0.18rem 0.45rem;
    }
    .service-active-badge {
        font-size: 0.7rem;
        padding: 0.15rem 0.45rem;
    }
    .services-dropdown-item {
        padding: 0.5rem 0.7rem;
        font-size: 0.82rem;
    }
}

@media (max-width: 359px) {
    .services-btn span:not(.services-btn-icon) {
        display: none;
    }
    .services-btn {
        padding: 0.25rem 0.45rem;
    }
}

/* Touch devices — larger close target */
@media (hover: none) and (pointer: coarse) {
    .service-active-badge-close {
        width: 28px;
        height: 28px;
        font-size: 1rem;
        opacity: 0.7;
    }
}

/* ============================================================
   BARCODE SCANNER — Mobile camera overlay
   ============================================================ */

.scan-barcode-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-full);
    background: var(--c-bg-card);
    color: var(--c-primary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}

.scan-barcode-btn:hover {
    background: var(--c-bg-warm);
    border-color: var(--c-primary);
    transform: scale(1.05);
}

.scan-barcode-btn:active {
    transform: scale(0.95);
}

@media (hover: none) and (pointer: coarse) {
    .scan-barcode-btn {
        display: flex;
    }
}

/* Fullscreen scanner overlay */
.scanner-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    animation: scannerFadeIn 0.2s ease-out;
}

.scanner-overlay.scanner-closing {
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

@keyframes scannerFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    background: rgba(0, 0, 0, 0.6);
}

.scanner-title {
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--f-body);
}

.scanner-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background var(--dur-fast);
}

.scanner-close:hover,
.scanner-close:active {
    background: rgba(255, 255, 255, 0.3);
}

.scanner-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#scannerReader {
    width: 100%;
    height: 100%;
}

#scannerReader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Hide html5-qrcode default UI elements */
#scannerReader img[alt="Info"],
#scannerReader > div:last-child {
    display: none !important;
}

.scanner-viewfinder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 400px;
    height: 30%;
    max-height: 160px;
    border: 3px solid var(--c-accent);
    border-radius: var(--r-md);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.scanner-viewfinder::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--c-accent);
    box-shadow: 0 0 8px var(--c-accent);
    animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
    0%, 100% { top: 10%; }
    50% { top: 90%; }
}

.scanner-subtitle {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-family: var(--f-body);
    padding: 16px 24px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    margin: 0;
    background: rgba(0, 0, 0, 0.6);
}

.scanner-subtitle.scanner-success {
    color: var(--c-accent);
    font-weight: 600;
    font-size: 1rem;
}
