@import url('https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;700&display=swap');

.sales-section {
    display: none; /* shown via Navigation.js */
    padding: 10px 20px 20px;
    font-family: 'Ubuntu', sans-serif;
    color: var(--Darkbrown);
}

/* Header */

.sales-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.sales-header h2 {
    font-size: 28px;
    color: var(--Darkbrown);
}

.sales-header h2 span {
    color: var(--Lightbrown);
}

.sales-subtitle {
    font-size: 13px;
    color: #6c757d;
    margin-top: 4px;
}

.sales-meta {
    text-align: right;
    font-size: 13px;
    color: #6c757d;
}

.sales-meta span span {
    font-weight: 600;
    color: var(--Darkbrown);
}

/* Layout */

.sales-layout {
    display: grid;
    grid-template-columns: 1.1fr 1.6fr 1.1fr;
    gap: 15px;
    margin-top: 10px;
}

/* Panels */

.sales-left,
.sales-center,
.sales-right {
    background: var(--brown2);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

.sales-panel-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--Darkbrown);
}

/* Search panel */

.sales-search-input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 20px;
    border: 1px solid var(--Lightbrown);
    font-size: 14px;
    margin-bottom: 8px;
}

.medicine-results {
    max-height: 260px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid var(--brown3);
    background: #fff;
    padding: 4px;
}

.medicine-item {
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.medicine-item:hover {
    background: var(--brown1);
}

.medicine-item-name {
    font-weight: 500;
}

.medicine-item-price {
    color: var(--Lightbrown);
}

/* Cart table */

.sales-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sales-table th,
.sales-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--brown3);
    text-align: left;
}

.sales-table thead th {
    background: var(--brown1);
    position: sticky;
    top: 0;
    z-index: 1;
}

.sales-qty-input {
    width: 60px;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid var(--Lightbrown);
    text-align: right;
}

.sales-remove-btn {
    border: none;
    background: none;
    color: #e03131;
    cursor: pointer;
    font-size: 14px;
}

/* Right panel: totals + payment */

.sales-totals p,
.sales-payment p,
.sales-payment label {
    font-size: 13px;
    margin: 4px 0;
}

.sales-totals input {
    width: 100px;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid var(--Lightbrown);
    margin-left: 4px;
    text-align: right;
}

.sales-payment select,
.sales-payment input {
    width: 100%;
    padding: 6px 8px;
    margin-bottom: 6px;
    border-radius: 6px;
    border: 1px solid var(--Lightbrown);
}

.confirm-sale-button {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    border-radius: 20px;
    border: 1px solid var(--Lightbrown);
    background: var(--Lightbrown);
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}

.confirm-sale-button:hover {
    background: var(--brown1);
    color: var(--Darkbrown);
}

.search-wrapper {
    position: relative;
    width: 100%;
}

#medicineSearch {
    width: 100%;
    padding-right: 35px; /* space for the clear button */
}

.clear-search-btn {
    position: absolute;
    right: 10px;
    top: 40%;
    transform: translateY(-50%);
    font-size: 20px;
    color: #999;
    cursor: pointer;
    display: none; /* hidden until typing */
}

.clear-search-btn:hover {
    color: #ff4c4c;
}


/* Mobile */

@media (max-width: 992px) {
    .sales-layout {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        grid-template-areas:
            "left right"
            "center center";
    }

    .sales-left {
        grid-area: left;
    }
    .sales-center {
        grid-area: center;
    }
    .sales-right {
        grid-area: right;
    }
}

@media (max-width: 768px) {
    .sales-layout {
        grid-template-columns: 1fr;
    }
}


/* =========================
   Mobile UX Fixes (WebView)
   ========================= */

/* Make the sales section use full width on small screens */
@media (max-width: 768px) {

  /* Reduce side padding inside Sales section */
  .sales-section {
    padding: 10px 12px 16px;
  }

  /* Stack header nicely */
  .sales-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .sales-meta {
    text-align: left;
  }

  /* Make panels take full width and reduce inner padding */
  .sales-left,
  .sales-center,
  .sales-right {
    padding: 12px 12px;
    border-radius: 12px;
  }

  .sales-panel-title {
    font-size: 15px;
    margin-bottom: 10px;
  }

  /* Bigger search box */
  .sales-search-input {
    font-size: 16px;            /* ✅ mobile-friendly */
    padding: 12px 14px;         /* ✅ bigger touch target */
    border-radius: 12px;        /* less extreme pill */
    margin-bottom: 10px;
  }

  /* Clear button alignment */
  .clear-search-btn {
    top: 50%;
    font-size: 22px;
    right: 12px;
  }

  /* Search results area: taller for phone */
  .medicine-results {
    max-height: 45vh;
    padding: 6px;
  }

  .medicine-item {
    padding: 10px 10px;
    font-size: 14px;
  }

  /* Cart table: allow horizontal scroll instead of squeezing */
  .sales-center {
    overflow: hidden;
  }

  .sales-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  .sales-table thead,
  .sales-table tbody,
  .sales-table tr {
    width: 100%;
  }

  /* Bigger qty input on mobile */
  .sales-qty-input {
    width: 70px;
    padding: 8px 8px;
    font-size: 15px;
  }

  /* Payment inputs: bigger */
  .sales-payment select,
  .sales-payment input,
  .sales-totals input {
    font-size: 16px;
    padding: 10px 10px;
  }

  .sales-totals input {
    width: 120px;
  }

  /* Buttons bigger and more tappable */
  .confirm-sale-button {
    padding: 12px;
    border-radius: 12px;
    font-size: 16px;
  }

  .secondary-button {
    padding: 12px;
    border-radius: 12px;
    font-size: 16px;
  }

  /* If you have a sales-actions wrapper, make buttons stack */
  .sales-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

@media (max-width: 768px) {
  #SalesForm.sales-section {
    padding: 0 !important; /* main already has padding */
  }
}

/* ===================================
   Mobile POS layout: Search gets space
   =================================== */
@media (max-width: 768px) {

  /* Force proper order */
  .sales-layout {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px;
  }

  /* Search panel first and larger */
  .sales-left { order: 1; }
  .sales-center { order: 2; }
  .sales-right { order: 3; }

  /* Bigger search box and results */
  .sales-search-input {
    font-size: 16px;
    padding: 12px 14px;
    border-radius: 12px;
  }

  .medicine-results {
    max-height: 52vh;         /* ✅ give search results the most space */
    border-radius: 10px;
  }

  .medicine-item {
    padding: 10px 10px;
    font-size: 14px;
  }

  /* Cart table: horizontal scroll */
  .sales-center {
    overflow: hidden;
  }

  .sales-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* Payment fields bigger */
  .sales-payment select,
  .sales-payment input,
  .sales-totals input {
    font-size: 16px;
    padding: 10px;
  }

  /* Buttons full width for mobile */
  .sales-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .secondary-button,
  .confirm-sale-button {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    font-size: 16px;
  }
}
@media (max-width: 768px) {
  .sales-left {
    border: 2px solid rgba(0, 184, 148, 0.25);
  }
}
