/* =====================================================
   Fridge POS System - Touch-optimized Styles
   ===================================================== */

:root {
    /* Colors - Dark Mode */
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-glass: rgba(255, 255, 255, 0.08);
    --bg-glass-hover: rgba(255, 255, 255, 0.15);

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);

    --accent-blue: #0a84ff;
    --accent-green: #30d158;
    --accent-orange: #ff9f0a;
    --accent-red: #ff453a;
    --accent-purple: #bf5af2;

    /* Shadows */
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(10, 132, 255, 0.3);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Sizing */
    --touch-target: 56px;
    --border-radius: 16px;
    --border-radius-lg: 24px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* =====================================================
   Screens
   ===================================================== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* =====================================================
   Lockscreen
   ===================================================== */
.lockscreen-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    padding: 40px 20px;
}

.time {
    font-size: clamp(64px, 15vw, 120px);
    font-weight: 200;
    letter-spacing: -2px;
    margin-bottom: 8px;
}

.date {
    font-size: clamp(16px, 4vw, 24px);
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

/* PIN Display */
.pin-display {
    margin-bottom: 32px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pin-dots {
    display: flex;
    gap: 16px;
}

.dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: 2px solid var(--text-secondary);
    transition: all 0.2s ease;
}

.dot.filled {
    background: var(--text-primary);
    border-color: var(--text-primary);
    transform: scale(1.1);
}

.dot.error {
    background: var(--accent-red);
    border-color: var(--accent-red);
    animation: shake 0.5s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    20%,
    60% {
        transform: translateX(-8px);
    }

    40%,
    80% {
        transform: translateX(8px);
    }
}

.pin-error {
    margin-top: 16px;
    color: var(--accent-red);
    font-size: 14px;
    font-weight: 500;
    min-height: 20px;
}

/* Keypad */
.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 320px;
    width: 100%;
}

.key {
    height: 80px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-size: 32px;
    font-weight: 300;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.key:active {
    background: var(--bg-glass-hover);
    transform: scale(0.95);
}

.key.guest {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--accent-blue), #5856d6);
}

.key.guest:active {
    background: linear-gradient(135deg, #0066cc, #4644b0);
}

.key.delete svg {
    width: 28px;
    height: 28px;
}

/* =====================================================
   Modal
   ===================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-soft);
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-content h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal-input {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 18px;
    font-family: var(--font-family);
    margin-bottom: 16px;
    outline: none;
    transition: box-shadow 0.2s ease;
}

.modal-input:focus {
    box-shadow: 0 0 0 2px var(--accent-blue);
}

.modal-input::placeholder {
    color: var(--text-tertiary);
}

/* Modal Numpad */
.modal-numpad {
    max-width: 320px;
}

.numpad-display {
    width: 100%;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.numpad-key {
    padding: 20px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--border-radius);
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.numpad-key:active {
    background: var(--accent-blue);
    transform: scale(0.95);
}

.numpad-clear {
    background: var(--accent-orange);
    color: white;
}

.numpad-del {
    background: var(--bg-secondary);
}

/* Log Subtabs */
.log-subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.log-subpanel {
    display: none;
}

.log-subpanel.active {
    display: block;
}

/* Totals Controls */
.totals-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.month-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.month-btn:active {
    background: var(--accent-blue);
    transform: scale(0.95);
}

.month-display {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 150px;
    text-align: center;
}

/* Totals Content */
.totals-user {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 12px;
}

.totals-user h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.totals-user .total {
    font-size: 14px;
    color: var(--accent-green);
    font-weight: 500;
}

.totals-products {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.totals-product {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: 16px;
    font-size: 13px;
}

.totals-product .qty {
    font-weight: 600;
    color: var(--accent-blue);
}

.totals-product-img {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
}

.totals-product-emoji {
    font-size: 14px;
}

.totals-overall {
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-top: 20px;
}

.totals-overall h3 {
    color: white;
    font-size: 16px;
    margin-bottom: 16px;
}

/* Subpanel Description */
.subpanel-desc {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: -8px 0 16px 0;
}

/* Correction Modal */
.correction-location {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.location-btn {
    flex: 1;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.location-btn.active {
    border-color: var(--accent-blue);
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.correction-adjust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.adjust-btn {
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    font-size: 28px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.adjust-btn.minus {
    background: var(--accent-red);
    color: white;
}

.adjust-btn.plus {
    background: var(--accent-green);
    color: white;
}

.adjust-btn:active {
    transform: scale(0.9);
}

.adjust-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 80px;
    text-align: center;
}

.adjust-value.negative {
    color: var(--accent-red);
}

.adjust-value.positive {
    color: var(--accent-green);
}

/* Stocktake List */
.stocktake-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stocktake-item {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 16px;
}

.stocktake-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.stocktake-header img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.stocktake-header .emoji {
    font-size: 32px;
}

.stocktake-header .name {
    font-size: 16px;
    font-weight: 600;
}

.stocktake-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stocktake-field {
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 12px;
}

.stocktake-field label {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.stocktake-field input {
    width: 100%;
    padding: 8px;
    background: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.stocktake-diff {
    margin-top: 12px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stocktake-diff.has-diff {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--accent-red);
}

.stocktake-diff .diff-text {
    font-size: 13px;
    color: var(--text-secondary);
}

.stocktake-diff .diff-value {
    font-weight: 600;
}

.stocktake-diff .diff-value.positive {
    color: var(--accent-green);
}

.stocktake-diff .diff-value.negative {
    color: var(--accent-red);
}

.stocktake-save {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: var(--accent-blue);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: none;
}

.stocktake-save.show {
    display: block;
}

.stocktake-save:active {
    transform: scale(0.98);
}

/* Image Upload */
.image-upload-container {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.image-preview {
    width: 100px;
    height: 100px;
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-placeholder {
    font-size: 40px;
    opacity: 0.5;
}

.image-upload-btn {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.image-upload-btn:active {
    background: var(--accent-blue);
    transform: scale(0.95);
}

/* Product Image in Card */
.product-image {
    width: 80px;
    height: 80px;
    border-radius: var(--border-radius);
    object-fit: cover;
    margin-bottom: 16px;
}

.guest-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.guest-suggestion {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
}

.guest-suggestion:hover,
.guest-suggestion:active {
    background: var(--accent-blue);
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.modal-btn.primary:active {
    background: #0066cc;
    transform: scale(0.95);
}

.modal-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-btn.secondary:active {
    background: var(--bg-glass-hover);
    transform: scale(0.95);
}

.modal-btn.danger {
    background: var(--accent-red);
    color: white;
}

.modal-btn.danger:active {
    background: #c93b3b;
    transform: scale(0.95);
}

/* Undo Modal */
.undo-modal {
    max-width: 450px;
}

.undo-info {
    font-size: 14px;
    margin-bottom: 16px;
}

.undo-items {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
}

.undo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.undo-item-img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.undo-item-emoji {
    font-size: 28px;
    width: 40px;
    text-align: center;
}

.undo-item-info {
    flex: 1;
    min-width: 0;
}

.undo-item-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.undo-item-details {
    font-size: 12px;
    color: var(--text-tertiary);
}

.undo-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.undo-qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.undo-qty-btn.minus {
    background: var(--accent-red);
    color: white;
}

.undo-qty-btn.plus {
    background: var(--accent-green);
    color: white;
}

.undo-qty-btn:active {
    transform: scale(0.9);
}

.undo-qty-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.undo-item-qty {
    font-size: 18px;
    font-weight: 700;
    min-width: 30px;
    text-align: center;
}

.undo-item-max {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Quantity Display */
.quantity-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin: 24px 0;
}

.qty-btn {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: var(--accent-blue);
    color: white;
    font-size: 28px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qty-btn:active {
    transform: scale(0.9);
}

.qty-value {
    font-size: 48px;
    font-weight: 300;
    min-width: 80px;
    text-align: center;
}

/* =====================================================
   POS Screen
   ===================================================== */
#pos {
    flex-direction: column;
    background: var(--bg-primary);
}

.pos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    font-size: 28px;
}

.user-name {
    font-size: 18px;
    font-weight: 600;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.15s ease;
}

.logout-btn:active {
    background: var(--accent-red);
    transform: scale(0.95);
}

.logout-btn svg {
    width: 20px;
    height: 20px;
}

.pos-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 100px;
    -webkit-overflow-scrolling: touch;
}

.legend {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    justify-content: center;
}

.legend-item {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.product-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.product-card:active {
    transform: scale(0.96);
    border-color: var(--accent-blue);
}

.product-card:active::before {
    opacity: 1;
}

.product-card.taking {
    pointer-events: none;
    opacity: 0.7;
}

.product-card.success {
    border-color: var(--accent-green);
    animation: pulse-success 0.5s ease;
}

@keyframes pulse-success {

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

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

.product-emoji {
    font-size: 56px;
    margin-bottom: 16px;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.product-stock {
    display: flex;
    gap: 16px;
    font-size: 14px;
}

.stock-item {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.stock-item.low {
    color: var(--accent-orange);
}

.stock-item.empty {
    color: var(--accent-red);
}

/* Log Comment and Type */
.log-type {
    display: inline-block;
    margin-right: 8px;
    font-size: 14px;
}

.log-comment {
    margin-top: 6px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

.log-quantity.positive {
    color: var(--accent-green);
}

.log-quantity.negative {
    color: var(--accent-red);
}

/* Grouped Log Entries (Cart Checkout) */
.log-entry.grouped {
    border-left: 3px solid var(--accent-green);
    background: linear-gradient(90deg, rgba(0, 217, 117, 0.05) 0%, transparent 100%);
}

.log-entry.grouped .log-content {
    gap: 6px;
}

.log-type.cart {
    background: var(--accent-green);
    color: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 12px;
    margin-right: 6px;
}

/* =====================================================
   POS Toolbar with Quick Checkout
   ===================================================== */
.pos-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    margin-bottom: 16px;
}

.quick-checkout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-green), #00a86b);
    border: none;
    border-radius: 25px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

.quick-checkout-btn.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.quick-checkout-btn:active {
    transform: scale(0.95);
}

.quick-checkout-count {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
}

/* =====================================================
   Cart Tab (Right Edge)
   ===================================================== */
.cart-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, var(--accent-green), #00a86b);
    padding: 16px 8px;
    border-radius: 12px 0 0 12px;
    cursor: pointer;
    z-index: 99;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.cart-tab:hover {
    padding-right: 12px;
}

.cart-tab-arrow {
    color: white;
    font-size: 14px;
}

.cart-tab-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.cart-tab-badge {
    background: white;
    color: var(--accent-green);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.cart-tab-badge:empty,
.cart-tab-badge:contains('0') {
    display: none;
}

/* Cart Tab Wiggle Animation */
@keyframes cartWiggle {

    0%,
    100% {
        transform: translateY(-50%) rotate(0deg);
    }

    20% {
        transform: translateY(-50%) rotate(-8deg);
    }

    40% {
        transform: translateY(-50%) rotate(8deg);
    }

    60% {
        transform: translateY(-50%) rotate(-5deg);
    }

    80% {
        transform: translateY(-50%) rotate(5deg);
    }
}

.cart-tab.wiggle {
    animation: cartWiggle 0.5s ease-in-out;
}

/* =====================================================
   Cart Panel (Right Slide-In)
   ===================================================== */
.cart-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 350px;
    max-width: 90vw;
    background: var(--bg-secondary);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 150;
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.4);
}

.cart-panel.show {
    transform: translateX(0);
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--accent-green), #00a86b);
}

.cart-header h3 {
    color: white;
    font-size: 18px;
    margin: 0;
}

.cart-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-close:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.9);
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    -webkit-overflow-scrolling: touch;
}

.cart-items:empty::after {
    content: 'Warenkorb ist leer';
    display: block;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.cart-item-image {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
}

.cart-item-emoji {
    font-size: 36px;
    width: 48px;
    text-align: center;
}

.cart-item-info {
    flex: 1;
    min-width: 0;
}

.cart-item-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cart-item-location {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.cart-qty-btn.minus {
    background: var(--accent-red);
    color: white;
}

.cart-qty-btn.plus {
    background: var(--accent-green);
    color: white;
}

.cart-qty-btn:active {
    transform: scale(0.85);
}

.cart-item-qty {
    font-size: 18px;
    font-weight: 700;
    min-width: 24px;
    text-align: center;
    color: var(--text-primary);
}

.cart-footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--bg-tertiary);
    padding: 16px 20px;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 16px;
    color: var(--text-secondary);
}

.cart-total span:last-child {
    font-weight: 600;
    color: var(--text-primary);
}

.cart-actions {
    display: flex;
    gap: 10px;
}

.cart-clear-btn {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-clear-btn:active {
    background: var(--accent-red);
    color: white;
}

.cart-checkout-btn {
    flex: 1;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--accent-green), #00a86b);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-checkout-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* =====================================================
   Admin Screen
   ===================================================== */
#admin {
    flex-direction: column;
    background: var(--bg-primary);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--accent-purple), #8b5cf6);
}

.admin-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: white;
}

.admin-tabs {
    display: flex;
    gap: 4px;
    padding: 12px;
    background: var(--bg-secondary);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.admin-tab {
    flex-shrink: 0;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.admin-tab.active {
    background: var(--accent-purple);
    color: white;
}

.admin-tab:active:not(.active) {
    background: var(--bg-tertiary);
}

.admin-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
}

.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

.admin-panel h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Inventory Subtabs */
.inventory-subtabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.subtab {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.subtab.active {
    background: var(--accent-blue);
    color: white;
}

.subpanel {
    display: none;
}

.subpanel.active {
    display: block;
}

.subpanel h3 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

/* Transaction Log Timeline */
.log-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    position: relative;
}

.log-entry::before {
    content: '';
    position: absolute;
    left: 34px;
    top: 52px;
    width: 2px;
    height: calc(100% + 12px);
    background: var(--bg-tertiary);
}

.log-entry:last-child::before {
    display: none;
}

.log-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
    flex-shrink: 0;
}

.log-time .time {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.log-time .date {
    font-size: 11px;
    color: var(--text-tertiary);
}

.log-content {
    flex: 1;
    min-width: 0;
}

.log-user {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.log-action {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.log-product {
    display: flex;
    align-items: center;
    gap: 8px;
}

.log-product img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
}

.log-product .emoji {
    font-size: 20px;
}

.log-quantity {
    font-weight: 600;
    color: var(--accent-red);
}

.log-location {
    font-size: 12px;
    color: var(--text-tertiary);
}

.undo-btn {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.undo-btn:hover,
.undo-btn:active {
    background: var(--accent-red);
    color: white;
}

.load-more-btn {
    width: 100%;
    padding: 14px;
    margin-top: 16px;
    background: var(--bg-secondary);
    border: 2px dashed var(--bg-tertiary);
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-more-btn:active {
    background: var(--bg-tertiary);
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.admin-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.admin-card:active {
    border-color: var(--accent-purple);
    transform: scale(0.98);
}

.admin-card .emoji {
    font-size: 40px;
    margin-bottom: 12px;
}

.admin-card-img {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    margin-bottom: 12px;
}

.admin-card .name {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.admin-card .stock {
    font-size: 13px;
    color: var(--text-secondary);
}

.admin-action-btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--accent-purple);
    color: white;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.2s ease;
}

.admin-action-btn:active {
    transform: scale(0.95);
}

/* Admin List */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.admin-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
}

.admin-list-item .info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-list-item .emoji {
    font-size: 28px;
}

.admin-list-img {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
}

.admin-list-item .details h3 {
    font-size: 16px;
    font-weight: 500;
}

.admin-list-item .details p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.admin-list-item .actions {
    display: flex;
    gap: 8px;
}

.admin-list-item .action-btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-list-item .action-btn:active {
    transform: scale(0.95);
}

.admin-list-item .action-btn.danger {
    background: var(--accent-red);
    color: white;
}

/* Analytics */
.analytics-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 24px;
}

.month-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.month-btn:active {
    background: var(--accent-purple);
    transform: scale(0.9);
}

.month-display {
    font-size: 20px;
    font-weight: 600;
    min-width: 160px;
    text-align: center;
}

.analytics-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.analytics-user {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 20px;
}

.analytics-user h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analytics-user h3 .total {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.analytics-products {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.analytics-product {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.analytics-product .name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.analytics-product .quantity {
    font-weight: 600;
    color: var(--accent-blue);
}

.analytics-total {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid var(--accent-purple);
}

.analytics-total h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--accent-purple);
}

/* =====================================================
   Toast
   ===================================================== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--accent-green);
    border-radius: var(--border-radius);
    color: white;
    font-weight: 600;
    box-shadow: var(--shadow-soft);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    background: var(--accent-red);
}

.toast-icon {
    font-size: 20px;
}

/* =====================================================
   Loading Overlay
   ===================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =====================================================
   Responsive
   ===================================================== */
@media (min-width: 768px) {
    .keypad {
        max-width: 380px;
    }

    .key {
        height: 90px;
        font-size: 36px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .product-card {
        padding: 32px;
    }

    .product-emoji {
        font-size: 72px;
    }

    .admin-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

/* Landscape mode adjustments */
@media (orientation: landscape) and (max-height: 600px) {
    .lockscreen-container {
        padding: 20px;
    }

    .time {
        font-size: 48px;
        margin-bottom: 4px;
    }

    .date {
        font-size: 14px;
        margin-bottom: 16px;
    }

    .pin-display {
        margin-bottom: 16px;
        min-height: 50px;
    }

    .keypad {
        gap: 8px;
    }

    .key {
        height: 56px;
        font-size: 24px;
    }

    .toast {
        bottom: 20px;
    }
}