/**
 * UFMIP Calculator - Premium UI Styles
 * A truly polished, professional financial tool
 */

/* ==========================================================================
   RESET & BASE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
  background-attachment: fixed;
  color: var(--color-text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding: 40px 20px;
}

/* ==========================================================================
   LAYOUT CONTAINER
   ========================================================================== */
.container {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
  text-align: center;
  margin-bottom: 32px;
}

.app-title {
  font-size: 2rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.app-subtitle {
  color: #94A3B8;
  font-size: 1rem;
  font-weight: 500;
}

/* ==========================================================================
   MAIN CARD - Glassmorphism
   ========================================================================== */
.card-base {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  box-shadow: 
    0 25px 50px -12px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  padding: 32px;
  position: relative;
  overflow: hidden;
}

.card-base::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #3B82F6, #8B5CF6, #EC4899);
  border-radius: 24px 24px 0 0;
}

/* ==========================================================================
   FORM ELEMENTS
   ========================================================================== */
fieldset {
  border: none;
  padding: 0;
  margin: 0 0 28px 0;
}

legend {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 700;
  color: #64748B;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

legend::before {
  content: '';
  width: 3px;
  height: 12px;
  background: linear-gradient(180deg, #3B82F6, #8B5CF6);
  border-radius: 2px;
}

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

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
}

/* Inputs & Selects */
input, select {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
  border-radius: 12px;
  border: 2px solid #E2E8F0;
  background: #FFFFFF;
  color: #1E293B;
  transition: all 0.2s ease;
  font-family: var(--font-main);
}

input:hover, select:hover {
  border-color: #CBD5E1;
}

input:focus, select:focus {
  outline: none;
  border-color: #3B82F6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

input[type="number"], .input-with-symbol {
  font-family: var(--font-mono);
  font-weight: 500;
}

/* Date Picker Row */
.date-picker-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.date-select {
  padding: 14px 40px 14px 16px;
  font-size: 0.95rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%233B82F6' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* Input with Currency Symbol */
.input-wrapper {
  position: relative;
}

.currency-symbol {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748B;
  font-weight: 600;
  font-size: 1rem;
  pointer-events: none;
}

.input-with-symbol {
  padding-left: 36px !important;
}

/* Helper Text */
small {
  display: block;
  font-size: 0.75rem;
  color: #94A3B8;
  margin-top: 6px;
}

/* Form Row */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Conditional Fields Animation */
.conditional-field {
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ==========================================================================
   RESULTS SECTION
   ========================================================================== */
.results-section {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid #E2E8F0;
  transition: all 0.4s ease;
}

/* Pending State */
.results-pending {
  opacity: 0.4;
  filter: grayscale(0.5);
}

.results-pending .result-card-primary {
  background: #F1F5F9 !important;
  border: 2px dashed #CBD5E1;
  box-shadow: none;
}

.results-pending .primary-result-value {
  color: #94A3B8 !important;
}

/* Active State */
.results-active {
  opacity: 1;
  filter: none;
}

/* ==========================================================================
   PRIMARY RESULT CARD - The Hero
   ========================================================================== */
.result-card-primary {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 
    0 20px 40px -15px rgba(15, 23, 42, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.result-card-primary::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.result-card-primary.eligible {
  background: linear-gradient(135deg, #0F172A 0%, #064E3B 100%);
}

.result-card-primary.eligible::before {
  background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, transparent 50%);
}

.result-card-primary.not-eligible {
  background: linear-gradient(135deg, #1E293B 0%, #374151 100%);
}

.primary-result-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 8px;
}

.primary-result-value {
  font-size: 3.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: #10B981;
  line-height: 1;
  text-shadow: 0 0 40px rgba(16, 185, 129, 0.4);
  letter-spacing: -0.02em;
}

.result-card-primary.not-eligible .primary-result-value {
  color: #6B7280;
  text-shadow: none;
}

.primary-result-note {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 12px;
}

/* ==========================================================================
   TIMELINE
   ========================================================================== */
.timeline-container {
  margin: 24px 0;
  padding: 20px;
  background: #F8FAFC;
  border-radius: 16px;
  border: 1px solid #E2E8F0;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timeline-header span:first-child {
  color: #64748B;
}

.timeline-header span:last-child {
  color: #3B82F6;
  font-family: var(--font-mono);
}

.timeline-track {
  width: 100%;
  height: 10px;
  background: #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.timeline-bar {
  height: 100%;
  background: linear-gradient(90deg, #3B82F6, #8B5CF6);
  border-radius: 10px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.timeline-bar.warning {
  background: linear-gradient(90deg, #F59E0B, #EF4444);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.timeline-bar.danger {
  background: #EF4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.7rem;
  color: #94A3B8;
}

/* ==========================================================================
   DETAIL GRID
   ========================================================================== */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.result-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.detail-item {
  background: #FFFFFF;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #E2E8F0;
  transition: all 0.2s ease;
}

.detail-item:hover {
  border-color: #CBD5E1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.detail-label {
  font-size: 0.7rem;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 4px;
}

.detail-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1E293B;
  font-family: var(--font-mono);
}

/* Reconstruction Card */
.reconstruction-details {
  background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  border: 1px solid #FCD34D;
  border-radius: 12px;
  padding: 16px;
  font-size: 0.875rem;
  color: #92400E;
}

.reconstruction-details h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  opacity: 0.7;
}

.reconstruction-details div {
  padding: 4px 0;
  display: flex;
  justify-content: space-between;
}

.reconstruction-details strong {
  font-family: var(--font-mono);
}

/* ==========================================================================
   MOBILE RESPONSIVE
   ========================================================================== */
@media (max-width: 540px) {
  body {
    padding: 20px 16px;
  }
  
  .card-base {
    padding: 24px 20px;
    border-radius: 20px;
  }
  
  .app-title {
    font-size: 1.5rem;
  }
  
  .primary-result-value {
    font-size: 2.5rem;
  }
  
  .form-row, .result-details-grid {
    grid-template-columns: 1fr;
  }
  
  .date-picker-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.2); }
  50% { box-shadow: 0 0 40px rgba(16, 185, 129, 0.4); }
}

.results-active .result-card-primary.eligible {
  animation: pulseGlow 3s ease-in-out infinite;
}
