/**
 * WW Quick Order — Styles
 * Mobile-first, theme-agnostic
 */

/* ─── Reset & Base ─────────────────────────────────── */

[x-cloak] { display: none !important; }

.ww-qo {
    --qo-primary: #d4a017;
    --qo-primary-hover: #b88a13;
    --qo-danger: #dc3545;
    --qo-success: #28a745;
    --qo-bg: #ffffff;
    --qo-bg-alt: #f8f9fa;
    --qo-border: #dee2e6;
    --qo-text: #212529;
    --qo-text-light: #6c757d;
    --qo-radius: 8px;
    --qo-shadow: 0 1px 3px rgba(0,0,0,0.1);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--qo-text);
    line-height: 1.5;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 12px;
    box-sizing: border-box;
}

.ww-qo *, .ww-qo *::before, .ww-qo *::after {
    box-sizing: border-box;
}

/* ─── Login ────────────────────────────────────────── */

.ww-qo-login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 20px;
}

.ww-qo-login-card {
    background: var(--qo-bg);
    border: 1px solid var(--qo-border);
    border-radius: 12px;
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: var(--qo-shadow);
}

.ww-qo-login-logo {
    font-size: 48px;
    margin-bottom: 8px;
}

.ww-qo-login-card h2 {
    font-size: 20px;
    margin: 0 0 4px;
}

.ww-qo-login-sub {
    color: var(--qo-text-light);
    font-size: 14px;
    margin: 0 0 20px;
}

.ww-qo-login-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ─── Header ───────────────────────────────────────── */

.ww-qo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--qo-border);
    margin-bottom: 16px;
    position: sticky;
    top: 0;
    background: var(--qo-bg);
    z-index: 10;
}

.ww-qo-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ww-qo-header-title {
    font-weight: 600;
    font-size: 16px;
}

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

.ww-qo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    border: 1px solid var(--qo-border) !important;
    border-radius: var(--qo-radius) !important;
    background: var(--qo-bg) !important;
    color: var(--qo-text) !important;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    box-shadow: none !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
}

.ww-qo-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ww-qo-btn-primary {
    background: var(--qo-primary) !important;
    border-color: var(--qo-primary) !important;
    color: #fff !important;
}

.ww-qo-btn-primary:hover:not(:disabled) {
    background: var(--qo-primary-hover) !important;
    color: #fff !important;
}

.ww-qo-btn-ghost {
    background: transparent !important;
    border-color: transparent !important;
    color: var(--qo-text) !important;
}

.ww-qo-btn-ghost:hover {
    background: var(--qo-bg-alt) !important;
}

.ww-qo-btn-outline {
    background: transparent !important;
    border-color: var(--qo-primary) !important;
    color: var(--qo-primary) !important;
}

.ww-qo-btn-outline:hover {
    background: var(--qo-primary) !important;
    color: #fff !important;
}

.ww-qo-btn-danger {
    background: transparent !important;
    border-color: transparent !important;
    color: var(--qo-danger) !important;
}

.ww-qo-btn-danger:hover {
    background: #fff0f0 !important;
}

.ww-qo-btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    min-height: 36px;
}

.ww-qo-btn-lg {
    padding: 14px 24px;
    font-size: 16px;
    min-height: 52px;
}

.ww-qo-btn-full {
    width: 100%;
}

.ww-qo-btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ─── Inputs ───────────────────────────────────────── */

.ww-qo-input {
    width: 100%;
    padding: 10px 12px !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    border: 1px solid var(--qo-border) !important;
    border-radius: var(--qo-radius) !important;
    background: var(--qo-bg) !important;
    color: var(--qo-text) !important;
    min-height: 44px;
    font-family: inherit;
    box-shadow: none !important;
}

.ww-qo-input:focus {
    outline: none !important;
    border-color: var(--qo-primary) !important;
    box-shadow: 0 0 0 2px rgba(212, 160, 23, 0.2) !important;
}

.ww-qo-input-sm {
    min-height: 36px;
    padding: 6px 8px;
    font-size: 14px;
    width: auto;
    min-width: 80px;
}

select.ww-qo-input {
    appearance: auto;
}

textarea.ww-qo-input {
    resize: vertical;
}

/* ─── Fields ───────────────────────────────────────── */

.ww-qo-field {
    margin-bottom: 14px;
}

.ww-qo-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--qo-text-light);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ww-qo-field-row {
    display: flex;
    gap: 10px;
}

.ww-qo-field-row .ww-qo-field {
    flex: 1;
}

.ww-qo-hint {
    font-size: 12px;
    color: var(--qo-text-light);
    margin-top: 2px;
    display: block;
}

.ww-qo-error {
    color: var(--qo-danger);
    font-size: 14px;
    margin: 4px 0 0;
}

/* ─── Panels ───────────────────────────────────────── */

.ww-qo-panel {
    margin-bottom: 24px;
}

.ww-qo-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.ww-qo-panel-header h3 {
    margin: 0;
    font-size: 18px;
}

.ww-qo-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--qo-text-light);
    background: var(--qo-bg-alt);
    border-radius: var(--qo-radius);
    font-size: 14px;
}

/* ─── Cards ────────────────────────────────────────── */

.ww-qo-card-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ww-qo-card {
    background: var(--qo-bg);
    border: 1px solid var(--qo-border);
    border-radius: var(--qo-radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.ww-qo-card:hover {
    border-color: var(--qo-primary);
}

.ww-qo-card-compact {
    cursor: default;
}

.ww-qo-card-compact:hover {
    border-color: var(--qo-border);
}

.ww-qo-card-inactive {
    opacity: 0.5;
}

.ww-qo-card-title {
    font-weight: 600;
    font-size: 15px;
}

.ww-qo-card-sub {
    font-size: 13px;
    color: var(--qo-text-light);
    margin-top: 2px;
}

.ww-qo-card-meta {
    font-size: 12px;
    margin-top: 6px;
}

.ww-qo-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.ww-qo-card-actions {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}

/* ─── Tabs ─────────────────────────────────────────── */

.ww-qo-tabs {
    display: flex;
    border-bottom: 2px solid var(--qo-border);
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding: 0 4px;
}

.ww-qo-tabs button {
    flex: 1;
    padding: 10px 8px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    background: var(--qo-bg-alt) !important;
    border: 1px solid var(--qo-border) !important;
    border-bottom: 2px solid transparent !important;
    border-radius: 6px 6px 0 0 !important;
    margin-bottom: -2px;
    color: var(--qo-text-light) !important;
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    box-shadow: none !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
}

.ww-qo-tabs button:hover {
    background: var(--qo-bg) !important;
    color: var(--qo-text) !important;
}

.ww-qo-tabs button.active {
    color: var(--qo-primary) !important;
    background: var(--qo-bg) !important;
    border-color: var(--qo-border) !important;
    border-bottom-color: var(--qo-bg) !important;
    font-weight: 600 !important;
}

/* ─── Order Grid ───────────────────────────────────── */

.ww-qo-order-panel {
    padding-bottom: 80px; /* Room for sticky summary */
}

.ww-qo-order-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 16px;
}

.ww-qo-order-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--qo-bg);
    border: 1px solid var(--qo-border);
    border-radius: 6px;
    min-height: 52px;
}

.ww-qo-order-flavor {
    flex: 1;
    min-width: 0;
}

.ww-qo-order-name {
    font-weight: 500;
    font-size: 14px;
    display: block;
}

.ww-qo-order-size {
    font-size: 12px;
    color: var(--qo-text-light);
}

.ww-qo-order-price {
    font-size: 12px;
    color: var(--qo-text-light);
    margin-left: 6px;
}

.ww-qo-order-qty {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.ww-qo-qty-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    border: 1px solid var(--qo-border) !important;
    border-radius: 6px !important;
    background: var(--qo-bg-alt) !important;
    color: var(--qo-text) !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    line-height: 1;
    text-decoration: none !important;
    box-shadow: none !important;
}

.ww-qo-qty-btn:hover {
    background: var(--qo-border) !important;
    color: var(--qo-text) !important;
}

.ww-qo-qty-btn:active {
    background: #ccc !important;
    color: var(--qo-text) !important;
}

.ww-qo-qty-input {
    width: 48px;
    height: 40px;
    text-align: center;
    font-size: 16px !important;
    font-weight: 600 !important;
    border: 1px solid var(--qo-border) !important;
    border-radius: 6px !important;
    background: var(--qo-bg) !important;
    color: var(--qo-text) !important;
    box-shadow: none !important;
    -moz-appearance: textfield;
    padding: 4px !important;
}

.ww-qo-qty-input::-webkit-outer-spin-button,
.ww-qo-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ─── Order Summary ────────────────────────────────── */

.ww-qo-order-summary {
    position: sticky;
    bottom: 0;
    background: var(--qo-bg);
    border-top: 2px solid var(--qo-border);
    padding: 12px 0;
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
}

.ww-qo-order-total {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 15px;
}

/* ─── Success Panel ────────────────────────────────── */

.ww-qo-success-panel {
    text-align: center;
    padding: 40px 20px;
}

.ww-qo-success-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--qo-success);
    color: #fff;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.ww-qo-success-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* ─── Badges ───────────────────────────────────────── */

.ww-qo-badge {
    display: inline-block;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    background: #e3f2fd;
    color: #1565c0;
    text-transform: uppercase;
    vertical-align: middle;
    margin-left: 4px;
}

.ww-qo-badge-warn {
    background: #fff3e0;
    color: #e65100;
}

.ww-qo-badge-success {
    background: #e8f5e9;
    color: #2e7d32;
}

/* ─── Modals ───────────────────────────────────────── */

.ww-qo-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

@media (min-width: 600px) {
    .ww-qo-modal-overlay {
        align-items: center;
        padding: 20px;
    }
}

.ww-qo-modal {
    background: var(--qo-bg);
    border-radius: 16px 16px 0 0;
    padding: 24px 20px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

@media (min-width: 600px) {
    .ww-qo-modal {
        max-width: 520px;
        border-radius: 12px;
        animation: none;
    }
}

.ww-qo-modal-lg {
    max-width: 640px;
}

.ww-qo-modal h3 {
    margin: 0 0 16px;
    font-size: 18px;
}

.ww-qo-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ─── Product Search (Flavor Modal) ────────────────── */

.ww-qo-product-list {
    max-height: 50vh;
    overflow-y: auto;
}

.ww-qo-product-item {
    border-bottom: 1px solid var(--qo-border);
    padding: 12px 0;
}

.ww-qo-product-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}

.ww-qo-variations {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 8px;
}

.ww-qo-variation-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    padding: 4px 0;
}

.ww-qo-variation-price {
    color: var(--qo-text-light);
    font-size: 12px;
}

.ww-qo-inline-form {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-left: auto;
}

/* ─── Toast ────────────────────────────────────────── */

.ww-qo-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    background: #333;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.ww-qo-toast.success {
    background: var(--qo-success);
}

.ww-qo-toast.error {
    background: var(--qo-danger);
}

/* ─── Responsive ───────────────────────────────────── */

@media (max-width: 480px) {
    .ww-qo-field-row {
        flex-direction: column;
        gap: 0;
    }

    .ww-qo-card-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .ww-qo-card-actions {
        margin-top: 4px;
    }

    .ww-qo-variation-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .ww-qo-inline-form {
        margin-left: 0;
        margin-top: 4px;
    }

    .ww-qo-btn-group {
        flex-direction: column;
    }
}

/* ─── All Quantities Control ──────────────────────── */

.ww-qo .ww-qo-all-qty {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: var(--qo-primary) !important;
    color: #fff !important;
    padding: 10px 14px !important;
    border-radius: var(--qo-radius) !important;
    margin-bottom: 8px !important;
}

.ww-qo .ww-qo-all-qty-label {
    font-weight: 600 !important;
    font-size: 15px !important;
    color: #fff !important;
}

.ww-qo .ww-qo-all-qty .ww-qo-qty-btn {
    background: rgba(255,255,255,0.2) !important;
    color: #fff !important;
    border-color: rgba(255,255,255,0.3) !important;
}

.ww-qo .ww-qo-all-qty .ww-qo-qty-btn:hover {
    background: rgba(255,255,255,0.35) !important;
}

.ww-qo .ww-qo-all-qty .ww-qo-qty-input {
    background: rgba(255,255,255,0.9) !important;
    color: var(--qo-text) !important;
}

/* ─── Order Success Screen ────────────────────────── */

.ww-qo .ww-qo-success-panel {
    text-align: center;
    padding: 32px 16px !important;
}

.ww-qo .ww-qo-success-icon {
    width: 56px;
    height: 56px;
    line-height: 56px;
    border-radius: 50%;
    background: var(--qo-success);
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    margin: 0 auto 12px;
}

.ww-qo .ww-qo-success-total {
    font-size: 28px;
    font-weight: 700;
    margin: 4px 0;
}

.ww-qo .ww-qo-success-sub {
    color: var(--qo-text-light);
    margin: 0 0 16px;
}

/* ─── Invoice Action Buttons ──────────────────────── */

.ww-qo .ww-qo-invoice-actions {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--qo-border);
}

.ww-qo .ww-qo-invoice-actions h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--qo-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ww-qo .ww-qo-btn-group-vertical {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
}

.ww-qo .ww-qo-btn-group-vertical .ww-qo-btn {
    text-align: center !important;
}

/* ─── Badge Variants ──────────────────────────────── */

.ww-qo .ww-qo-badge-success {
    background: var(--qo-success) !important;
    color: #fff !important;
}

.ww-qo .ww-qo-badge-warn {
    background: #ffc107 !important;
    color: #212529 !important;
}

.ww-qo .ww-qo-badge-lg {
    font-size: 14px !important;
    padding: 6px 20px !important;
    border-radius: 4px !important;
    letter-spacing: 1px !important;
    display: inline-block !important;
}

/* ─── Order Detail View ───────────────────────────── */

.ww-qo .ww-qo-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.ww-qo .ww-qo-detail-label {
    margin: 0 0 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--qo-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ww-qo .ww-qo-detail-value {
    margin: 0;
    font-size: 14px;
}

.ww-qo .ww-qo-detail-items {
    border: 1px solid var(--qo-border);
    border-radius: var(--qo-radius);
    overflow: hidden;
}

.ww-qo .ww-qo-detail-item-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--qo-border);
    font-size: 14px;
}

.ww-qo .ww-qo-detail-item-row:last-child {
    border-bottom: none;
}

.ww-qo .ww-qo-detail-item-row span:first-child {
    flex: 1;
}

.ww-qo .ww-qo-detail-item-row span:nth-child(2) {
    width: 50px;
    text-align: center;
    color: var(--qo-text-light);
}

.ww-qo .ww-qo-detail-item-row span:last-child {
    width: 80px;
    text-align: right;
    font-weight: 500;
}

.ww-qo .ww-qo-detail-totals {
    margin-top: 12px;
    border-top: 1px solid var(--qo-border);
    padding-top: 8px;
}

.ww-qo .ww-qo-detail-total-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}

.ww-qo .ww-qo-detail-total-grand {
    font-size: 18px;
    font-weight: 700;
    padding-top: 8px;
    border-top: 2px solid var(--qo-text);
    margin-top: 4px;
}

@media (max-width: 480px) {
    .ww-qo .ww-qo-detail-grid {
        grid-template-columns: 1fr;
    }
    .ww-qo .ww-qo-all-qty {
        flex-wrap: wrap;
        gap: 8px;
    }
}

/* ─── WC Customer Linking ─────────────────────────── */

.ww-qo .ww-qo-linked-account {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    background: var(--qo-bg-alt) !important;
    border: 1px solid var(--qo-border) !important;
    border-radius: var(--qo-radius) !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
}

.ww-qo .ww-qo-linked-label {
    font-weight: 500 !important;
}

.ww-qo .ww-qo-dropdown-list {
    border: 1px solid var(--qo-border) !important;
    border-radius: var(--qo-radius) !important;
    max-height: 200px !important;
    overflow-y: auto !important;
    margin-top: 4px !important;
    background: var(--qo-bg) !important;
    box-shadow: var(--qo-shadow) !important;
}

.ww-qo .ww-qo-dropdown-item {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 10px 14px !important;
    cursor: pointer !important;
    border-bottom: 1px solid var(--qo-border) !important;
    font-size: 14px !important;
    gap: 8px !important;
}

.ww-qo .ww-qo-dropdown-item:last-child {
    border-bottom: none !important;
}

.ww-qo .ww-qo-dropdown-item:hover {
    background: var(--qo-bg-alt) !important;
}

.ww-qo .ww-qo-hint {
    font-size: 12px !important;
    color: var(--qo-text-light) !important;
    margin: 4px 0 8px !important;
}

.ww-qo .ww-qo-hint code {
    background: var(--qo-bg-alt) !important;
    padding: 1px 5px !important;
    border-radius: 3px !important;
    font-size: 12px !important;
}
