:root {
    --primary-color: #6200EA;
    --primary-hover: #3700b3;
    --secondary-color: #03DAC6;
    --bg-color: #F5F5FA;
    --card-bg: #FFFFFF;
    --text-color: #121212;
    --text-muted: #666;
    --border-color: #e0e0e0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --radius-md: 0.5rem;
    --sidebar-width: 350px;
    --header-height: 70px;
}

#turbo-pos-app * {
    box-sizing: border-box;
}

/* Force consistency for form elements which often don't inherit by default */
#turbo-pos-app input,
#turbo-pos-app select,
#turbo-pos-app textarea,
#turbo-pos-app button {
    font-family: inherit;
}

#turbo-pos-app {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    /* Fixed height, not min-height */
    overflow: hidden;
    /* Prevent app-level scroll */
    display: flex;
    flex-direction: column;
}

/* Ensure global scroll is killed if likely conflict with WP admin bar */
/* Ensure global scroll is killed only when POS is active */
body.turbo-pos-active {
    height: 100vh;
    margin: 0;
    overflow: hidden;
    /* Prevent double scrollbars */
}

/* Header */
.turbo-pos-header {
    height: var(--header-height);
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 50;
}

.pos-brand h1 {
    font-size: 1.5rem;
    margin: 0;
    font-weight: 700;
    letter-spacing: 1px;
    color: white;
}

.pos-search-container {
    flex: 1;
    max-width: 600px;
    margin: 0 20px;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input-wrapper input {
    width: 100%;
    padding: 10px 10px 10px 40px;
    border-radius: 20px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: background 0.2s;
}

.search-input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-input-wrapper input:focus {
    background: rgba(255, 255, 255, 0.3);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
}

.pos-user-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-role-badge {
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
}

#pos-refresh-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#pos-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.pos-search-container {
    flex: 1;
    max-width: 600px;
    margin: 0 20px;
    display: flex;
    /* Align input and toggle side-by-side */
    align-items: center;
}

/* iOS Toggle Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.3);
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--secondary-color);
    /* Use secondary color for active state */
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--secondary-color);
}

input:checked+.slider:before {
    -webkit-transform: translateX(20px);
    -ms-transform: translateX(20px);
    transform: translateX(20px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Gift Toggle Specifics & Discount Toggle (Darker background for white canvas) */
.ios-gift-toggle .slider,
.toggle-wrapper .slider,
.pos-popup-content .slider {
    background-color: #ccc;
}

.ios-gift-toggle input:checked+.slider,
.toggle-wrapper input:checked+.slider,
.pos-popup-content input:checked+.slider {
    background-color: var(--secondary-color);
}

/* Main Layout */
#turbo-pos-app .turbo-pos-main-layout {
    display: flex;
    flex: 1;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
    margin: 0;
}

/* Products Area */
#turbo-pos-app .pos-products-area {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#turbo-pos-app .pos-category-tabs {
    display: flex;
    gap: 10px;
    margin: 0 0 20px 0;
    overflow-x: auto;
    padding: 20px 20px 10px 20px;
    position: sticky;
    top: 0;
    background: var(--bg-color);
    z-index: 20;
    flex-shrink: 0;
    list-style: none;
}

#turbo-pos-app .pos-category-tabs button,
#turbo-pos-app .cat-tab {
    padding: 8px 16px;
    border: none;
    background: #FF9800;
    /* Orange by default */
    border-radius: 20px;
    /* Pill shape */
    cursor: pointer;
    font-weight: 500;
    color: white;
    /* White text */
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    font-family: inherit;
    font-size: 14px;
    line-height: normal;
    text-transform: none;
    appearance: none;
    -webkit-appearance: none;
    margin-right: 5px;
}

#turbo-pos-app .cat-tab.active,
#turbo-pos-app .cat-tab:hover {
    background: var(--primary-color) !important;
    /* Force Purple override */
    color: white !important;
    transform: translateY(-1px);
}

#turbo-pos-app .pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    padding: 0 20px 20px 20px;
}

/* Variable Product Styles */
#turbo-pos-app .pos-variations-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

#turbo-pos-app .pos-var-pill {
    display: flex;
    align-items: center;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 15px;
    /* Pill shape */
    padding: 2px 8px 2px 2px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    max-width: 100%;
    min-height: 28px;
    box-sizing: border-box;
}

#turbo-pos-app .pos-var-pill:hover {
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

#turbo-pos-app .pos-var-pill img {
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    margin-right: 6px !important;
    object-fit: cover !important;
    border: none !important;
    padding: 0 !important;
    display: block !important;
}

#turbo-pos-app .pos-var-pill span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
    line-height: 24px;
}

#turbo-pos-app .product-image {
    height: 200px !important;
    width: 100%;
    overflow: hidden;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

#turbo-pos-app .product-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block;
    transition: transform 0.3s ease;
    margin: 0;
    padding: 0;
    max-width: none !important;
}

#turbo-pos-app .product-image-placeholder {
    height: 200px !important;
    width: 100%;
    background: #e1e1e1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 2rem;
}

#turbo-pos-app .pos-product-card.variable-product {
    border: 1px solid var(--primary-color);
    background: #f9f9ff;
}

/* Sticky Cart Layout Tweaks */
.turbo-pos-main-layout {
    height: calc(100vh - 70px);
    overflow: hidden;
}

/* Make products list scrollable independently */
.pos-products-area {
    overflow-y: auto;
    height: 100%;
    flex: 1;
}

/* Scoped Cart & Product Info */
#turbo-pos-app .product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

#turbo-pos-app .product-info h3 {
    margin: 0 0 5px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

#turbo-pos-app .product-info .sku {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0 0 auto;
}

#turbo-pos-app .product-info .price {
    margin-top: 10px;
    font-weight: 700;
    color: var(--primary-color);
    font-size: 1.1rem;
}

#turbo-pos-app .pos-cart-sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: white;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    max-height: 100%;
}

#turbo-pos-app .cart-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#turbo-pos-app .clear-cart-btn {
    background: transparent;
    border: none;
    color: #e53935;
    cursor: pointer;
    font-size: 0.9rem;
}

#turbo-pos-app .cart-items-container {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 0;
}

#turbo-pos-app .empty-state-cart {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
}

#turbo-pos-app .cart-footer-summary {
    padding: 20px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 10;
    /* margin-bottom: 20px; Removed to prevent overflow */
}

#turbo-pos-app .summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

#turbo-pos-app .summary-row.total {
    font-weight: 700;
    font-size: 1.2rem;
    margin-top: 10px;
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
}

#turbo-pos-app .cart-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

#turbo-pos-app .checkout-btn,
#turbo-pos-app #reserve-order-btn {
    border: none;
    color: white;
    padding: 15px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 5px;
    /* Removed shared width: 100% since we use flex */
}

#turbo-pos-app .checkout-btn {
    background: var(--primary-color);
    flex: 3 !important;
    /* 75% */
}

#turbo-pos-app #reserve-order-btn {
    background: #FF9800;
    flex: 1 !important;
    /* 25% */
}

#turbo-pos-app #reserve-order-btn:hover {
    background: #f57c00;
}

/* Header Hold Buttons */
#pos-held-orders-btn,
#hold-order-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    border-radius: 20px;
    padding: 5px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    height: 32px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-right: 10px;
    position: relative;
    /* Ensure badge positions correctly */
    overflow: visible;
    /* Ensure badge can be seen outside button */
}

#pos-held-orders-btn:hover,
#hold-order-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

#hold-order-btn {
    background: var(--secondary-color);
    /* Make "Mantener" distinct */
    color: #000;
    /* Contrast for secondary color */
}

#turbo-pos-app .cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 10px 0;
    gap: 10px;
}

#turbo-pos-app .cart-item-left {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    gap: 10px;
}

#turbo-pos-app .item-name {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

#turbo-pos-app .cart-item-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid #eee;
    flex-shrink: 0;
}

#turbo-pos-app .cart-item-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#turbo-pos-app .pos-price-input {
    width: 70px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 5px;
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
}

#turbo-pos-app .item-line-total {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 50px;
    text-align: right;
}

#turbo-pos-app .remove-item-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(229, 57, 53, 0.1);
    color: #e53935;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
}

#turbo-pos-app .remove-item-btn:hover {
    background: #e53935;
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    #turbo-pos-app .turbo-pos-main-layout {
        flex-direction: column;
        height: auto;
    }

    #turbo-pos-app .pos-cart-sidebar {
        width: 100%;
        height: 50vh;
    }
}

/* Payment Popup Styles - Keep Global or Scoped */
.pos-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.pos-popup-content {
    background: white;
    width: 100%;
    max-width: 500px;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pos-popup-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.payment-methods-grid {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.pm-btn {
    flex: 1;
    padding: 15px;
    border: 2px solid #ddd;
    background: #f9f9f9;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: #555;
}

.pm-btn:hover {
    background: #eee;
    border-color: #ccc;
}

.pm-btn.active {
    border-color: var(--primary-color);
    background: rgba(98, 0, 234, 0.05);
    color: var(--primary-color);
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.pos-input {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
}

.popup-actions {
    display: flex;
    gap: 15px;
}

.popup-actions button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
}

#cancel-payment-btn {
    background: #e0e0e0;
    color: #333;
}

#finalize-payment-btn {
    background: #4CAF50;
    color: white;
}

#finalize-payment-btn:hover {
    background: #43a047;
}

#cancel-payment-btn:hover {
    background: #d5d5d5;
}

/* Clear All Toggle Specifics */
.clear-toggle-wrapper .slider {
    background-color: #ccc;
}

.clear-toggle-wrapper input:checked+.slider {
    background-color: #e53935;
    /* Red for clear all active */
}

/* Quick Create Button */
#pos-quick-create-btn {
    margin-left: 10px;
    height: 30px;
    width: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: #FF9800;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: none;
    /* Hidden by default, toggled by JS */
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
}

#pos-quick-create-btn:hover {
    transform: scale(1.1);
    background: #43a047;
    border-color: white;
}

/* iOS Style Buttons & Inputs */
.ios-btn-full {
    width: 100%;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #444;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ios-btn-full:hover {
    background: #fafafa;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

.ios-btn-full:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.ios-btn-icon {
    flex: 1;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

.ios-btn-icon:hover {
    background: #fafafa;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

.ios-btn-icon.active {
    background: #eff6ff;
    border-color: #2196f3;
    color: #2196f3;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ios-btn-small {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.ios-btn-small:hover {
    background: #f5f5f5;
    color: #333;
}

.ios-header-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 12px;
    color: white;
    transition: background 0.2s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}

.ios-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ios-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF3B30;
    /* iOS Red */
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid white;
}

/* Animations */
.held-active {
    animation: bounceIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

/* User Profile Modal Custom */
#user-profile-modal .pos-popup-content {
    border-radius: 20px;
    padding: 30px 20px;
}