/* Custom styles for Angrosist website - Bootstrap enhanced */

/* Custom color variables */
:root {
  --primary-color: #0d6efd;
  --success-color: #198754;
  --danger-color: #dc3545;
  --warning-color: #ffc107;
  --info-color: #0dcaf0;
  --light-color: #f8f9fa;
  --dark-color: #212529;
}

/* Body and general styles */
body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f8f9fa;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  height: 100vh;
}

/* Main container - full height with padding */
main {
  height: 100%;
}

main .row {
  margin: 0;
}

/* Card enhancements - full height with rounded corners */
.card {
  border: none;
  border-radius: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1) !important;
}

.card-header {
  border-radius: 10px 10px 0 0 !important;
  border-bottom: none;
  flex-shrink: 0;
}

.card-body {
  padding: 1rem !important;
}

/* Category cards - optimized for full height */
.category-card {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

.category-card:hover {
  border-color: var(--success-color);
  background: #e8f5e8;
  transform: translateY(-3px);
  box-shadow: 0 4px 15px rgba(25, 135, 84, 0.2);
}

.category-card.active {
  border-color: var(--success-color);
  background: #d1e7dd;
  color: #0f5132;
  box-shadow: 0 4px 15px rgba(25, 135, 84, 0.3);
}

.category-card h3 {
  font-size: 1rem;
  margin-bottom: 0;
  font-weight: 600;
}

/* Product cards - optimized for full height */
.product-card {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 150px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.product-card:hover {
  border-color: var(--success-color);
  box-shadow: 0 4px 15px rgba(25, 135, 84, 0.15);
  transform: translateY(-3px);
}

.product-card h3 {
  color: var(--success-color);
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.product-info {
  display: grid;
  gap: 0.5rem;
}

.product-info span {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  border-bottom: 1px solid #f1f3f4;
  font-size: 0.9rem;
}

.product-info span:last-child {
  border-bottom: none;
}

.product-info strong {
  color: #495057;
  font-weight: 600;
}

/* Selected product display - compact for full height */
#selected-product .card {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  margin-bottom: 1rem;
  flex-shrink: 0;
}

#selected-product .card-body {
  padding: 0.75rem;
}

/* Order items - compact for full height */
.order-item {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.order-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.order-item:last-child {
  margin-bottom: 0;
}

.order-item-info h4 {
  color: var(--success-color);
  margin-bottom: 0.25rem;
  font-weight: 600;
  font-size: 1rem;
}

.order-item-details {
  font-size: 0.8rem;
  color: #6c757d;
}

.order-item-details div {
  margin-bottom: 0.1rem;
}

.order-item-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 140px;
}

.quantity-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.quantity-input {
  width: 60px;
  text-align: center;
  border-radius: 4px;
}

.quantity-input:focus {
  border-color: var(--success-color);
  box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

/* Order list container */
#order-list {
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
}

/* Customer form - fixed at bottom */
#finalize-order-container {
  background: white;
  padding: 1rem;
  border-top: 1px solid #dee2e6;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
}

.d-flex-fill {
  flex: 1;
  min-height: 0;
}

.toast-alert {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1056; /* Higher than Bootstrap's modal z-index */
  width: auto;
  max-width: 90%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Form enhancements - compact for full height */
.form-control:focus {
  border-color: var(--success-color);
  box-shadow: 0 0 0 0.2rem rgba(25, 135, 84, 0.25);
}

.form-label {
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.25rem;
}

.form-control-sm {
  font-size: 0.875rem;
}

/* Button enhancements */
.btn {
  font-weight: 600;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn-primary {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-success {
  background: var(--success-color);
  border-color: var(--success-color);
}

.btn-danger {
  background: var(--danger-color);
  border-color: var(--danger-color);
}

/* Modal enhancements */
.modal-content {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
  border-radius: 12px 12px 0 0;
  border-bottom: none;
}

/* Product selection modal specific styles */
#product-selection-modal .modal-dialog {
  max-width: 600px;
}

#product-selection-modal .modal-body {
  padding: 1.5rem;
}

#product-selection-modal .card {
  border: 2px solid #e9ecef;
  transition: none;
}

#product-selection-modal .card:hover {
  transform: none;
  box-shadow: none;
}

#product-selection-modal .card-header {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
}

#product-selection-modal .card-body {
  padding: 1rem;
}

#product-selection-modal h6 {
  color: var(--success-color);
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

#product-selection-modal .small div {
  margin-bottom: 0.5rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid #f8f9fa;
}

#product-selection-modal .small div:last-child {
  border-bottom: none;
}

#product-selection-modal .small strong {
  color: #495057;
  min-width: 120px;
  display: inline-block;
}

/* Quantity input styling in modal */
#product-selection-modal #quantity-input {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  border: 1px solid #e9ecef;
}

#product-selection-modal #quantity-input .row {
  align-items: center;
}

#product-selection-modal #quantity-input label {
  margin-bottom: 0;
  color: #495057;
  font-weight: 600;
}

#product-selection-modal #quantity-input input {
  border: 2px solid #e9ecef;
  border-radius: 6px;
}

#product-selection-modal #quantity-input input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

#product-selection-modal #add-to-order {
  border-radius: 6px;
  font-weight: 600;
  padding: 0.5rem 1rem;
}

/* Modal footer styling */
#product-selection-modal .modal-footer {
  border-top: 1px solid #dee2e6;
  padding: 1rem 1.5rem;
}

#product-selection-modal .modal-footer .btn {
  border-radius: 6px;
  font-weight: 600;
  padding: 0.5rem 1.5rem;
}

/* Loading states */
.loading {
  text-align: center;
  padding: 1rem;
  color: #6c757d;
  font-style: italic;
}

.loading::after {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--success-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 10px;
}

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

/* Error and success states */
.error {
  background: #f8d7da;
  color: #721c24;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  border: 1px solid #f5c6cb;
  font-size: 0.9rem;
}

.success {
  background: #d1e7dd;
  color: #0f5132;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  border: 1px solid #badbcc;
  font-size: 0.9rem;
}

/* Responsive adjustments */
@media (max-width: 991px) {
  /* Tablet and mobile - vertical layout */
  body {
    overflow: auto;
    height: auto;
    padding-bottom: 0;
  }

  main {
    height: auto;
    padding-bottom: 0;
  }

  main .row {
    height: auto;
    margin: 0;
  }

  .card {
    height: auto;
    min-height: 400px;
    border-radius: 8px;
    margin-bottom: 0.5rem;
  }

  .card-body {
    max-height: none;
    overflow-y: visible;
    padding: 0.75rem !important;
  }

  .category-card {
    padding: 1.5rem;
    min-height: 100px;
  }

  .category-card h3 {
    font-size: 1.2rem;
  }

  .product-card {
    padding: 1.5rem;
    min-height: 150px;
  }

  .product-card h3 {
    font-size: 1.3rem;
  }

  .order-item {
    padding: 1rem;
    font-size: 1rem;
  }

  .order-item-info h4 {
    font-size: 1.1rem;
  }

  .order-item-details {
    font-size: 0.9rem;
  }

  .form-control {
    font-size: 1rem;
  }

  .form-label {
    font-size: 1rem;
  }

  #filters-container {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    padding-top: 1rem;
    padding-bottom: 0.5rem;
  }

  /* Sticky order section for mobile */
  #order-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--success-color);
    border-top: none;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    max-height: 70px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: max-height 0.3s ease;
  }

  #order-section.expanded {
    max-height: 60vh;
  }

  #order-section .card {
    min-height: initial;
    height: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    border: none;
    background: transparent;
  }

  #order-section .card-header {
    border-radius: 0;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  #order-section .card-header:hover {
    background-color: #0f5132;
  }

  #order-section .card-body {
    padding: 0.5rem 0.75rem !important;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    display: none !important;
    background: white;
  }

  #order-section.expanded .card-body {
    display: flex !important;
  }

  #finalize-order-container {
    display: none;
  }

  /* Compact order summary header */
  .order-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .order-summary-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }

  .order-count {
    background: var(--success-color);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
  }

  .order-summary-text {
    font-size: 0.9rem;
    font-weight: 600;
  }

  .order-expander {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: transform 0.3s ease;
  }

  #order-section.expanded .order-expander {
    transform: rotate(180deg);
  }

  /* Adjust products section to account for compact sticky order */
  #products-section {
    margin-bottom: 70px;
  }

  /* Compact order items for mobile */
  .order-item-controls {
    min-width: 100px;
  }

  .quantity-input {
    width: 50px;
  }

  /* Finalize button styling for mobile */
  #finalize-order-container {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
  }

  #finalize-order-btn {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
  }
}

@media (max-width: 768px) {
  .category-card {
    padding: 1rem;
  }

  .category-card h3 {
    font-size: 1rem;
  }

  .product-card {
    padding: 1rem;
  }

  .product-card h3 {
    font-size: 1.1rem;
  }

  .order-item {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .order-item .btn {
    width: 100%;
  }

  #quantity-input .row {
    flex-direction: column;
  }

  #quantity-input .col-4 {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 576px) {
  .card-body {
    padding: 0.75rem !important;
  }

  .product-info span {
    flex-direction: column;
    text-align: center;
  }
}

/* Custom animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeIn 0.5s ease-out;
}

/* Focus states for accessibility */
.category-card:focus,
.product-card:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Backdrop Blur Overlay */
#backdrop-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.order-expanded #backdrop-overlay {
  display: block;
  opacity: 1;
}

/* Scrollbar styling */
.card-body::-webkit-scrollbar {
  width: 6px;
}

.card-body::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.card-body::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.card-body::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Print styles */
@media print {
  .btn,
  #quantity-input,
  .modal {
    display: none !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #000 !important;
  }

  main .row {
    display: block !important;
  }

  .col-lg-4 {
    width: 100% !important;
    margin-bottom: 2rem !important;
  }
}

/* List view styles */
.list-view {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.product-list-item {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 0.75rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.product-list-item:hover {
  border-color: var(--success-color);
  box-shadow: 0 2px 8px rgba(25, 135, 84, 0.15);
  transform: translateY(-1px);
}

.product-list-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.product-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.product-list-title {
  color: var(--success-color);
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}

.product-list-details {
  font-size: 0.8rem;
  color: #6c757d;
}

.product-list-details div {
  margin-bottom: 0.15rem;
}

.product-list-details strong {
  color: #495057;
  font-weight: 600;
}

/* Responsive adjustments for list view */
@media (max-width: 768px) {
  .product-list-header {
    flex-direction: column;
    align-items: stretch;
  }

  .product-list-title {
    text-align: center;
  }

  .product-list-details .row {
    margin: 0;
  }

  .product-list-details .col-md-6 {
    padding: 0.25rem 0;
  }
}

body.order-expanded main {
  transition: filter 0.3s ease;
}
