/* base.css - Core styles for SayServe order entry UI */

/* Basic styles for a mobile-first, vertical layout */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f4f4f4;
}

body {
    display: flex;
    flex-direction: column;
    /* Use vh for viewport height, but dvh is better for mobile browsers */
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height, accounts for mobile browser UI */
}

/* Container for the app */
#app-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Takes up all available space */
    min-height: 0; /* Allow shrinking */
    padding: 0.75rem 0.75rem 0.25rem 0.75rem; /* Reduced padding on all sides */
    box-sizing: border-box; /* Includes padding in height/width */
    overflow: hidden; /* Prevent container from growing */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    gap: 0.2rem;
}

/* Row 1: Dialog/text area with hamburger menu (13% height) */
#dialog-area {
    flex: 0 0 13%;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 0;
    overflow: visible;
    padding: 0;
    width: 100%;
    position: relative;
}

/* Row 2: Order area (72% height) */
#order-area-row {
    flex: 0 0 72%;
    display: flex;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

/* Row 3: Record button + Confirm button (13% height) */
#button-row-bottom {
    flex: 0 0 13%;
    display: flex;
    gap: 0.4rem;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

/* Constrain to tablet width on larger screens */
@media (min-width: 801px) {
    body {
        align-items: center; /* Center horizontally */
        background-color: #e0e0e0; /* Subtle background for desktop */
    }

    #app-container {
        max-width: 800px;
        width: 100%;
        box-shadow: 0 0 20px rgba(0,0,0,0.1); /* Subtle shadow for depth */
    }
}

/* Dialog message bubble */
.dialog-message {
    background-color: rgba(230, 230, 230, 0.70); /* Same as buttons but darker - TRANSLUCENCY: Change 0.85 to adjust opacity (0.0-1.0) */
    border-radius: 0.5rem;
    padding: 0.35rem 3.5rem 0.35rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.3;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    overflow-y: auto;
}

.dialog-message.fade-out {
    opacity: 0;
}

/* Style for user's spoken text */
.user-transcription {
    color: #663399; /* Deep purple */
    font-weight: 500;
}

/* Order area - positioned in row 3 */
#order-area {
    flex: 1; /* Take full width of row */
    min-height: 0; /* Allow flex item to shrink below content size */
    max-height: 100%; /* Don't exceed parent height */
    display: flex;
    flex-direction: column;
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #000;  /* Match record/confirm button border style */
    border-radius: 0.75rem;  /* Match record/confirm button border radius */
    padding: 0.5rem;
    overflow: hidden; /* Hide overflow on container */
    position: relative;
}


#order-area h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 0.8125rem;
    color: #333;
    font-weight: bold;
}

/* Order table wrapper - scrollable */
.order-table-wrapper {
    flex: 1; /* Takes remaining space */
    min-height: 0; /* Allow shrinking */
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scrolling */
    margin-bottom: 0.5rem;
}

/* Order table */
#order-table {
    width: 100%;
    table-layout: fixed; /* Fixed layout prevents overflow */
    border-collapse: collapse;
}

/* Column widths - applied to td since there's no thead */
#order-table tbody td:nth-child(1) { /* Item name */
    width: auto; /* Takes remaining space */
}

#order-table tbody td:nth-child(2) { /* Info icon */
    width: 1.5rem;
}

#order-table tbody td:nth-child(3) { /* Qty */
    width: 4.5rem;
}

#order-table tbody td:nth-child(4) { /* Price */
    width: 3.5rem;
}

#order-table tbody td:nth-child(5) { /* Delete button */
    width: 2rem;
}

#order-table tbody tr {
    border-bottom: 1px solid #eee;
}

#order-table tbody tr:hover {
    background-color: #f5f5f5;
}

#order-table tbody td {
    padding: 0.25rem 0.15rem;
    font-size: 0.8125rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
}

#order-table tbody td:first-child {
    /* Allow item names to wrap */
    white-space: normal;
    word-wrap: break-word;
    padding-right: 0.3rem; /* Extra padding to separate from other columns */
}

#order-table tbody td:nth-child(2) { /* Info icon */
    text-align: center;
    padding: 0.25rem 0.1rem;
}

#order-table tbody td:nth-child(3) { /* Qty */
    text-align: center;
    font-weight: bold;
    padding: 0.25rem 0.1rem;
}

#order-table tbody td:nth-child(4) { /* Price */
    text-align: right;
    padding: 0.25rem 0.1rem;
}

#order-table tbody td:nth-child(5) { /* Delete button */
    text-align: center;
    padding: 0.25rem 0.1rem;
}

/* Delete button in table */
.delete-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 0.25rem;
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
    min-height: 2rem;
    min-width: 2rem;
}

.delete-btn:hover {
    background-color: #c82333;
}

/* Quantity plus/minus buttons */
.qty-btn {
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 0.35rem;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: bold;
    min-height: 2.1rem;
    min-width: 2.1rem;
    font-size: 1.05rem;
}

.qty-btn:hover {
    background-color: #0056b3;
}

.qty-btn:active {
    background-color: #004085;
}

/* Order total */
#order-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8125rem;
    font-weight: bold;
    padding: 0.5rem 0.25rem;
    border-top: 2px solid #000;
    margin-top: auto; /* Push to bottom */
}

/* Recording button in bottom row - 50% width, horizontal layout (icon | text left-aligned) */
#record-button {
    flex: 1; /* Take 50% of space (equal with confirm button) */
    height: 100%;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: row; /* Horizontal: icon left, text right */
    align-items: center;
    justify-content: flex-start; /* Left-align content */
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
    padding: 0.5rem 0 0.5rem 0.5rem; /* Right padding set to 0 */
    box-sizing: border-box;
    overflow: hidden;
    text-align: left;
    border: 2px solid #000;
    background: rgba(255, 255, 255, 0.70); /* TRANSLUCENCY: Change 0.85 to adjust opacity (0.0-1.0) */
    color: #000;
    min-width: 0;
    position: relative; /* For absolute positioned stop label */
}

#record-button:hover {
    background: rgba(245, 245, 245, 0.70); /* TRANSLUCENCY: Change 0.85 to adjust opacity */
}

#record-button img {
    height: 2.5rem; /* Increased from 2rem */
    width: 2.5rem; /* Increased from 2rem */
    flex-shrink: 0;
    object-fit: contain;
}

#record-button span {
    flex: 1;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
}

/* Hamburger button inside dialog area - positioned on right */
#hamburger-container {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Confirm button in bottom row - 50% width, horizontal layout (icon | text left-aligned) */
#submit-button {
    flex: 1; /* Take 50% of space (equal with record button) */
    height: 100%;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: row-reverse; /* Reverse to put icon before text */
    align-items: center;
    justify-content: flex-end; /* Align to left (reversed) */
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
    padding: 0.5rem 0 0.5rem 0.5rem; /* Right padding set to 0 */
    box-sizing: border-box;
    overflow: hidden;
    text-align: left;
    border: 2px solid #000;
    background: rgba(255, 255, 255, 0.70); /* TRANSLUCENCY: Change 0.70 to adjust opacity (0.0-1.0) */
    color: #000;
    min-width: 0;
}

#submit-button:hover:not(:disabled) {
    background: rgba(245, 245, 245, 0.70); /* TRANSLUCENCY: Change 0.85 to adjust opacity */
}

#submit-button:disabled {
    border-color: #999;
    color: #999;
    cursor: not-allowed;
    background: rgba(200, 200, 200, 0.7);
}

#submit-button img {
    height: 2.5rem; /* Increased from 2rem */
    width: 2.5rem; /* Increased from 2rem */
    flex-shrink: 0;
    object-fit: contain;
}

#submit-button:disabled img {
    opacity: 0.3;
}

#submit-button span {
    flex: 1;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
}

/* Hide Ask and Call Waiter buttons */
#ask-button,
#call-waiter-button {
    display: none;
}

/* Loading spinner */
.spinner {
    border: 0.25rem solid #f3f3f3;
    border-top: 0.25rem solid #007bff;
    border-radius: 50%;
    width: 3.125rem;
    height: 3.125rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 1000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
}
