:root {
    --primary-color: #003366;
    --secondary-color: #b08d57;
    /* More subtle gold */
    --accent-color: #007aff;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --border-color: #e1e4e8;
    --text-color: #1a1a1a;
    --text-dim: #666666;
    --success-color: #34c759;
    --error-color: #ff3b30;
    --transition: all 0.2s ease-in-out;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

.app-container {
    width: 100%;
    max-width: 505px;
    margin: 0 auto;
    background: var(--card-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
    overflow-x: hidden;
}

.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    animation: slideIn 0.3s ease-out;
    overflow-x: hidden;
}

/* Special layout for customer screen with fixed button */
.customers-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

.logo {
    text-align: center;
    padding: 40px 0;
}

.logo span {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

/* UI Elements */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

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

.input-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="tel"],
select {
    width: 100%;
    padding: 14px;
    background: #fff;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 16px;
    outline: none;
    transition: var(--transition);
}

input:focus,
select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

.btn {
    display: block;
    width: 100%;
    padding: 16px;
    border-radius: 10px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:active {
    background-color: #002244;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:active {
    background: rgba(0, 51, 102, 0.05);
}

/* List Items */
.list-item {
    background: #fff;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-item:active {
    background: #f9f9f9;
}

.list-item.selected {
    border-color: var(--primary-color);
    background: rgba(0, 51, 102, 0.02);
}

/* Nav Bar */
.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.back-btn {
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
}

/* Table Style for Cart Summary */
.cart-summary-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 6px;
    margin-top: 20px;
    font-size: 10px;
}

.cart-summary-table th {
    text-align: center;
    color: var(--text-dim);
    padding: 6px 2px;
    border-bottom: 1px solid var(--border-color);
    font-size: 9px;
    line-height: 1.2;
}

.cart-summary-table td {
    text-align: center;
    padding: 10px 3px;
    position: relative;
    background-color: inherit;
    font-size: 10px;
    line-height: 1.3;
}

.cart-summary-table td:first-child {
    text-align: left;
    padding-left: 8px;
    padding-right: 4px;
    font-size: 11px;
}

.cart-summary-table td:first-child .bold {
    font-size: 12px;
    line-height: 1.2;
}

.cart-summary-table td:first-child .small {
    font-size: 9px;
    display: block;
    margin-top: 2px;
}

.cart-summary-table td:not(:first-child) {
    min-width: 50px;
    max-width: 62px;
}

.cart-summary-table tr.cart-row td {
    border-top: 1.5px solid var(--border-color);
    border-bottom: 1.5px solid var(--border-color);
}

.cart-summary-table tr.cart-row td:first-child {
    border-left: 1.5px solid var(--border-color);
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.cart-summary-table tr.cart-row td:last-child {
    border-right: 1.5px solid var(--border-color);
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

.cart-summary-table select {
    position: relative;
    z-index: 10;
}

.category-price {
    font-weight: 700;
    color: var(--primary-color);
}

/* Slight improvements for desktop while keeping 505px width */
@media (min-width: 769px) {
    .cart-summary-table {
        font-size: 11px;
    }

    .cart-summary-table th {
        font-size: 10px;
        padding: 8px 3px;
    }

    .cart-summary-table td {
        padding: 12px 4px;
        font-size: 11px;
    }

    .cart-summary-table td:first-child {
        font-size: 12px;
    }

    .cart-summary-table td:first-child .bold {
        font-size: 13px;
    }
}

/* Picker UI */
.picker-container {
    display: flex;
    gap: 10px;
}

/* Bottom Actions */
.bottom-actions {
    margin-top: auto;
    padding-top: 20px;
}

/* Helper Classes */
.mt-auto {
    margin-top: auto;
}

.text-center {
    text-align: center;
}

.text-dim {
    color: var(--text-dim);
}

.small {
    font-size: 13px;
}

.bold {
    font-weight: 700;
}

.price-box {
    text-align: center;
    padding: 24px;
    background: #f8faff;
    border-radius: 12px;
    margin: 20px 0;
}

.price-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary-color);
}

.cart-item {
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
}

.cart-item:last-child {
    border-bottom: none;
}

/* Mobile Optimizations */
@media (max-width: 768px) {

    /* Better touch targets */
    .btn {
        min-height: 48px;
        padding: 14px 16px;
    }

    .list-item {
        min-height: 56px;
        padding: 18px;
    }

    .back-btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        padding: 8px 12px;
    }

    /* Horizontal scroll for cart table - FIXED */
    .cart-summary-table {
        font-size: 12px;
        min-width: 100%;
        border-collapse: collapse;
    }

    .cart-summary-table th,
    .cart-summary-table td {
        padding: 10px 8px;
        min-width: 70px;
        font-size: 12px;
        white-space: normal;
        word-wrap: break-word;
    }

    .cart-summary-table th:first-child,
    .cart-summary-table td:first-child {
        min-width: 120px;
        max-width: 150px;
    }

    /* Better input sizing for mobile */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="password"],
    input[type="tel"],
    select {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
        min-height: 48px;
    }

    /* iOS-specific fixes */
    input,
    select,
    textarea {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border-radius: 10px;
    }

    /* Prevent double-tap zoom */
    * {
        touch-action: manipulation;
    }

    /* Better spacing on mobile */
    .screen {
        padding: 16px;
    }

    .card {
        padding: 16px;
    }
}

/* Loading state for buttons */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Action link styling */
.action-link {
    cursor: pointer;
    text-decoration: underline;
    color: var(--accent-color);
}

.action-link:active {
    opacity: 0.7;
}

/* Logout button */
.btn-logout {
    background: transparent;
    border: 1px solid var(--error-color);
    color: var(--error-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:active {
    background: rgba(255, 59, 48, 0.1);
}

/* Mobile cart cards */
.cart-mobile-view {
    display: none;
}

.cart-item-card {
    background: #fff;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-details {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.cart-item-pricing {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 13px;
}

.cart-mobile-totals {
    background: #f8faff;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    margin-top: 16px;
}

.cart-mobile-total-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
}

/* Responsive: Show mobile view on small screens */
@media (max-width: 768px) {
    .cart-desktop-view {
        display: none !important;
    }

    .cart-mobile-view {
        display: block !important;
    }
}

/* Customer List Styling with Creative Reveal */
.customer-card-container {
    position: relative;
    overflow: hidden;
    margin-bottom: 12px;
    border-radius: 12px;
    background: #f8faff;
    /* Match subtotal bg */
    border: 1.5px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.customer-card-container:active {
    transform: scale(0.995);
}

.customer-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f8faff;
    /* Match subtotal bg */
    cursor: pointer;
    position: relative;
    z-index: 2;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.customer-info {
    flex: 1;
}

.customer-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.customer-subtext {
    font-size: 12px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* The hidden partial background for delete action */
.customer-actions-bg {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 80px;
    background: #fff1f0;
    /* Light red bg */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
}

.delete-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ff4444;
    color: #ffffff;
    /* Explicitly white */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
    transition: transform 0.2s;
    opacity: 0;
    transform: scale(0.5);
}

/* State for showing delete */
.customer-card-container.show-delete .customer-card {
    transform: translateX(-70px);
}

.customer-card-container.show-delete .delete-action-btn {
    opacity: 1;
    transform: scale(1);
}

/* The visual indicator to swipe/more */
.more-options-indicator {
    padding: 8px;
    color: var(--text-dim);
    opacity: 0.5;
    transition: opacity 0.2s;
}

.customer-card:hover .more-options-indicator {
    opacity: 1;
}

/* Avatar Circle */
.customer-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    margin-right: 16px;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Payment Button Pulse Animation */
@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
    }

    50% {
        box-shadow: 0 0 30px rgba(16, 185, 129, 0.6);
    }
}

/* Payment Modal Styling */
.payment-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.payment-modal-content {
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

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

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

.payment-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.close-modal-btn {
    background: transparent;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-dim);
    transition: color 0.2s;
}

.close-modal-btn:hover {
    color: var(--text-color);
}

/* Stripe Payment Element Container */
#payment-element {
    margin: 20px 0;
    padding: 16px;
    background: #f8faff;
    border-radius: 10px;
}

.payment-status-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.payment-status-paid {
    background: #d4edda;
    color: #155724;
}

.payment-status-pending {
    background: #fff3cd;
    color: #856404;
}