/* ============================================
   坦桑尼亚贷款还款系统 - 样式表
   ============================================ */

/* CSS Variables */
:root {
  --primary-color: #1e3a8a;
  --primary-hover: #1e40af;
  --primary-light: #dbeafe;
  --success-color: #059669;
  --success-light: #d1fae5;
  --warning-color: #d97706;
  --warning-light: #fef3c7;
  --danger-color: #dc2626;
  --danger-light: #fee2e2;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --bg-primary: #f3f4f6;
  --bg-secondary: #e5e7eb;
  --bg-card: #ffffff;
  --border-color: #d1d5db;
  --border-light: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(to bottom, #f3f4f6 0%, #e5e7eb 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  padding-bottom: 100px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Header */
.header {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #60a5fa 100%);
  color: white;
  padding: 32px 16px 40px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(30, 58, 138, 0.3);
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="2"/></svg>');
  opacity: 0.5;
  pointer-events: none;
}

.header-content {
  position: relative;
  z-index: 1;
}

.logo {
  margin-bottom: 16px;
  display: inline-block;
  animation: fadeInDown 0.6s ease-out;
}

.header-content h1 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  animation: fadeInDown 0.6s ease-out 0.1s both;
}

.header-content p {
  font-size: 0.9375rem;
  opacity: 0.95;
  font-weight: 500;
  animation: fadeInDown 0.6s ease-out 0.2s both;
}

/* Animations */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Main Content */
.main-content {
  padding: 20px 16px;
  max-width: 540px;
  margin: -20px auto 0;
  position: relative;
  z-index: 2;
}

/* Card */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
  border: 1px solid var(--border-light);
  animation: fadeInUp 0.5s ease-out;
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-xl);
  transform: translateY(-2px);
}

.search-card {
  text-align: center;
}

.card-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  display: inline-block;
  animation: scaleIn 0.5s ease-out 0.2s both;
}

.card h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Loan Count Badge */
.loan-count {
  background: var(--primary-light);
  color: var(--primary-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Loan List */
.loan-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.loan-item {
  background: linear-gradient(to right, #ffffff 0%, #f9fafb 100%);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.loan-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--border-color);
  transition: all 0.3s ease;
}

.loan-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
}

.loan-item:hover::before {
  background: var(--primary-color);
  width: 6px;
}

.loan-item.selected {
  border-color: var(--primary-color);
  background: linear-gradient(to right, #eff6ff 0%, #dbeafe 100%);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.loan-item.selected::before {
  background: var(--primary-color);
  width: 6px;
}

.loan-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 12px;
}

.loan-item-title {
  flex: 1;
}

.loan-id {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary-color);
  display: block;
  margin-bottom: 4px;
}

.loan-app-info {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.loan-app-badge {
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.status-badge {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.status-active {
  background: var(--primary-light);
  color: var(--primary-color);
}

.status-overdue {
  background: var(--danger-light);
  color: var(--danger-color);
}

.status-paid {
  background: var(--success-light);
  color: var(--success-color);
}

.loan-item-amount-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
}

.amount-box {
  display: flex;
  flex-direction: column;
}

.amount-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.amount-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.amount-value.highlight {
  color: var(--danger-color);
  font-size: 1.25rem;
}

.loan-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.loan-due-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

.overdue-warning {
  color: var(--danger-color);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.select-indicator {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loan-item.selected .select-indicator {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.loan-item.selected .select-indicator::after {
  content: '✓';
  color: white;
  font-size: 14px;
  font-weight: bold;
}

/* Search Form */
.search-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 8px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.input-group label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.phone-input-wrapper {
  display: flex;
  align-items: center;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.3s ease;
  background: var(--bg-card);
}

.phone-input-wrapper:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.country-code {
  padding: 14px 16px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 600;
  border-right: 1px solid var(--border-color);
  font-size: 1rem;
}

.phone-input-wrapper input {
  flex: 1;
  padding: 14px 16px;
  border: none;
  font-size: 1rem;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-weight: 500;
}

.phone-input-wrapper input::placeholder {
  color: var(--text-muted);
}

.input-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* Carrier Select Styles - 匹配其他输入框样式 */
.carrier-select {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"><path d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" fill="%231e3a8a"/></svg>');
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 20px 20px;
  padding-right: 44px;
  font-family: inherit;
  outline: none;
}

.carrier-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.carrier-select option {
  padding: 14px;
  font-size: 1.125rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-primary);
}

.carrier-select option:disabled {
  color: var(--text-muted);
  font-weight: 400;
}

.carrier-hint {
  margin-top: -4px;
}

.carrier-auto-info {
  color: var(--success-color);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.carrier-auto-info strong {
  font-weight: 600;
  color: var(--success-color);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

.btn-large {
  padding: 16px 32px;
  font-size: 1.0625rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(30, 58, 138, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 2px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-primary);
  border-color: var(--text-secondary);
}

.btn-pay {
  background: linear-gradient(135deg, var(--success-color) 0%, #10b981 100%);
  color: white;
  padding: 14px 28px;
  font-size: 1.0625rem;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-pay:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.4);
}

.btn-pay:disabled {
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: not-allowed;
  box-shadow: none;
}

.btn svg {
  width: 20px;
  height: 20px;
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

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

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

.btn-primary:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.btn-pay {
  background: var(--success-color);
  color: white;
  padding: 14px 32px;
}

.btn-pay:hover {
  background: #047857;
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Loan Header */
.loan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.loan-header h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

/* Payment Bar */
.payment-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  z-index: 100;
  animation: slideUp 0.3s ease-out;
}

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

.payment-bar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  max-width: 540px;
  margin: 0 auto;
  gap: 16px;
}

.payment-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.payment-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 2px;
}

.selected-loan-info {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--primary-color);
}

/* Selected Loan Details in Modal */
.selected-loan-card {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--primary-light);
}

.selected-loan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.selected-loan-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.selected-loan-apps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.selected-loan-amounts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.amount-item {
  display: flex;
  flex-direction: column;
}

.amount-item .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.amount-item .value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
}

.amount-item.highlight {
  background: var(--bg-card);
  padding: 8px;
  border-radius: var(--radius-sm);
}

.amount-item.highlight .value {
  color: var(--danger-color);
  font-size: 1.25rem;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: calc(100% - 32px);
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: 16px;
}

@keyframes modalSlideUp {
  from {
    transform: translateY(40px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.375rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-primary);
  border-radius: 50%;
  font-size: 1.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s ease;
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  transform: rotate(90deg);
}

/* Payment Form */
.payment-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.payment-form input[type="number"] {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1.125rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
}

.payment-form input[type="number"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.carrier-info {
  padding: 14px;
  background: var(--success-light);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--success-color);
}

.carrier-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--success-color);
  font-size: 1rem;
}

.carrier-icon {
  font-size: 1.5rem;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.form-actions .btn {
  flex: 1;
}

/* Processing Modal */
.processing-content {
  text-align: center;
  padding: 48px 28px;
  border-radius: var(--radius-xl);
  animation: scaleIn 0.4s ease-out;
}

.processing-spinner {
  width: 64px;
  height: 64px;
  border: 5px solid var(--border-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 28px;
}

.processing-content h2 {
  margin-bottom: 12px;
  color: var(--primary-color);
}

.processing-content p {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.processing-hint {
  font-size: 0.9375rem;
  margin-top: 20px;
  color: var(--primary-color);
  font-weight: 600;
}

/* Success Modal */
.success-content {
  text-align: center;
  padding: 44px 28px;
  border-radius: var(--radius-xl);
  animation: scaleIn 0.4s ease-out;
}

.success-icon {
  font-size: 5rem;
  margin-bottom: 20px;
  animation: successBounce 0.6s ease-out 0.2s both;
}

@keyframes successBounce {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.success-content h2 {
  color: var(--success-color);
  margin-bottom: 16px;
  font-size: 1.5rem;
}

.success-content p {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.success-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 8px;
  margin-bottom: 28px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-secondary);
}

/* Error Card */
.error-card {
  text-align: center;
  padding: 40px 24px;
  border: 2px solid var(--danger-light);
  background: linear-gradient(to bottom, #fef2f2 0%, #fee2e2 100%);
}

.error-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.error-card h3 {
  color: var(--danger-color);
  margin-bottom: 12px;
  font-size: 1.25rem;
}

.error-card p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* Responsive */
@media (min-width: 480px) {
  .main-content {
    padding: 24px 16px;
  }
  
  .card {
    padding: 28px;
  }
}

/* Safe area for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .payment-bar {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  body {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
}
