@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap");

:root {
  --primary: #283593; /* Deep Navy Blue from UAP Screenshot */
  --primary-hover: #1a237e;
  --secondary: #3949ab;
  --accent: #d32f2f;
  --bg-light: #ffffff; /* Pure white background */
  --glass-bg: #ffffff; /* Solid white for clean corporate look */
  --glass-border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --radius: 12px; /* Slightly squarer radius from screenshot */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", sans-serif;
  background-color: var(--bg-light);
  background-image:
    radial-gradient(at 0% 0%, hsla(253, 16%, 96%, 1) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(225, 39%, 94%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(339, 49%, 96%, 1) 0, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-x: hidden;
}

.container {
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06); /* Subtler shadow */
  animation: fadeIn 0.6s ease-out;
}

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

h1 {
  font-family: "Outfit", sans-serif;
  font-size: 24px; /* Slightly smaller, cleaner */
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--primary); /* Use brand color for title */
  background: none;
  -webkit-text-fill-color: var(--primary);
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.input-wrapper {
  position: relative;
}

.currency-symbol {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
}

input[type="number"],
input[type="tel"] {
  width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 14px 14px 40px;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 600;
  outline: none;
  transition: all 0.3s ease;
}

input[type="number"]:focus,
input[type="tel"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Remove arrows from number input */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.btn-pay {
  width: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border: none;
  border-radius: 12px;
  padding: 16px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 6px -1px rgba(40, 53, 147, 0.3); /* Matches new primary */
}

/* Toggle Styles */
.toggle-container {
  display: flex !important; /* Force flex */
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
  width: 100%;
}

.toggle-option {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

.toggle-option.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Mandate Fields */
.hidden-fields {
  display: none;
  animation: slideDown 0.3s ease-out;
}

.hidden-fields.show {
  display: block;
}

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

select,
input[type="text"],
input[type="date"] {
  width: 100%;
  background-color: #ffffff !important;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  color: var(--text-primary) !important; /* Force dark text */
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s ease;
  appearance: none; /* Remove default browser styling */
  -webkit-appearance: none;
}

select:focus,
input[type="text"]:focus,
input[type="date"]:focus {
  border-color: var(--primary);
}

/* Fix date input icon color */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.6;
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-group.half {
  flex: 1;
}

.btn-pay:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.4);
}

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

.btn-pay:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.status-box {
  margin-top: 24px;
  padding: 16px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  display: none;
}

.status-box.error {
  display: block;
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.2);
  color: #fda4af;
}

.status-box.success {
  display: block;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.loader {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  display: none;
}

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

.btn-pay.loading .loader {
  display: block;
}

.btn-pay.loading .btn-text {
  opacity: 0.8;
}

.merchant-info {
  margin-top: 32px;
  border-top: 1px solid var(--glass-border);
  padding-top: 16px;
}

.merchant-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 8px;
}

.merchant-row span:first-child {
  color: var(--text-secondary);
}

.footer {
  position: fixed;
  bottom: 24px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Success Overlay */
.success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  padding: 20px;
}

.success-card {
  background: #ffffff;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px 24px;
  width: 100%;
  max-width: 340px;
  margin: auto; /* Force centering */
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.2);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.success-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 32px;
  color: #fff;
  margin: 0 auto 20px;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.success-card h2 {
  font-family: "Outfit", sans-serif;
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.success-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.success-details {
  background: rgba(241, 245, 249, 0.6);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 24px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 10px;
}

.detail-row:last-child {
  margin-bottom: 0;
}

.detail-row span:first-child {
  color: var(--text-secondary);
  text-align: left;
}

.detail-row span:last-child {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
  overflow-wrap: anywhere;
  font-size: 11px; /* Smaller for long IDs */
  max-width: 60%;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border: none;
  border-radius: 12px;
  padding: 14px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 20000; /* Much higher than success overlay */
}

/* --- Loan Summary Page Styles --- */
.loan-summary-body {
  background-image:
    radial-gradient(at 0% 0%, hsla(253, 16%, 96%, 1) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(225, 39%, 94%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(339, 49%, 96%, 1) 0, transparent 50%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden; /* Prevent body scroll, handle inside container */
}

.mobile-app-container {
  width: 100%;
  max-width: 400px;
  height: 100vh; /* Full height on mobile, constrained on desktop */
  background: #f8f9fe;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.1); /* Shadow for desktop view */
}

/* Header inside container */
.app-header {
  background: #ffffff; /* White header to match main app clean look */
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0; /* Prevent header from shrinking */
  border-bottom: 1px solid var(--glass-border);
}

.app-header h2 {
  font-family: "Outfit", sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--primary); /* Brand color for title */
}

.material-icons-round {
  font-size: 24px;
  color: var(--text-secondary);
  cursor: pointer;
}

.content-wrapper {
  padding: 16px; /* Reduced from 20px */
  flex-grow: 1; /* Allow content to grow and push bottom bar if needed */
  padding-bottom: 80px; /* Space for bottom bar */
}

.summary-card {
  background: #ffffff;
  border-radius: 16px; /* Reduced radius */
  padding: 16px; /* Reduced from 24px */
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.05); /* Lighter shadow */
  margin-bottom: 12px; /* Reduced from 20px */
}

.summary-card h3 {
  text-align: center;
  font-family: "Outfit", sans-serif;
  font-size: 15px; /* Reduced from 18px */
  margin-bottom: 16px; /* Reduced */
  color: #0f172a;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 16px;
  row-gap: 16px; /* Drastically reduced from 32px */
  margin-bottom: 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-item.full-width {
  grid-column: 1 / -1;
}

.detail-item .label {
  font-size: 12px;
  color: #94a3b8; /* Light grey text */
  font-weight: 500;
  line-height: 1.3;
}

.detail-item .value {
  font-size: 14px;
  color: #0f172a;
  font-weight: 600;
  word-wrap: break-word;
  word-break: break-word; /* Allows long numbers to wrap without stretching grid */
  line-height: 1.3;
}

.status-overdue {
  color: #ef4444; /* Red */
}

.status-active {
  color: #10b981; /* Emerald Green */
}

.card-note {
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.4;
  border-top: 1px solid #f1f5f9;
  padding-top: 12px;
}

.action-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 16px; /* More compact */
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.05);
}

.icon-label {
  display: flex;
  align-items: center;
  gap: 16px;
}

.id-icon {
  background: rgba(40, 53, 147, 0.1); /* Light primary bg */
  padding: 8px;
  border-radius: 12px;
  font-size: 20px;
  color: var(--primary);
}

.text-col {
  display: flex;
  flex-direction: column;
}

.main-text {
  font-weight: 600;
  font-size: 14px;
  color: #0f172a;
}

.sub-text {
  font-size: 11px;
  color: #64748b;
}

/* Timer Modal */
.text-center {
  text-align: center;
}

.modal-content {
  background: white;
  padding: 32px 24px; /* Increased padding */
  border-radius: 20px; /* Softer corners */
  width: 90%;
  max-width: 360px;
  position: relative;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.timer-circle {
  width: 120px; /* Slightly larger */
  height: 120px;
  border-radius: 50%;
  border: 5px solid #e2e8f0;
  border-top-color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin: 32px auto; /* More spacing */
  background: #f8fafc; /* Subtle fill */
}

/* Static ring override for countdown */
.timer-circle {
  animation: none;
}

.timer-note {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 8px;
}

/* Active Mandate Card */
.active-mandate-card {
  border: 1px solid #dcfce7;
  background: #f0fdf4;
  margin-top: -8px; /* Pulled closer to the previous card */
}

.mandate-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.mandate-details-grid .detail-item {
  display: flex;
  flex-direction: column;
}

.mandate-details-grid label {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
}

.mandate-details-grid .value {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%; /* Horizontal Center */
  transform: translateX(-50%); /* Center Alignment */
  width: 100%;
  max-width: 400px; /* Match App Container */
  background: white;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-around;
  padding: 12px 0 24px; /* Integrated safe area padding */
  z-index: 100;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.02);
}

.confirm-details {
  background: #f8fafc;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  color: #64748b;
}

.detail-row:last-child {
  margin-bottom: 0;
}

.bold-text {
  font-weight: 600;
  color: #1e293b;
}

.input-field {
  width: 100%;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.input-field:focus {
  border-color: var(--primary);
}

.status-box {
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
}

.status-box.error {
  background: #fee2e2;
  color: #ef4444;
}

.status-box.success {
  background: #dcfce7;
  color: #16a34a;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #94a3b8;
  cursor: pointer;
  flex: 1;
  padding: 4px 0;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 24px;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-end; /* Slide up from bottom on mobile */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #ffffff;
  width: 100%;
  max-width: 400px; /* Match app container */
  max-height: 80vh;
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: "Outfit", sans-serif;
  font-size: 18px;
  margin: 0;
  color: #0f172a;
}

.close-icon {
  font-size: 24px;
  color: #64748b;
  padding: 4px;
  cursor: pointer;
}

.modal-body {
  overflow-y: auto;
  padding: 12px; /* Added padding around table */
}

/* Schedule Table */
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.schedule-table th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  padding: 8px 8px; /* Compact padding */
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 10px; /* Smaller header */
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap; /* Prevent wrap */
}

.schedule-table td {
  padding: 10px 8px; /* Compact padding */
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  font-weight: 500;
  font-size: 11px; /* Smaller Data */
  white-space: nowrap;
}

.schedule-table tr:last-child td {
  border-bottom: none;
}

.schedule-table td:not(:first-child),
.schedule-table th:not(:first-child) {
  text-align: right;
}

.schedule-table .completed {
  background-color: #f0fdf4; /* Light green row for paid */
}

.status-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.status-badge.paid {
  color: #15803d;
  background: #dcfce7;
}

.status-badge.pending {
  color: #94a3b8;
  background: #f1f5f9;
}

/* Modal Desktop tweak */
@media (min-width: 450px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-content {
    border-radius: 24px;
    max-height: 70vh;
    transform: translateY(20px) scale(0.95);
  }
  .modal-overlay.show .modal-content {
    transform: translateY(0) scale(1);
  }
}
/* Flexi Repayment Card */
/* Flexi Repayment Card */
.flexi-card {
  margin-top: 8px; /* Tight spacing as requested */
  background: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
}

.flexi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Align top since desc wraps */
  gap: 12px;
}

.header-title h3 {
  text-align: left;
  margin-bottom: 4px;
}

.flexi-card .chevron {
  color: var(--primary);
  font-size: 24px;
  transition: transform 0.3s ease;
  transform: rotate(180deg); /* Expanded by default */
}

/* Collapsed State */
.flexi-card.collapsed .chevron {
  transform: rotate(0deg);
}

.flexi-content {
  max-height: 500px; /* Arbitrary large height */
  opacity: 1;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 12px;
}

.flexi-card.collapsed .flexi-content {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}

.section-desc {
  text-align: left;
  font-size: 11px; /* Smaller */
  color: var(--text-secondary);
  line-height: 1.3;
  margin-bottom: 0;
}

.select-wrapper select {
  width: 100%;
  padding: 10px 14px; /* More compact input */
  padding-right: 36px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc !important;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  appearance: none;
  cursor: pointer;
  box-shadow: none;
}

.select-wrapper select:focus {
  border-color: var(--primary);
  background: #ffffff !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); /* Soft shadow */
}

.dropdown-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary); /* Highlight color */
  pointer-events: none;
}

.calculation-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px; /* Highly compacted */
  text-align: center;
  margin-top: 16px;
}

.calc-label {
  display: block;
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.calc-amount-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}

.calc-amount {
  font-family: "Outfit", sans-serif;
  font-size: 20px; /* Reduced form 28px */
  font-weight: 700;
  color: var(--primary);
}

.view-plan-link {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--secondary);
  text-decoration: none;
  font-weight: 600;
  border-top: 1px solid #e2e8f0;
  padding-top: 8px;
}

.view-plan-link:hover {
  text-decoration: underline;
}

.calc-freq {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.calc-note {
  font-size: 11px;
  color: #64748b;
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 8px;
  display: inline-block;
}
