/* ========================================
   E-Commerce Styles for Techwood Malta
   Extends the existing site.css design system
   ======================================== */

/* --- Cart Badge in Navigation --- */
.nav-ecommerce {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cart-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  transition: background 0.2s;
}

.cart-link:hover {
  background: var(--tw-grey);
  color: var(--tw-red);
}

.cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--tw-red);
  color: var(--tw-white);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-badge:empty,
.cart-badge[data-count="0"] {
  display: none;
}

.account-link {
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  transition: background 0.2s;
}

.account-link:hover {
  background: var(--tw-grey);
  color: var(--tw-red);
}

/* --- Category Filter Tabs --- */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.category-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.2rem;
  border: 1px solid rgba(16, 18, 20, 0.12);
  border-radius: 999px;
  background: var(--tw-white);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s;
}

.category-tab:hover {
  border-color: var(--tw-red);
  color: var(--tw-red);
}

.category-tab.active {
  background: var(--tw-red);
  color: var(--tw-white);
  border-color: var(--tw-red);
}

/* --- Product Grid --- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .product-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Product Card --- */
.product-card {
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.12);
}

.product-card-image {
  position: relative;
  width: 100%;
  padding-top: 75%;
  background: var(--tw-grey);
  overflow: hidden;
}

.product-card-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card-image .placeholder-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  color: #bbb;
}

.product-card-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-card-category {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--tw-red);
  margin-bottom: 0.35rem;
}

.product-card-body h3 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.product-card-body p {
  font-size: 0.9rem;
  color: #666;
  flex: 1;
  margin-bottom: 0.75rem;
}

.product-card-price {
  font-family: "Montserrat", sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--tw-black);
  margin-bottom: 0.75rem;
}

.product-card-actions {
  display: flex;
  gap: 0.5rem;
}

.product-card-actions .button {
  flex: 1;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  border-radius: 12px;
}

/* --- Product Detail Page --- */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}

@media (max-width: 820px) {
  .product-detail {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

.product-gallery {
  position: sticky;
  top: 120px;
}

.product-gallery-main {
  width: 100%;
  border-radius: var(--tw-radius);
  overflow: hidden;
  background: var(--tw-grey);
  margin-bottom: 1rem;
}

.product-gallery-main img {
  width: 100%;
  display: block;
}

.product-gallery-thumbs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.product-gallery-thumbs img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s;
}

.product-gallery-thumbs img.active,
.product-gallery-thumbs img:hover {
  border-color: var(--tw-red);
}

.product-info h1 {
  color: var(--tw-black);
  margin-bottom: 0.5rem;
}

.product-info .product-card-category {
  margin-bottom: 1rem;
}

.product-info .price {
  font-family: "Montserrat", sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--tw-red);
  margin-bottom: 1.5rem;
}

.product-info .description {
  color: #444;
  line-height: 1.7;
  margin-bottom: 2rem;
}

.quantity-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(16, 18, 20, 0.12);
  border-radius: 12px;
  overflow: hidden;
  margin-right: 1rem;
}

.quantity-control button {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--tw-grey);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quantity-control button:hover {
  background: #ddd;
}

.quantity-control input {
  width: 50px;
  height: 40px;
  border: none;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  font-family: inherit;
}

.add-to-cart-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.product-specs {
  margin-top: 2rem;
  border-top: 1px solid rgba(16, 18, 20, 0.08);
  padding-top: 2rem;
}

.product-specs h3 {
  margin-bottom: 1rem;
}

.product-specs table {
  width: 100%;
  border-collapse: collapse;
}

.product-specs td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(16, 18, 20, 0.06);
}

.product-specs td:first-child {
  font-weight: 700;
  width: 40%;
  color: #555;
}

/* --- Cart Page --- */
.cart-table {
  width: 100%;
  border-collapse: collapse;
}

.cart-table th {
  text-align: left;
  padding: 1rem;
  border-bottom: 2px solid rgba(16, 18, 20, 0.1);
  font-family: "Montserrat", sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #777;
}

.cart-table td {
  padding: 1rem;
  border-bottom: 1px solid rgba(16, 18, 20, 0.06);
  vertical-align: middle;
}

.cart-item-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.cart-item-image {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: var(--tw-grey);
  overflow: hidden;
  flex-shrink: 0;
}

.cart-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item-name {
  font-weight: 700;
}

.cart-remove-btn {
  border: none;
  background: none;
  color: var(--tw-red);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
}

.cart-summary {
  background: var(--tw-grey);
  border-radius: var(--tw-radius);
  padding: 2rem;
  margin-top: 2rem;
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 1.05rem;
}

.cart-summary-row.total {
  font-family: "Montserrat", sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  border-top: 2px solid rgba(16, 18, 20, 0.1);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.cart-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-state h2 {
  margin-bottom: 0.75rem;
}

.empty-state p {
  color: #777;
  margin-bottom: 1.5rem;
}

/* --- Checkout Form --- */
.checkout-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 820px) {
  .checkout-grid {
    grid-template-columns: 1fr;
  }
}

.checkout-form {
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  padding: 2rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
}

.checkout-form h2 {
  margin-bottom: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 620px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-weight: 700;
  font-size: 0.92rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(16, 18, 20, 0.12);
  border-radius: 12px;
  font: inherit;
  color: var(--tw-text);
  background: #fbfbfb;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.order-summary-panel {
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  padding: 2rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 120px;
}

.order-summary-panel h2 {
  margin-bottom: 1rem;
}

.order-summary-item {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(16, 18, 20, 0.06);
  font-size: 0.92rem;
}

.order-summary-item .item-name {
  flex: 1;
}

.order-summary-item .item-qty {
  color: #777;
  margin: 0 0.5rem;
}

/* --- Account / Auth Pages --- */
.auth-container {
  max-width: 440px;
  margin: 0 auto;
}

.auth-card {
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  padding: 2.5rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.08);
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-card .form-group {
  margin-bottom: 1rem;
}

.auth-card .button {
  width: 100%;
  margin-top: 0.5rem;
}

.auth-toggle {
  text-align: center;
  margin-top: 1.5rem;
  color: #666;
}

.auth-toggle a {
  color: var(--tw-red);
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 820px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.dash-sidebar {
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  padding: 1.5rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
}

.dash-sidebar a {
  display: block;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  margin-bottom: 0.25rem;
  transition: background 0.2s;
}

.dash-sidebar a:hover,
.dash-sidebar a.active {
  background: var(--tw-grey);
  color: var(--tw-red);
}

.dash-content {
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  padding: 2rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
  min-height: 400px;
}

.dash-content h2 {
  margin-bottom: 1.5rem;
}

/* --- Admin Dashboard --- */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (max-width: 820px) {
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-card {
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  padding: 1.5rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.stat-card .stat-number {
  font-family: "Montserrat", sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--tw-red);
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: #777;
  margin-top: 0.25rem;
}

/* --- Data Tables --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--tw-grey);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #555;
  font-family: "Montserrat", sans-serif;
}

.data-table th:first-child {
  border-radius: 10px 0 0 10px;
}

.data-table th:last-child {
  border-radius: 0 10px 10px 0;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(16, 18, 20, 0.06);
  vertical-align: middle;
  font-size: 0.92rem;
}

.data-table .actions {
  display: flex;
  gap: 0.35rem;
}

.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-edit {
  background: #e8f4fd;
  color: #1976d2;
}

.btn-edit:hover {
  background: #bbdefb;
}

.btn-delete {
  background: #fce4ec;
  color: #c62828;
}

.btn-delete:hover {
  background: #ffcdd2;
}

.btn-view {
  background: #e8f5e9;
  color: #2e7d32;
}

.btn-view:hover {
  background: #c8e6c9;
}

/* --- Status Badges --- */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pending {
  background: #fff3e0;
  color: #e65100;
}

.status-processing {
  background: #e3f2fd;
  color: #1565c0;
}

.status-delivered {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-cancelled {
  background: #fce4ec;
  color: #c62828;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal {
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  padding: 2rem;
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* --- Notifications --- */
.notification {
  position: fixed;
  top: 100px;
  right: 1rem;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.notification-success {
  background: #2e7d32;
  color: white;
}

.notification-error {
  background: #c62828;
  color: white;
}

.notification-info {
  background: #1565c0;
  color: white;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* --- Image Upload --- */
.image-upload-area {
  border: 2px dashed rgba(16, 18, 20, 0.15);
  border-radius: 14px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}

.image-upload-area:hover {
  border-color: var(--tw-red);
}

.image-upload-area p {
  color: #777;
  margin: 0;
}

.image-preview-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.image-preview-grid .preview {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
}

.image-preview-grid .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-grid .preview.primary {
  border-color: var(--tw-red);
}

.image-preview-grid .preview .remove-img {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Loading spinner --- */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(16, 18, 20, 0.1);
  border-top-color: var(--tw-red);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-center {
  display: flex;
  justify-content: center;
  padding: 3rem;
}

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 0.75rem;
}

.breadcrumb a {
  color: rgba(255, 255, 255, 0.65);
}

.breadcrumb a:hover {
  color: white;
}

.breadcrumb .separator {
  margin: 0 0.15rem;
}

/* --- Order Confirmation --- */
.confirmation-card {
  max-width: 680px;
  margin: 0 auto;
  background: var(--tw-white);
  border-radius: var(--tw-radius);
  padding: 2.5rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.confirmation-card .check-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #e8f5e9;
  color: #2e7d32;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.5rem;
}

.confirmation-details {
  text-align: left;
  margin-top: 2rem;
  border-top: 1px solid rgba(16, 18, 20, 0.08);
  padding-top: 1.5rem;
}

.confirmation-details dt {
  font-weight: 700;
  font-size: 0.85rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 1rem;
}

.confirmation-details dd {
  margin: 0.25rem 0 0 0;
}

/* --- Responsive cart table --- */
@media (max-width: 620px) {
  .cart-table thead {
    display: none;
  }

  .cart-table tr {
    display: block;
    margin-bottom: 1rem;
    border: 1px solid rgba(16, 18, 20, 0.08);
    border-radius: 12px;
    padding: 1rem;
  }

  .cart-table td {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border: none;
  }

  .cart-table td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.85rem;
    color: #777;
  }

  .cart-item-info {
    flex-direction: column;
    align-items: flex-start;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }
}

/* --- Select dropdown for admin --- */
.status-select {
  padding: 0.35rem 0.5rem;
  border: 1px solid rgba(16, 18, 20, 0.12);
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
}

/* --- Tab navigation for admin --- */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--tw-grey);
  margin-bottom: 2rem;
}

.admin-tab {
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: inherit;
  color: #777;
}

.admin-tab:hover {
  color: var(--tw-black);
}

.admin-tab.active {
  color: var(--tw-red);
  border-bottom-color: var(--tw-red);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 2rem;
}

.pagination button {
  min-width: 36px;
  height: 36px;
  border: 1px solid rgba(16, 18, 20, 0.12);
  border-radius: 8px;
  background: var(--tw-white);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination button:hover {
  border-color: var(--tw-red);
  color: var(--tw-red);
}

.pagination button.active {
  background: var(--tw-red);
  color: white;
  border-color: var(--tw-red);
}

/* --- Search Input --- */
.search-bar {
  position: relative;
  margin-bottom: 1.5rem;
}

.search-bar input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.5rem;
  border: 1px solid rgba(16, 18, 20, 0.12);
  border-radius: 14px;
  font: inherit;
  background: var(--tw-white);
}

.search-bar::before {
  content: "\1F50D";
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
}
