/* Profile Overlay Styles */

.profile-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.profile-wrapper.active {
  display: flex;
  opacity: 1;
}

.profile-overlay {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.profile-wrapper.active .profile-overlay {
  transform: scale(1) translateY(0);
}

/* Close Button */
.profile-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  z-index: 10001;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.profile-close-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ffffff;
  transform: scale(1.1);
}

/* Profile Header */
.profile-header {
  background: linear-gradient(135deg, #1A2151, #2d3b7a);
  color: white !important;
  padding: 30px 80px 30px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.profile-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: white !important;
}

.profile-header h2 span {
  color: white !important;
}

/* User Info Section */
.user-info-section {
  padding: 0 0 24px 0;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 32px;
}

.user-info-label {
  font-size: 18px;
  font-weight: 600;
  color: rgba(26, 33, 81, 0.6);
  margin: 0 0 8px 0;
}

.user-display-name {
  font-size: 24px;
  font-weight: 700;
  color: #1A2151;
  margin: 0 0 4px 0;
}

.user-email {
  font-size: 14px;
  font-weight: 400;
  color: rgba(26, 33, 81, 0.6);
  margin: 0;
}

/* Savings Section */
.savings-section {
  margin-bottom: 32px;
}

.savings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.savings-title {
  font-size: 20px;
  font-weight: 700;
  color: #1A2151;
  margin: 0;
}

.month-selector-btn {
  background: rgba(26, 33, 81, 0.05);
  border: 1px solid rgba(26, 33, 81, 0.2);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 13px;
  font-weight: 600;
  color: #1A2151;
}

.month-selector-btn:hover {
  background: rgba(26, 33, 81, 0.1);
  border-color: rgba(26, 33, 81, 0.3);
}

.month-selector-btn i {
  font-size: 16px;
}

.savings-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.savings-card {
  border-radius: 20px;
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: all 0.3s ease;
  border: 1.5px solid;
}

.total-savings-card {
  background: linear-gradient(135deg, rgba(0, 176, 80, 0.1), rgba(0, 176, 80, 0.05));
  border-color: rgba(0, 176, 80, 0.3);
}

.month-savings-card {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), rgba(74, 222, 128, 0.05));
  border-color: rgba(74, 222, 128, 0.3);
}

.savings-card-icon {
  background: rgba(0, 176, 80, 0.2);
  border-radius: 12px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.total-savings-card .savings-card-icon {
  background: rgba(0, 176, 80, 0.2);
}

.month-savings-card .savings-card-icon {
  background: rgba(74, 222, 128, 0.2);
}

.savings-card-icon i {
  font-size: 32px;
  color: #00B050;
}

.month-savings-card .savings-card-icon i {
  color: #4ADE80;
}

.savings-card-content {
  flex: 1;
}

.savings-card-label {
  font-size: 14px;
  font-weight: 500;
  color: rgba(26, 33, 81, 0.7);
  margin: 0 0 4px 0;
}

.savings-amount {
  font-size: 28px;
  font-weight: 800;
  margin: 0;
  transition: transform 0.15s ease;
  transform-origin: left center;
  display: inline-block;
}

.total-savings-card .savings-amount {
  color: #00B050;
}

.month-savings-card .savings-amount {
  color: #4ADE80;
}

/* Profile Content Wrapper */
.profile-content-wrapper {
  flex: 1;
  overflow-y: auto;
  max-height: calc(90vh - 160px);
}

/* Loading State */
.profile-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 30px;
  color: #666;
}

.profile-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #042D6B;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Profile Content */
.profile-content {
  padding: 30px;
}

.profile-section {
  margin-bottom: 40px;
}

.profile-section-title {
  font-size: 20px;
  font-weight: 700;
  color: #1A2151;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.profile-section-title > span {
  flex: 1;
  min-width: 200px;
}

.addresses-count {
  background: rgba(26, 33, 81, 0.1);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #1A2151;
}

.add-address-btn {
  width: 100%;
  margin-top: 12px;
  background: white;
  border: 1.5px solid rgba(26, 33, 81, 0.3);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  font-weight: 600;
  color: #1A2151;
}

.add-address-btn:hover {
  background: rgba(26, 33, 81, 0.05);
  border-color: rgba(26, 33, 81, 0.5);
}

/* Address Cards */
.addresses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.address-card {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  position: relative;
  transition: all 0.3s ease;
  cursor: pointer;
}

.address-card:hover {
  border-color: #042D6B;
  box-shadow: 0 4px 12px rgba(4, 45, 107, 0.1);
  transform: translateY(-2px);
}

.address-card.default {
  border-color: #059669;
  background: #f0fdf4;
}

.address-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.address-label {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.address-default-badge {
  display: inline-block;
  background: #059669;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.address-details {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.6;
  margin-bottom: 16px;
}

.address-details-line {
  margin-bottom: 4px;
}

.address-actions {
  display: flex;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.address-action-btn {
  flex: 1;
  background: none;
  border: 1px solid #d1d5db;
  color: #6b7280;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.address-action-btn:hover {
  border-color: #042D6B;
  color: #042D6B;
  background: rgba(4, 45, 107, 0.05);
}

.address-action-btn.delete:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
}

.add-address-card {
  background: #f9fafb;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 200px;
}

.add-address-card:hover {
  border-color: #042D6B;
  background: #f0f7ff;
}

.add-address-card i {
  font-size: 48px;
  color: #9ca3af;
  margin-bottom: 12px;
}

.add-address-card span {
  font-size: 16px;
  font-weight: 600;
  color: #6b7280;
}

/* Address Form Modal */
.address-form-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: white;
  z-index: 10;
  overflow-y: auto;
  display: none;
}

.address-form-modal.active {
  display: block;
}

.address-form-header {
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.address-form-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #111827;
}

.address-form-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  transition: color 0.2s ease;
}

.address-form-close-btn:hover {
  color: #111827;
}

.address-form-content {
  padding: 30px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}

.form-label.required::after {
  content: " *";
  color: #ef4444;
}

.form-control {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: #042D6B;
  box-shadow: 0 0 0 3px rgba(4, 45, 107, 0.1);
}

.form-control.error {
  border-color: #ef4444;
}

.form-error {
  color: #ef4444;
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.form-error.show {
  display: block;
}

.form-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
}

.form-help-text {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.form-success-message {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  color: #047857;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
  display: none;
}

.form-success-message.show {
  display: block;
}

.form-checkbox-group {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.form-checkbox {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  cursor: pointer;
}

.form-checkbox-label {
  font-size: 14px;
  color: #374151;
  cursor: pointer;
}

.form-section-title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin: 30px 0 16px 0;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}

.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
  margin-top: 30px;
}

.btn {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
}

.btn-primary {
  background: #042D6B;
  color: white;
  flex: 1;
}

.btn-primary:hover {
  background: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(4, 45, 107, 0.3);
}

.btn-secondary {
  background: white;
  color: #6b7280;
  border: 1px solid #d1d5db;
  flex: 1;
}

.btn-secondary:hover {
  background: #f9fafb;
  color: #374151;
  border-color: #9ca3af;
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Dropdown styling override */
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23374151' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Postcode Lookup */
.postcode-lookup-group {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.postcode-lookup-group .form-control {
  flex: 1;
}

.btn-lookup {
  background: #042D6B;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.btn-lookup:hover {
  background: #1e40af;
}

.btn-lookup:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

/* Error State */
.profile-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 30px;
  text-align: center;
}

.profile-error i {
  font-size: 64px;
  color: #f59e0b;
  margin-bottom: 20px;
}

.profile-error h3 {
  font-size: 24px;
  color: #374151;
  margin-bottom: 12px;
}

.profile-error p {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 30px;
}

.profile-retry-btn {
  background: #042D6B;
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.profile-retry-btn:hover {
  background: #1e40af;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(4, 45, 107, 0.3);
}

/* Month Picker Modal */
.month-picker-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.month-picker-modal.active {
  display: flex;
}

.month-picker-content {
  background: white;
  border-radius: 20px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.month-picker-title {
  font-size: 20px;
  font-weight: 700;
  color: #1A2151;
  margin: 0 0 24px 0;
  text-align: center;
}

.year-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
}

.year-nav-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #1A2151;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 8px;
  border-radius: 8px;
}

.year-nav-btn:hover:not(:disabled) {
  background: rgba(26, 33, 81, 0.1);
}

.year-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.selected-year {
  font-size: 18px;
  font-weight: 600;
  color: #1A2151;
  min-width: 60px;
  text-align: center;
}

.months-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 24px;
}

.month-item {
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(26, 33, 81, 0.05);
  color: #1A2151;
  border: 2px solid transparent;
}

.month-item:hover:not(.disabled):not(.selected) {
  background: rgba(26, 33, 81, 0.1);
}

.month-item.selected {
  background: #00B050;
  color: white;
  border-color: #00B050;
  font-weight: 700;
}

.month-item.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  background: rgba(128, 128, 128, 0.1);
  color: #9ca3af;
}

.month-picker-close-btn {
  width: 100%;
  padding: 12px;
  background: none;
  border: none;
  color: #1A2151;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
}

.month-picker-close-btn:hover {
  background: rgba(26, 33, 81, 0.05);
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .profile-overlay {
    width: 95%;
    max-height: 95vh;
  }

  .profile-header {
    padding: 20px;
    text-align: center;
  }

  .profile-header h2 {
    font-size: 20px;
  }

  .profile-content {
    padding: 20px;
  }

  .addresses-grid {
    grid-template-columns: 1fr;
  }

  .savings-cards {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .address-form-content {
    padding: 20px;
  }

  .postcode-lookup-group {
    flex-direction: column;
  }
}
