:root {
    --primary-color: #5e72e4;
    --primary-light: #7e8ee9;
    --primary-dark: #4a5bd1;
    --secondary-color: #f7fafc;
    --success-color: #2dce89;
    --warning-color: #fb6340;
    --danger-color: #f5365c;
    --light-color: #f8f9fa;
    --dark-color: #32325d;
    --text-color: #525f7f;
    --text-muted: #8898aa;
    --bg-color: #f8f9fe;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
    --nav-height: 60px;
    --header-height: 56px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --ios-blue: #007aff;
    --android-green: #25D366;
}

[data-theme="dark"] {
    --primary-color: #5e72e4;
    --primary-light: #7e8ee9;
    --primary-dark: #4a5bd1;
    --secondary-color: #1a2035;
    --text-color: #f8f9fe;
    --text-muted: #adb5bd;
    --bg-color: #172b4d;
    --card-bg: #1e2a4a;
    --card-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
    line-height: 1.5;
    transition: var(--transition);
    overscroll-behavior-y: contain;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 0 16px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.theme-toggle {
    position: absolute;
    right: 16px;
    cursor: pointer;
    background: none;
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle:active {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
}

.theme-toggle i {
    font-size: 18px;
}

.app-main {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    margin-bottom: var(--nav-height);
    -webkit-overflow-scrolling: touch;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background-color: var(--card-bg);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    height: var(--nav-height);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.nav-btn {
    flex: 1;
    padding: 8px 0;
    border: none;
    background: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.nav-btn i {
    font-size: 20px;
    margin-bottom: 4px;
    transition: var(--transition);
}

.nav-btn.active {
    color: var(--primary-color);
    font-weight: 600;
}

.nav-btn.active i {
    transform: translateY(-5px);
}

.nav-btn:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background-color: var(--primary-color);
    transition: var(--transition);
}

.nav-btn.active:after {
    width: 60%;
}

/* Card Styles */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 20px;
    margin-bottom: 16px;
    transition: var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--primary-color);
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Dashboard Styles */
.stats-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    text-align: center;
    padding: 16px;
    background-color: var(--secondary-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.stat-card .label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(94, 114, 228, 0.2);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-light);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #ec0c38;
}

.btn-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    margin: 0 2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-action:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
}

.btn-action.delete-transaction:hover {
    color: var(--danger-color);
}

.btn-action i {
    pointer-events: none;
}

/* Enhanced Responsive Table */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
  
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
  
.table th,
.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    text-align: left;
    white-space: nowrap;
}
  
.table thead th {
    background-color: var(--secondary-color);
    color: var(--text-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}
  
.table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}
  
.table-actions {
    white-space: nowrap;
    width: 1%;
    text-align: right;
}

/* Status badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    text-transform: capitalize;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-process {
    background-color: var(--warning-color);
    color: white;
}

.status-completed {
    background-color: var(--success-color);
    color: white;
}

.status-taken {
    background-color: var(--primary-color);
    color: white;
}

.total-price-display {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    padding: 16px 0;
    text-align: right;
    border-top: 1px solid rgba(0,0,0,0.1);
    margin-top: 16px;
}

/* Modal Styles */
.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.modal-container.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.modal-container.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:active {
    background-color: rgba(0, 0, 0, 0.05);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.modal-actions-vertical {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions-vertical .btn i {
    margin-right: 8px;
}

/* Styles for receipt generation */
#receipt-to-capture {
    position: absolute;
    left: -9999px; /* Move it off-screen */
    top: 0;
    width: 320px; /* Fixed width for consistent output */
    background-color: #ffffff;
    color: #000000;
    font-family: 'Courier New', Courier, monospace;
}

#receipt-to-capture .receipt {
    padding: 15px;
    box-sizing: border-box;
    background-color: #ffffff; /* Ensure background is not transparent */
}
#receipt-to-capture .header { text-align: center; margin-bottom: 15px; }
#receipt-to-capture .title { font-size: 1.2em; font-weight: bold; }
#receipt-to-capture .address { font-size: 0.8em; margin-bottom: 10px; }
#receipt-to-capture .divider { border-top: 1px dashed #000; margin: 10px 0; }
#receipt-to-capture .item { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 0.9em; }
#receipt-to-capture .item span:first-child { flex-grow: 1; }
#receipt-to-capture .item span.price-col { text-align: right; min-width: 80px; }
#receipt-to-capture .receipt-items-table { width: 100%; font-size: 0.9em; border-collapse: collapse; }
#receipt-to-capture .receipt-items-table th, #receipt-to-capture .receipt-items-table td { padding: 2px 0; }
#receipt-to-capture .receipt-items-table .col-item { text-align: left; }
#receipt-to-capture .receipt-items-table .col-qty { text-align: center; }
#receipt-to-capture .receipt-items-table .col-price { text-align: right; }
#receipt-to-capture .notes-section { margin-top: 10px; }
#receipt-to-capture .notes-section .item-note { font-size: 0.85em; text-align: left; margin-top: -5px; padding-left: 5px; white-space: pre-wrap; word-wrap: break-word; }
#receipt-to-capture .total { font-weight: bold; margin-top: 10px; }
#receipt-to-capture .footer { text-align: center; margin-top: 15px; font-size: 0.8em; }


/* New Order Form Specific Styles */
#order-items-container {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-top: 16px;
    background-color: var(--bg-color);
    min-height: 80px;
}

.order-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    background-color: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.order-item-details {
    flex-grow: 1;
}

.order-item-details .name {
    font-weight: 600;
    font-size: 14px;
}

.order-item-details .info {
    font-size: 12px;
    color: var(--text-muted);
}

.order-item-subtotal {
    font-weight: 600;
    font-size: 14px;
    margin-right: 8px;
}

.order-item-remove-btn {
    background-color: var(--danger-color);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
}

#customer-balance-info {
    background-color: var(--success-color);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 500;
    display: none; /* Hidden by default */
}

.payment-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.payment-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.payment-row strong {
    font-size: 16px;
}

/* Responsive Styles */
@media (min-width: 768px) {
    .app-container {
        max-width: 1024px;
        margin: 0 auto;
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
        display: grid;
        grid-template-columns: 240px 1fr;
        grid-template-rows: var(--header-height) 1fr;
        grid-template-areas: 
            "header header"
            "nav main";
        height: 100vh;
    }
    
    .app-header { grid-area: header; }
    .app-main { grid-area: main; margin-bottom: 0; }
    .bottom-nav {
        grid-area: nav;
        position: static;
        flex-direction: column;
        justify-content: flex-start;
        height: auto;
        box-shadow: none;
        border-top: none;
        border-right: 1px solid rgba(0,0,0,0.05);
        padding-top: 20px;
    }
    .nav-btn {
        flex-direction: row;
        justify-content: flex-start;
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 0 50px 50px 0;
        margin-bottom: 8px;
    }
    .nav-btn i { margin-right: 16px; margin-bottom: 0; }
    .nav-btn.active { background-color: var(--primary-light); color: white; }
    .nav-btn.active i { transform: none; }
    .nav-btn:after { display: none; }

    .stats-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Utility Classes */
.text-center { text-align: center; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.slide-up {
    animation: slideInFromBottom 0.5s ease-out forwards;
}

@keyframes slideInFromBottom {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--dark-color);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-size: 14px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 768px) {
    .toast {
        bottom: 30px;
    }
}
