/**
 * TasisPlus Package Product Compatibility Calculator Widget CSS
 * Pure responsive layout, RTL native, zero external dependencies
 */

.tasis-package-calc-wrapper {
  margin: 2rem auto 2.5rem auto;
  width: 100%;
  clear: both;
}

.tasis-package-calc-widget {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px 28px;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
  font-family: inherit;
  direction: rtl;
  text-align: right;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tasis-package-calc-widget:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 24px -2px rgba(15, 23, 42, 0.08);
}

.tasis-package-calc-widget * {
  box-sizing: border-box;
}

/* Header */
.tpc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

.tpc-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tpc-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  color: #2563eb;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.tpc-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.4;
}

.tpc-subtitle {
  margin: 3px 0 0;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.5;
}

.tpc-device-badge {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tpc-device-badge strong {
  color: #2563eb;
}

/* Form Grid */
.tpc-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.tpc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tpc-field label {
  font-size: 0.84rem;
  font-weight: 700;
  color: #334155;
  margin: 0;
}

.tpc-field input,
.tpc-field select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background-color: #f8fafc;
  color: #0f172a;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  outline: none;
  transition: all 0.2s ease;
}

.tpc-field input:focus,
.tpc-field select:focus {
  border-color: #2563eb;
  background-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.tpc-btn-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.tpc-btn {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
  transition: all 0.2s ease;
}

.tpc-btn:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.tpc-btn:active {
  transform: translateY(0);
}

/* Result Box */
.tpc-result {
  margin-top: 20px;
  padding: 20px 24px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  display: none;
  animation: tpcFadeIn 0.3s ease;
}

@keyframes tpcFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.tpc-result.match {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-color: #86efac;
}

.tpc-result.under {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #fcd34d;
}

.tpc-result.over {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-color: #7dd3fc;
}

.tpc-result.over-large,
.tpc-result.over-central {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
  border-color: #fca5a5;
}

.tpc-alert-header {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: #0f172a;
}

.tpc-result.match .tpc-alert-header { color: #14532d; }
.tpc-result.under .tpc-alert-header { color: #78350f; }
.tpc-result.over .tpc-alert-header { color: #0369a1; }
.tpc-result.over-large .tpc-alert-header,
.tpc-result.over-central .tpc-alert-header { color: #991b1b; }

.tpc-desc {
  font-size: 0.92rem;
  line-height: 1.8;
  color: #334155;
  margin: 0 0 14px 0;
}

.tpc-note {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  margin-bottom: 12px;
  color: #1e293b;
  border-right: 3px solid #2563eb;
}

/* Product Cards in Results */
.tpc-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.tpc-pcard {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  gap: 14px;
  align-items: center;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.tpc-pcard:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
}

.tpc-pcard.pack {
  border-color: #93c5fd;
  background: #f8fafc;
}

.tpc-pcard__thumb {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tpc-pcard__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tpc-pcard__body {
  flex: 1;
  min-width: 0;
}

.tpc-pcard__badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: #2563eb;
  background: #eff6ff;
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  margin-bottom: 4px;
}

.tpc-pcard.pack .tpc-pcard__badge {
  color: #16a34a;
  background: #dcfce7;
}

.tpc-pcard__title {
  display: block;
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
  text-decoration: none;
  line-height: 1.4;
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpc-pcard__title:hover {
  color: #2563eb;
}

.tpc-pcard__sub {
  font-size: 0.76rem;
  color: #64748b;
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tpc-pcard__action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tpc-pcard__price {
  font-size: 0.88rem;
  font-weight: 800;
  color: #0f172a;
}

.tpc-pcard__price .unit {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: normal;
}

.tpc-quick-add {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.tpc-quick-add:hover {
  background: #1d4ed8;
}

.tpc-quick-add.added {
  background: #16a34a;
  cursor: default;
}

.tpc-added-notice {
  font-size: 0.76rem;
  color: #166534;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tpc-cart-link {
  color: #2563eb;
  font-weight: 700;
  text-decoration: none;
}

.tpc-cart-link:hover {
  text-decoration: underline;
}

/* Actions in alerts */
.tpc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.tpc-action-btn {
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.tpc-action-btn.primary {
  background: #2563eb;
  color: #ffffff;
}

.tpc-action-btn.primary:hover {
  background: #1d4ed8;
}

.tpc-action-btn.secondary {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
}

.tpc-action-btn.secondary:hover {
  background: #f8fafc;
}

/* Responsive */
@media (max-width: 768px) {
  .tasis-package-calc-widget {
    padding: 18px 16px;
  }
  .tpc-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .tpc-header-left {
    width: 100%;
  }
  .tpc-form {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .tpc-btn-row {
    justify-content: stretch;
  }
  .tpc-btn {
    width: 100%;
  }
  .tpc-cards-row {
    grid-template-columns: 1fr;
  }
}
