:root {
    --app-height: 100dvh;
}

* {
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

input, textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: #EEEEEE;
    overflow: hidden;
}

body {
    margin: 0 auto;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    width: 100%;
    max-width: 75vh; 
    height: 100%; 
    height: 100dvh; 
    height: var(--app-height);
    background-color: #f4f4f4;
    color: #333;
    overflow: hidden;
    overscroll-behavior: none;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.hidden {
    display: none !important;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* --- App Title Bar --- */
#app-title-bar {
    background-color: #000;
    color: #888;
    text-align: center;
    padding: 14px 10px;
    font-size: 16px;
    font-weight: bold;
    flex-shrink: 0;
    letter-spacing: 1px;
}

/* --- Top Bar --- */
.top-bar {
    display: flex;
    background-color: #333;
    color: white;
    flex-shrink: 0;
    padding: 4px;
    gap: 4px;
    justify-content: space-between;
}

.top-bar button {
    flex: 1 1 0;
    padding: 16px 2px;
    text-align: center;
    cursor: pointer;
    border: 1px solid #555;
    background-color: #444;
    color: white;
    font-size: 14px;
    font-weight: bold;
    border-radius: 4px;
    transition: background-color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top-bar button.icon-btn {
    font-size: 20px;
}

.top-bar button.nav-arrow {
    font-size: 28px;
    font-weight: 900;
    padding: 9px 2px; /* Adjusted padding to compensate for larger font height */
    line-height: 1;
}

.top-bar button:active {
    background-color: #666;
}

.top-bar .tab-btn.active {
    background-color: #007bff;
    border-color: #007bff;
}

.top-bar .action-btn {
    background-color: #28a745;
}

/* --- Order Info Bar --- */
#order-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    background-color: #e0e0e0;
    padding: 8px 10px;
    font-size: 14px;
    border-bottom: 1px solid #ccc;
    flex-shrink: 0;
}

#order-info-left, #order-info-center, #order-info-right {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#order-info-left {
    width: 50%;
    text-align: left;
    font-weight: bold;
    z-index: 1;
}

#order-info-center {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    text-align: center;
    font-weight: 900;
    color: #007bff;
    z-index: 0;
    pointer-events: none;
}

#order-info-right {
    width: 50%;
    text-align: right;
    font-weight: bold;
    z-index: 1;
}

/* --- Tabs --- */
.tab-content {
    flex-grow: 1;
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* --- Settings View --- */
.settings-header {
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

#settings-scroll-area {
    flex-grow: 1;
    overflow-y: auto;
}

.settings-section {
    padding: 15px;
    background-color: white;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.settings-section h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: #555;
}

.currency-group {
    display: flex;
    gap: 10px;
}

.currency-btn {
    flex: 1;
    padding: 12px;
    font-size: 18px;
    font-weight: bold;
    border: 1px solid #ccc;
    background-color: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
}

.currency-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.setting-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.setting-stepper .tile-btn {
    min-width: 44px;
    height: 44px;
    font-size: 20px;
    padding: 0 4px;
}

.setting-stepper .tile-count {
    font-size: 22px;
    min-width: 30px;
    text-align: center;
}

.settings-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
}

.settings-btn.primary { background-color: #007bff; }
.settings-btn.primary:active { background-color: #0069d9; }
.settings-btn.secondary { background-color: #6c757d; }
.settings-btn.secondary:active { background-color: #5a6268; }

.danger-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.danger-btn:active {
    background-color: #c82333;
}

/* --- Order View --- */
#order-scroll-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    position: relative;
}

#order-remark-display {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: bold;
    white-space: pre-wrap;
    border: 1px solid #ffeeba;
}

.group-header {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background-color: #6c757d;
    padding: 6px 10px;
    border-radius: 4px;
    margin: 10px 0 5px 0;
    position: sticky;
    top: 0;
    z-index: 2;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    margin-bottom: 15px;
}

.tile {
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.tile.active-item {
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.3);
}

.tile-title-wrapper {
    position: relative;
    margin-bottom: 8px;
    height: 34px;
    width: 100%;
}

.tile-title {
    font-size: 14px;
    font-weight: bold;
    text-align: left;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    width: 100%;
    height: 100%;
}

.tile-price {
    position: absolute;
    bottom: 0;
    right: 0;
    background-color: white;
    padding-left: 6px;
    font-size: 12px;
    font-weight: bold;
    color: #b30000;
    box-shadow: -4px 0 4px white;
    border-radius: 2px;
}

.tile-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 2px;
}

.tile-btn {
    min-width: 32px;
    height: 32px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    background-color: #e9ecef;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-btn:active {
    background-color: #ced4da;
}

.tile-btn.plus {
    background-color: #d4edda;
    color: #155724;
}

.tile-btn.plus:active {
    background-color: #c3e6cb;
}

.tile-btn.minus {
    background-color: #f8d7da;
    color: #721c24;
}

.tile-btn.minus:active {
    background-color: #f5c6cb;
}

.tile-count {
    font-size: 18px;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

.zero-count {
    color: #bbb;
}

#add-bar {
    padding: 10px;
    background-color: #fff;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    align-items: stretch;
}

#add-bar button {
    flex: 1;
    padding: 18px 4px;
    font-size: 15px;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.split-btn-wrapper {
    flex: 1;
    display: flex;
    gap: 5px;
}

#btn-add-product { background-color: #007bff; }
#btn-show-order { background-color: #17a2b8; }
#btn-extra, #btn-table { background-color: #6c757d; }

.clock-display {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: #555;
    white-space: nowrap;
    padding: 0 5px;
}

/* --- History View --- */
.history-header {
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
}

#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex-grow: 1;
}

#history-list li {
    padding: 15px;
    border-bottom: 1px solid #eee;
    background-color: white;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    gap: 8px;
}

#history-list li:active {
    background-color: #f8f9fa;
}

#history-list li.current-view {
    border-left: 4px solid #007bff;
    background-color: #e9f2ff;
    padding-left: 11px;
}

.hist-main {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

.history-status-btn {
    padding: 2px 6px;
    margin-left: 6px;
    font-size: 12px;
    font-weight: bold;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #e9ecef;
    color: #333;
    cursor: pointer;
    text-transform: capitalize;
    vertical-align: middle;
}
.history-status-btn:active {
    background-color: #ced4da;
}

.hist-stats {
    white-space: nowrap;
    font-weight: bold;
    flex-shrink: 0;
    color: #555;
}

/* --- Modals --- */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content.fullscreen-dialog {
    background-color: #f3f4f6;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.modal-dialog {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    text-align: center;
}

.dialog-header {
    padding: 15px;
    background-color: #fff;
    flex-grow: 1;
    overflow-y: auto;
}

.dialog-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.dialog-header-top h3 {
    margin: 0;
}

.add-order-stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-order-stepper label {
    font-weight: bold;
    color: #555;
    font-size: 14px;
    margin: 0;
}

.stepper-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 2px;
}

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

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

.input-group input, 
.input-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    caret-color: #007bff;
}

.input-group textarea {
    resize: none;
    height: 80px;
    flex-grow: 1;
}

/* Add Product Price Input Layout */
.price-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.price-input-wrapper input {
    flex: 0 0 120px;
}

#add-modal-currency-label {
    font-size: 18px;
    font-weight: bold;
    color: #555;
}

/* Status Buttons inside Extra modal */
.status-group {
    display: flex;
    gap: 8px;
}

.status-btn {
    flex: 1;
    padding: 12px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f8f9fa;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    text-align: center;
}

.status-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

/* Quick Table Selection Grid */
.table-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
    justify-content: center;
    padding: 5px;
}

.table-chip {
    min-width: 50px;
    height: 50px;
    padding: 0 10px;
    background-color: #f8f9fa;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.table-chip:active {
    background-color: #ced4da;
}

.table-chip.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

#existing-groups-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.group-chip {
    padding: 6px 10px;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
}

.group-chip:active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.dialog-actions {
    padding: 10px 15px;
    display: flex;
    gap: 10px;
    justify-content: space-around;
    background-color: #f3f4f6;
    flex-shrink: 0;
}

.dialog-actions button {
    flex: 1;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    color: white;
}

#btn-cancel-add, #btn-cancel-extra { background-color: #6c757d; }
#btn-confirm-add, #btn-confirm-extra { background-color: #28a745; }
#btn-delete-product { background-color: #dc3545; }

/* Custom Confirm/Alert Dialog Styles */
#custom-dialog-modal .modal-dialog {
    padding: 25px 20px;
}
#custom-dialog-modal h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #333;
}
#custom-dialog-modal p {
    color: #555;
    margin-bottom: 25px;
    font-size: 18px;
    line-height: 1.4;
}
.custom-dialog-actions {
    display: flex;
    gap: 10px;
    align-items: stretch;
}
.custom-dialog-actions button {
    flex: 1;
    margin: 0; 
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
}
.custom-dialog-actions .secondary-btn { background-color: #6c757d; }
.custom-dialog-actions .action-btn { background-color: #007bff; }
.custom-dialog-actions .danger-btn { background-color: #dc3545; }

#fullscreen-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

#fullscreen-buttons button {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
}

#fullscreen-buttons .secondary-btn {
    background-color: #6c757d;
}

/* --- Show Order Summary Styles --- */
.order-summary-list {
    max-height: 50vh;
    overflow-y: auto;
    text-align: left;
    padding-right: 5px;
}

.order-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 15px;
}

.order-summary-item-left {
    flex-grow: 1;
    display: flex;
    gap: 8px;
}

.order-summary-qty {
    font-weight: bold;
    min-width: 20px;
}

.order-summary-name {
    flex-grow: 1;
    word-break: break-word;
}

.order-summary-price-single {
    color: #888;
    font-size: 13px;
    align-self: center;
}

.order-summary-price-total {
    font-weight: bold;
    text-align: right;
    min-width: 50px;
}

.order-summary-total-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0 5px 0;
    font-size: 18px;
    font-weight: bold;
    border-top: 2px solid #ccc;
    margin-top: 5px;
}

/* --- Integrated Keyboard Styles --- */
.keyboard-container {
    width: 100%;
    background-color: #d1d5db;
    padding: 2px 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 2px;
    width: 100%;
    padding: 0 1px;
}

.keyboard-container .key-btn {
    flex: 1;
    height: 48px;
    background-color: #ffffff;
    border: 1px solid #888;
    border-radius: 4px;
    font-size: 20px;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0.2);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    padding: 0;
    min-width: 0;
}

.keyboard-container .key-btn:active, 
.keyboard-container .key-btn.active {
    background-color: #3b82f6;
    color: white;
    transform: translateY(1px);
}

.keyboard-container .key-function {
    background-color: #e5e7eb;
    font-size: 16px;
}

.keyboard-container button[data-action="shift"] { flex: 1.5; }
.keyboard-container button[data-action="symbol"] { flex: 2; }
.keyboard-container button[data-action="abc"] { flex: 2; }

.keyboard-container .key-space { flex: 4; }
.keyboard-container .key-space-short { flex: 2; }

.keyboard-container .key-zero { flex: 2; }

.keyboard-container .key-enter {
    background-color: #28a745;
    color: white;
    font-size: 20px;
    flex: 1.5;
}
.keyboard-container .key-enter:active {
    background-color: #218838 !important;
}

.keyboard-container .key-enter-num {
    background-color: #28a745;
    color: white;
    font-size: 20px;
    flex: 2.05;
}
.keyboard-container .key-enter-num:active {
    background-color: #218838 !important;
}

.keyboard-container .key-backspace {
    background-color: #eab308;
    color: black;
    font-size: 20px;
    flex: 2;
}
.keyboard-container .key-backspace:active {
    background-color: #ca8a04 !important;
}

.keyboard-container .key-clear {
    background-color: #dc3545;
    color: white;
    font-size: 20px;
    flex: 2;
}
.keyboard-container .key-clear:active {
    background-color: #c82333 !important;
}