/* SalesPal modal components */

:root {
  --modal-surface: #FFFFFF;
  --modal-border: #E4E7EC;
  --modal-border-light: #F0F2F5;
  --modal-text-primary: #111827;
  --modal-text-secondary: #6B7280;
  --modal-text-tertiary: #9CA3AF;
  --modal-blue-50: #EFF6FF;
  --modal-blue-500: #3B82F6;
  --modal-blue-600: #2563EB;
  --modal-green-50: #F0FDF4;
  --modal-green-500: #22C55E;
  --modal-green-600: #16A34A;
  --modal-red-50: #FEF2F2;
  --modal-red-500: #EF4444;
  --modal-red-600: #DC2626;
  --modal-amber-50: #FFFBEB;
  --modal-amber-500: #F59E0B;
  --modal-radius-sm: 6px;
  --modal-radius-md: 10px;
  --modal-radius-lg: 14px;
  --modal-radius-xl: 18px;
  --modal-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --modal-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --modal-shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --modal-shadow-modal: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.04);
}

/* v2 sp-* classes */

.sp-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  padding: 1rem;
}

.sp-modal.sp-show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sp-modal-dialog {
  background: white;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.04);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  animation: spModalIn 0.35s cubic-bezier(0.16,1,0.3,1);
  font-family: Arial, sans-serif;
  color: #111827;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@keyframes spModalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sp-modal-dialog.sp-modal-wide {
  max-width: 560px;
}

.sp-modal-header {
  padding: 1.25rem 1.5rem 0 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.sp-modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.01em;
}

.sp-modal-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sp-modal-footer {
  padding: 1rem 1.5rem 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid #F0F2F5;
}

body.sp-scroll-lock {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* v1 class names (used by navbar and existing templates) */

.modal-redesign {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  padding: 1rem;
}

.modal-redesign.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: white;
  border-radius: 18px;
  box-shadow: var(--modal-shadow-modal);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  animation: spModalIn 0.35s cubic-bezier(0.16,1,0.3,1);
  font-family: Arial, sans-serif;
  color: var(--modal-text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.modal-card.wide {
  max-width: 560px;
}

.m-header {
  padding: 1.25rem 1.5rem 0 1.5rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.m-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--modal-text-primary);
  letter-spacing: -0.01em;
}

.m-subtitle {
  font-size: 0.85rem;
  color: var(--modal-text-secondary);
  margin-top: 0.25rem;
}

.m-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--modal-text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  border-radius: var(--modal-radius-sm);
  transition: color 0.2s, background 0.2s;
}

.m-close:hover {
  color: var(--modal-text-primary);
  background: #f3f4f6;
}

.m-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.m-footer {
  padding: 1rem 1.5rem 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid var(--modal-border-light);
}

.seg-toggle {
  display: flex;
  background: #f3f4f6;
  border-radius: var(--modal-radius-md);
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: calc(var(--modal-radius-md) - 2px);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--modal-text-secondary);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.seg-btn.active {
  background: white;
  color: var(--modal-text-primary);
  box-shadow: var(--modal-shadow-sm);
}

/* Header sub-layout */
.m-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Form Elements */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.form-row-inline {
  display: flex;
  gap: 0.75rem;
}
.form-row-inline .form-row {
  flex: 1;
}
.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--modal-text-primary);
}
.form-hint {
  font-size: 0.7rem;
  color: var(--modal-text-tertiary);
  font-weight: 400;
}
.form-input,
.form-select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--modal-border);
  border-radius: var(--modal-radius-md);
  font-size: 0.85rem;
  color: var(--modal-text-primary);
  background: var(--modal-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus,
.form-select:focus {
  border-color: var(--modal-blue-500);
  box-shadow: 0 0 0 3px var(--modal-blue-50);
}
.form-input::placeholder {
  color: var(--modal-text-tertiary);
}
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

/* Amount Group with $/% Toggle */
.amount-group {
  display: flex;
  border: 1.5px solid var(--modal-border);
  border-radius: var(--modal-radius-md);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.amount-group:focus-within {
  border-color: var(--modal-blue-500);
  box-shadow: 0 0 0 3px var(--modal-blue-50);
}
.amount-group input {
  flex: 1;
  border: none;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  outline: none;
  min-width: 0;
}
.amount-toggle {
  display: flex;
  border-left: 1.5px solid var(--modal-border);
}
.amount-toggle button {
  padding: 0.6rem 0.65rem;
  border: none;
  background: #f3f4f6;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--modal-text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}
.amount-toggle button.active {
  background: var(--modal-blue-600);
  color: white;
}

/* Redesign Buttons */
.btn-redesign {
  padding: 0.55rem 1.1rem;
  border-radius: var(--modal-radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-primary-redesign {
  background: var(--modal-blue-600);
  color: white;
}
.btn-primary-redesign:hover {
  background: #1D4ED8;
}
.btn-secondary-redesign {
  background: #f3f4f6;
  color: var(--modal-text-secondary);
}
.btn-secondary-redesign:hover {
  background: var(--modal-border);
  color: var(--modal-text-primary);
}

/* Info Box (inside modals) */
.modal-redesign .info-box,
.modal-card .info-box {
  background: var(--modal-blue-50);
  border: 1px solid #DBEAFE;
  border-radius: var(--modal-radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.78rem;
  color: #1D4ED8;
  line-height: 1.45;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.modal-redesign .info-box svg,
.modal-card .info-box svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* Month Grid */
.month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.month-chip {
  padding: 0.5rem 0.25rem;
  border: 1.5px solid var(--modal-border);
  border-radius: var(--modal-radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--modal-text-secondary);
  user-select: none;
  background: transparent;
}
.month-chip:hover {
  border-color: var(--modal-blue-500);
  color: var(--modal-blue-600);
}
.month-chip.selected {
  background: var(--modal-blue-600);
  border-color: var(--modal-blue-600);
  color: white;
}

/* Category Chips */
.cat-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cat-chip {
  padding: 0.4rem 0.75rem;
  border: 1.5px solid var(--modal-border);
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--modal-text-secondary);
  background: transparent;
}
.cat-chip:hover {
  border-color: var(--modal-blue-500);
  color: var(--modal-blue-600);
}
.cat-chip.selected {
  background: var(--modal-blue-50);
  border-color: var(--modal-blue-500);
  color: var(--modal-blue-600);
}

/* Rate Type Buttons */
.rate-type-group {
  display: flex;
  gap: 6px;
}
.rate-type-btn {
  flex: 1;
  padding: 0.5rem;
  border: 1.5px solid var(--modal-border);
  border-radius: var(--modal-radius-md);
  background: var(--modal-surface);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--modal-text-secondary);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.rate-type-btn.selected {
  border-color: var(--modal-blue-500);
  background: var(--modal-blue-50);
  color: var(--modal-blue-600);
}

/* Store Tags */
.store-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0.5rem;
  background: #f3f4f6;
  border-radius: var(--modal-radius-md);
  min-height: 36px;
}
.store-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--modal-surface);
  border: 1px solid var(--modal-border);
  border-radius: 100px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--modal-text-primary);
}
