/* වර්ණ සහ මූලික සැකසුම් */
:root {
    --primary-color: #ff7e5f;
    /* Pastry shop එකකට ගැලපෙන වර්ණයක් */
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-dark: #2c3e50;
    --border-color: #e0e0e0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* ටැබ්ලට් එකේ ඉක්මනින් ඔබද්දී අකුරු Select වෙන එක නවත්වන්න */
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    overflow: hidden;
    height: 100%;
    /* මේ පේළිය අලුතින් එකතු කරන්න */
}

.pos-container {
    display: flex;
    height: 100dvh;
    /* මෙතන තිබුණු 100vh වෙනුවට 100dvh (Dynamic Viewport Height) කියලා වෙනස් කරන්න */
    width: 100vw;
}

/* --- වම් පැත්ත (කෑම ජාති) 65% ක ඉඩක් ගනී --- */
.products-section {
    flex: 0 0 65%;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

.categories {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.cat-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-dark);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
}

.cat-btn.active,
.cat-btn:active {
    background: var(--primary-color);
    color: white;
}

.products-grid {
    display: grid;
    /* එක පේළියකට කාඩ් කීයක් එනවද කියලා තිරයේ සයිස් එක අනුව හැදෙනවා */
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
    overflow-y: auto;
    padding-right: 5px;
}

.product-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: transform 0.1s;
}

.product-card:active {
    transform: scale(0.95);
    /* එබුවම පොඩි වෙන Effect එක */
}

.product-card img {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 10px;
    background-color: #eee;
}

.product-card h3 {
    font-size: 14px;
    margin-bottom: 5px;
}

.product-card p {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 15px;
}

/* --- දකුණු පැත්ත (බිල් එක) 35% ක ඉඩක් ගනී --- */
.cart-section {
    flex: 0 0 35%;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.08);
    z-index: 10;
}

.cart-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.order-type-toggle {
    margin-top: 15px;
    display: flex;
    gap: 20px;
}

.order-type-toggle label {
    font-size: 16px;
    font-weight: bold;
}

.order-type-toggle input {
    transform: scale(1.3);
    margin-right: 5px;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.empty-cart {
    text-align: center;
    color: #999;
    margin-top: 50px;
}

/* බිල් එකට එකතු වෙන Item එකක පෙනුම */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px dashed var(--border-color);
}

.cart-item h4 {
    font-size: 15px;
    margin-bottom: 5px;
}

.qty-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #eee;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
}

.cart-item-price {
    font-weight: bold;
    font-size: 16px;
}

.cart-footer {
    padding: 20px;
    background: #fafafa;
    border-top: 1px solid var(--border-color);
}

.totals {
    margin-bottom: 15px;
}

.totals h3 {
    display: flex;
    justify-content: space-between;
    font-size: 22px;
    color: var(--text-dark);
}

.print-btn {
    width: 100%;
    padding: 18px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    font-weight: bold;
}

.print-btn:active {
    background: #219653;
}

/* --- අලුතින් එකතු කළ Top Bar එකේ පෙනුම --- */
.pos-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.cashier-info {
    font-size: 16px;
    color: var(--text-dark);
}

.cashier-info strong {
    color: var(--primary-color);
}

.top-actions {
    display: flex;
    gap: 10px;
}

.btn-top {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.btn-refresh {
    background: #3498db;
    color: white;
}

.btn-refresh:hover {
    background: #2980b9;
}

.btn-logout {
    background: #e74c3c;
    color: white;
}

.btn-logout:hover {
    background: #c0392b;
}

/* Clear Cart බොත්තමේ පෙනුම */
.btn-clear-cart {
    background: #ffeded;
    color: #e74c3c;
    border: 1px solid #ffcccc;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: 0.2s;
}

.btn-clear-cart:hover {
    background: #e74c3c;
    color: white;
}

/* Search Input එක Focus වෙද්දී පෙනුම */
#search-product:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 5px rgba(255, 126, 95, 0.3);
}

/*////////////////////////////////PRINT/////////////////////////////////////*/

/* --- Print Receipt Styles (බිල්පත සඳහා පමණක්) --- */
@media print {
    @page {
        size: 80mm auto;
        margin: 0;
    }

    body {
        overflow: visible !important;
    }

    body * {
        visibility: hidden;
    }

    #print-section,
    #print-section * {
        visibility: visible;
    }

    #print-section {
        display: block !important;
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        width: 80mm;
        padding: 0mm;
        margin: 0 auto;
        box-sizing: border-box;
        font-family: 'Courier New', Courier, monospace;
        color: #000;
    }

    .receipt-header {
        text-align: center;
        border-bottom: 2px dashed #000;
        padding-bottom: 5px;
        margin-bottom: 5px;
    }

    .receipt-logo {
        width: 160px;
        height: auto;
        margin: -10px auto 5px auto;
        display: block;
    }

    .receipt-header h2 {
        margin: 0;
        font-size: 27px;
        font-weight: bold;
    }

    .receipt-header p {
        margin: 2px 0;
        font-size: 16px;
        font-weight: bold;
    }

    .receipt-info {
        font-size: 16px;
        margin-bottom: 5px;
        border-bottom: 2px dashed #000;
        padding-bottom: 3px;
    }

    .receipt-info p {
        margin: 2px 0;
    }

    .receipt-items {
        width: 100%;
        border-collapse: collapse;
        font-size: 16px;
        margin-bottom: 5px;
    }

    .receipt-items th {
        font-size: 17px;
        font-weight: bold;
        border-bottom: 2px solid #000;
        padding-bottom: 3px;
    }

    /* --- මෙතනින් තමයි කෑම ජාති අතර Gap එක අඩු වෙන්නේ --- */
    .receipt-items th,
    .receipt-items td {
        text-align: left;
        padding: 4px 0;
        /* 8px තිබුණු පරතරය 4px දක්වා අඩු කළා! */
        border-bottom: 1px dotted #ccc;
    }

    .receipt-items th:last-child,
    .receipt-items td:last-child {
        text-align: right;
    }

    .receipt-total {
        text-align: right;
        border-top: 2px dashed #000;
        border-bottom: 2px dashed #000;
        padding: 5px 0;
        /* 10px ඉඳන් 5px ට අඩු කළා */
        margin-bottom: 5px;
    }

    .receipt-total h3 {
        margin: 0;
        font-size: 22px;
        font-weight: bold;
    }

    .receipt-footer {
        text-align: center;
        font-size: 14px;
        font-weight: bold;
        margin-top: 5px;
    }

    .receipt-items th:nth-child(2),
    .receipt-items td:nth-child(2) {
        text-align: center;
        /* Qty (ප්‍රමාණය) තීරුව මැදට ගන්නවා */
    }

    .receipt-items th:last-child,
    .receipt-items td:last-child {
        text-align: right;
        /* Price (මිල) තීරුව දකුණු පැත්තටම ගන්නවා */
    }

}

/*//////////Pin Pad////////////*/

/* --- Cashier PIN Login Screen --- */

.pin-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #2c3e50;
    /* තද නිල් පාට පසුබිමක් */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    /* අනිත් හැමදේටම වඩා උඩින් පේන්න */
}

.pin-container {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 320px;
}

.pin-container h2 {
    color: #2c3e50;
    margin-bottom: 5px;
}

.pin-container p {
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 20px;
}

.pin-display input {
    width: 100%;
    text-align: center;
    font-size: 30px;
    letter-spacing: 10px;
    padding: 15px;
    border: 2px solid #bdc3c7;
    border-radius: 10px;
    margin-bottom: 20px;
    outline: none;
    background: #f9f9f9;
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.pin-pad button {
    padding: 20px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    background: #ecf0f1;
    color: #2c3e50;
    cursor: pointer;
    transition: 0.2s;
}

.pin-pad button:hover {
    background: #bdc3c7;
}

.pin-pad .btn-clear {
    background: #e74c3c;
    color: white;
}

.pin-pad .btn-clear:hover {
    background: #c0392b;
}

.pin-pad .btn-enter {
    background: #27ae60;
    color: white;
}

.pin-pad .btn-enter:hover {
    background: #219653;
}

.pin-error-msg {
    color: #e74c3c !important;
    margin-top: 15px;
    font-weight: bold;
    display: none;
}