/*!
 * ==========================================================
 * Plugin Name: Obydullah Restaurant POS Lite
 * Version: 1.0.1
 * Author: Shaik Obydullah
 * Author URI: https://obydullah.com
 * ==========================================================
 */

/**
 * INDEX
 * 1. Global Utilities & Keyframes
 * 2. Buttons (Primary, Secondary, Actions)
 * 3. General Containers (WP Admin Box)
 * 4. General Table Styles (Header, Body, Striped)
 * 5. Table Utilities (Compact Views, Thumbnails)
 * 6. Product & Stock Page Components
 * 7. POS Page Layout & Components
 * 8. POS Cart & Order Summary
 * 9. WordPress Admin Compatibility
 * 10. Search & Pagination Components
 * 11. Responsive Adjustments
 * 12. Print Styles
 */

/* ==========================================================================
   1. Global Utilities & Keyframes
   ========================================================================== */
.text-primary {
  color: #2271b1 !important;
}
.text-danger {
  color: #dc3232 !important;
}
.text-warning {
  color: #ffb236 !important;
}
.text-info {
  color: #17a2b8 !important;
}
.bg-primary {
  background-color: #2271b1 !important;
}

.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}

.spinner.is-active {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #ccc;
  border-top-color: #555;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 5px;
}

.spinner {
  margin-right: 0.5rem;
  vertical-align: middle;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   2. Buttons (Primary, Secondary, Actions)
   ========================================================================== */
.btn-primary,
.btn-secondary {
  display: inline-block;
  padding: 6px 14px;
  font-size: 13px;
  line-height: 1.5;
  height: 35px;
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  text-align: center;
  transition: all 0.15s ease-in-out;
}

.btn-primary {
  color: #fff;
  background-color: #2271b1;
  border: 1px solid #2271b1;
}

.btn-primary:hover {
  background-color: #135e96;
  border-color: #135e96;
}

.btn-secondary {
  color: #333;
  background-color: #f1f1f1;
  border: 1px solid #ccc;
}

.btn-secondary:hover {
  background-color: #e2e2e2;
  border-color: #bdbdbd;
}

.btn-secondary:disabled {
  background-color: #f5f5f5;
  color: #999;
  cursor: not-allowed;
  opacity: 0.8;
}

/* Row Action Buttons (Edit/Delete) */
.pos-row-actions {
  opacity: 0.85;
  white-space: nowrap;
  text-align: right;
}

tr:hover .pos-row-actions {
  opacity: 1;
}

.pos-row-actions .pos-action {
  background: none;
  border: 1px solid #c3c4c7;
  padding: 1px 5px;
  font-size: 0.8rem;
  line-height: 1.3;
  cursor: pointer;
  border-radius: 2px;
  min-height: 22px;
}

.pos-row-actions .edit {
  color: #2271b1;
}
.pos-row-actions .delete {
  color: #b32d2e;
}
.pos-row-actions .pos-action + .pos-action {
  margin-left: 3px;
}

/* ==========================================================================
   3. General Containers (WP Admin Box)
   ========================================================================== */
.bg-light.p-4.rounded.shadow-sm {
  background-color: #fff;
  border: 1px solid #ccd0d4;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
  padding: 20px;
}

.bg-light.p-4 {
  padding: 1rem !important;
}

/* ==========================================================================
   4. General Table Styles (Header, Body, Striped)
   ========================================================================== */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.table thead tr.bg-primary {
  background-color: #f1f1f1 !important;
  color: #555 !important;
}

.table thead th {
  padding: 10px;
  border-bottom: 2px solid #e1e1e1;
  text-align: left;
  font-weight: 600;
}

.table thead.bg-primary th {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.table td {
  padding: 8px 10px;
  vertical-align: middle;
  line-height: 1.4;
  background-color: #fff;
  border-bottom: 1px solid #f0f0f1;
}

.table tbody td {
  padding: 0.5rem 0.75rem;
  vertical-align: middle;
}

/* Table Striped Utility */
.table-striped tbody tr:nth-child(odd) td {
  background-color: #f9f9f9;
}

/* Table Hover Utility */
.table-hover tbody tr:hover td {
  background-color: #f0f6fb;
}

.table-hover tbody tr:hover {
  background-color: rgba(76, 175, 80, 0.05);
}

/* Specific fix for WordPress Admin striped tables */
.wp-admin .table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* ==========================================================================
   5. Table Utilities (Compact Views, Thumbnails)
   ========================================================================== */
.table-sm td,
.table-sm th {
  padding: 4px !important;
  font-size: 12px !important;
}

.compact-thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid #ddd;
  display: block;
}

.badge-status,
.table .status-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  text-transform: uppercase;
}

.table .status-active {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.table .status-inactive {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* ==========================================================================
   6. Product & Stock Page Components
   ========================================================================== */
.product-image {
  width: 32px;
  height: 32px;
  display: flex;
  overflow: hidden;
  border: 1px solid #ddd;
  border-radius: 3px;
  background-color: #f8f9fa;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stock-summary-card {
  background-color: #fff;
  border: 1px solid #ccd0d4;
  border-radius: 6px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 120px;
  justify-content: center;
  transition: transform 0.2s ease;
}

.stock-summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}
.stock-summary-card h3 {
  font-size: 1.2rem;
  color: #6c757d;
  margin-bottom: 5px;
}
.stock-summary-card .summary-number {
  font-size: 2rem;
  font-weight: 600;
  margin: 0;
}

/* ==========================================================================
   7. POS Page Layout & Components
   ========================================================================== */

.orpl-cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid #eee;
}

.orpl-cart-item-name {
  flex: 2;
  padding-right: 15px;
}

.orpl-cart-item-qty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
}

.qty-minus, .qty-plus {
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1;
}

.qty-input {
  max-width: 5rem;
  text-align: center;
  padding: 4px;
  font-size: 14px;
}

.qty-input::-webkit-inner-spin-button,
.qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

@media (max-width: 1400px) {
  .orpl-cart-item-qty {
    gap: 5px;
  }
  
  .qty-input {
    width: 45px;
  }
}

.orpl-cart-item-price {
  flex: 1;
  text-align: right;
  padding: 0 15px;
  font-weight: bold;
}

.orpl-cart-item-remove {
  flex: 0 0 auto;
}

.orpl-pos-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}
.orpl-pos-main {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}
.orpl-pos-left {
  flex: 2;
}
.orpl-pos-right {
  flex: 1;
  min-width: 400px;
}

.orpl-categories,
.orpl-products,
.orpl-cart,
.orpl-saved-sales {
  background: white;
  border: 1px solid #ccd0d4;
  border-radius: 4px;
  padding: 15px;
  margin-bottom: 20px;
}

.orpl-category-btn {
  padding: 8px 15px;
  background: #f1f1f1;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
}

.orpl-category-btn.active,
.orpl-category-btn:hover {
  background: #2271b1;
  color: white;
  border-color: #2271b1;
}

/* Stocks Grid */
.orpl-stocks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
}

.orpl-stock-card {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  text-align: center;
  background: white;
}

.orpl-stock-card:hover {
  border-color: #2271b1;
}
.orpl-stock-card.out-of-stock {
  opacity: 0.5;
  cursor: not-allowed;
}
.orpl-stock-price {
  color: #2271b1;
  font-weight: bold;
  font-size: 16px;
}

/* ==========================================================================
   8. POS Cart & Order Summary
   ========================================================================== */
.orpl-cart-items {
  min-height: 200px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #eee;
  padding: 10px;
}

.orpl-cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid #eee;
}

.orpl-cart-item-price {
  color: #28a745;
  font-weight: bold;
}

.orpl-summary-table {
  width: 100%;
}
.orpl-summary-table tr.total-row {
  border-top: 2px solid #2271b1;
}
.orpl-summary-table tr.total-row .value-cell {
  color: #2271b1;
  font-size: 18px;
  font-weight: bold;
}

/* Custom Scrollbar */
.orpl-stocks-grid::-webkit-scrollbar,
.orpl-cart-items::-webkit-scrollbar {
  width: 6px;
}
.orpl-stocks-grid::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.saved-sale-info {
  flex: 1;
}

.saved-sale-actions {
  flex-shrink: 0;
  margin-left: 15px;
}

.load-saved-btn,
.delete-saved-btn {
  padding: 2px 8px;
  font-size: 12px;
  min-width: 60px;
}

.orpl-saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   9. WordPress Admin Compatibility
   ========================================================================== */
.wp-admin .form-control {
  display: block;
  width: 100%;
  padding: 0 8px;
  min-height: 30px;
  border: 1px solid #8c8f94;
  border-radius: 3px;
}

.wp-admin .form-control:focus {
  border-color: #2271b1;
  box-shadow: 0 0 0 1px #2271b1;
  outline: none;
}

/* ==========================================================================
   10. Search & Pagination Components
   ========================================================================== */

/* Search container */
.search-section {
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
}

/* Search input group */
.search-section .search-group {
  margin-bottom: 0;
}

.search-section .search-group label {
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  color: #495057;
  font-weight: 500;
}

/* Input field with button */
.search-section .search-group .position-relative {
  flex: 1;
  min-width: 250px;
}

.search-section .form-control {
  height: 32px;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 0.25rem;
}

/* Search button */
#search-button {
  height: 32px;
  padding: 0.25rem 1rem;
  font-size: 0.85rem;
  border-radius: 0.25rem;
  white-space: nowrap;
}

/* Clear button */
#clear-search {
  right: 5px !important;
  padding: 0.2rem;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  transform: translateY(-50%);
}

#clear-search:hover {
  color: #dc3545 !important;
}

/* Helper text */
.search-section .form-text {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  color: #6c757d;
}

/* Pagination container */
.tablenav-pages {
  margin: 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Pagination button container */
.pagination-links {
  display: flex;
  align-items: center;
  gap: 0.15rem; /* Reduced gap between buttons */
}

/* General button style */
.tablenav-pages .btn {
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  min-height: 28px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

/* Dark buttons: Prev / Next / First / Last */
.tablenav-pages .btn.btn-dark {
  background-color: #2c3e50;
  color: #fff;
  border-color: #2c3e50;
}

.tablenav-pages .btn.btn-dark:hover {
  background-color: #34495e;
  border-color: #34495e;
}

/* White page number buttons */
.tablenav-pages .btn.btn-white {
  background-color: #fff;
  color: #333;
  border: 1px solid #dee2e6;
}

.tablenav-pages .btn.btn-white:hover {
  background-color: #f8f9fa;
  border-color: #adb5bd;
}

/* Current page button style */
.tablenav-pages .btn.current-page {
  background-color: #4caf50;
  color: white;
  border-color: #45a049;
  font-weight: 600;
}

/* Disabled buttons */
.tablenav-pages .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #e9ecef;
  color: #6c757d;
  border-color: #dee2e6;
}

/* Page input and select spacing */
.tablenav-pages .paging-input {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 0.25rem;
}

.tablenav-pages .current-page {
  width: 45px !important;
  height: 28px;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
  text-align: center;
}

.tablenav-pages select {
  height: 28px;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 3px;
  min-width: 120px;
}

.tablenav-pages .tablenav-paging-text {
  font-size: 0.8rem;
  white-space: nowrap;
  margin: 0 0.15rem;
}

/* Displaying number text */
.displaying-num {
  font-size: 0.8rem;
  color: #6c757d;
  white-space: nowrap;
}

/* Table responsiveness */
.table-responsive {
  border-radius: 0.375rem;
  border: 1px solid #dee2e6;
  overflow: hidden;
}

/* ==========================================================================
   11. Responsive Adjustments
   ========================================================================== */
@media screen and (max-width: 782px) {
  .orpl-pos-main {
    flex-direction: column;
  }
  .orpl-stocks-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  .table td {
    padding: 3px 4px !important;
    font-size: 12px;
  }
}

@media (max-width: 768px) {
  .tablenav-pages {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .pagination-links {
    order: 1;
    width: 100%;
    justify-content: center;
    margin-bottom: 0.5rem;
  }

  .displaying-num {
    order: 2;
    text-align: center;
    width: 100%;
  }

  .tablenav-pages:last-child {
    order: 3;
    width: 100%;
    text-align: center;
  }

  .search-section .search-group .position-relative {
    min-width: 200px;
  }
}

/* ==========================================================================
   12. Print Styles
   ========================================================================== */
@media print {
  .no-print,
  .orpl-actions,
  .orpl-saved-sales,
  .orpl-notes {
    display: none !important;
  }
  .orpl-pos-container {
    padding: 0;
  }
}