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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    padding: 5px;
    line-height: 1.4;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Make the form type group take more columns */
.form-type-group {
    grid-column: span 3; /* or span 4 if you want it even wider */
}

/* Make the FHA input group narrower */
.form-grid .form-group:has(#FHACaseNumber) {
    grid-column: span 1;
}

/* Alternative: Make the entire form grid wider for this section */
.form-grid:has(.form-type-group) {
    grid-template-columns: repeat(5, 1fr); /* or repeat(6, 1fr) */
}

h1 {
    color: #333;
    margin-bottom: 30px;
    text-align: center;
    font-size: 28px;
}

.form-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: #555;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    padding-top: 4px;
}

/* Special grid for property section - all fields in one row */
.property-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr; /* Address gets more space */
    gap: 10px;
}

/* Grid for borrower section with transaction type */
.borrower-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr; /* Borrower, Co-Borrower, Transaction Type */
    gap: 15px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    color: #666;
    margin-bottom: 5px;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 2px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* Transaction Type Buttons */
.transaction-type-group,
.form-type-group,
.optional-features-group {
    display: flex;
    flex-direction: column;
}

.transaction-type-buttons,
.optional-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.type-btn,
.form-btn,
.optional-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #555;
}

.type-btn:hover,
.form-btn:hover,
.optional-btn:hover {
    border-color: #64B5F6;
    color: #1976D2;
    background: #E3F2FD;
}

.type-btn.active,
.form-btn.active {
    background: #42A5F5;
    color: white;
    border-color: #42A5F5;
}

/* Optional buttons can have multiple selected */
.optional-btn.active {
    background: #66BB6A;
    color: white;
    border-color: #66BB6A;
}

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

.button-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 2px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-secondary {
    background: #f44336;
    color: white;
}

.btn-secondary:hover {
    background: #da190b;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.status-message {
    padding: 15px;
    border-radius: 2px;
    margin-top: 20px;
    text-align: center;
    display: none;
}

.status-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4CAF50;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    /* Stack property fields on mobile */
    .property-grid {
        grid-template-columns: 1fr;
    }

    .borrower-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .button-container {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .transaction-type-buttons {
        justify-content: center;
    }
}

/* Tablet view */
@media (min-width: 769px) and (max-width: 1024px) {
    .property-grid {
        grid-template-columns: 1fr 1fr;
    }

    .borrower-grid {
        grid-template-columns: 1fr;
    }
}

.option-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #555;
}

.option-btn:hover {
    border-color: #64B5F6;
    color: #1976D2;
    background: #E3F2FD;
}

.option-btn.active {
    background: #42A5F5;
    color: white;
    border-color: #42A5F5;
}

.template-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 2px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #555;
}

.template-btn:hover {
    border-color: #64B5F6;
    color: #1976D2;
    background: #E3F2FD;
}

.template-btn.active {
    background: #42A5F5;
    color: white;
    border-color: #42A5F5;
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px; /* Slightly larger to match date inputs */
    -webkit-appearance: none; /* Remove browser styling */
}

.dropzone-container {
    grid-column: span 2; /* Takes up 2 columns instead of full width */
}

.dropzone-container.half-width {
    grid-column: span 2; /* Half of the 4-column grid */
}

.dropzone {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #fafafa;
    position: relative;
}

.dropzone.compact {
    padding: 10px 30px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropzone.compact .dropzone-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropzone.compact .upload-icon {
    margin: 0;
}

.dropzone.compact .dropzone-text {
    margin: 0;
    font-size: 14px;
}

.dropzone.compact .dropzone-subtext {
    display: none; /* Hide subtext in compact mode */
}

.dropzone:hover {
    border-color: #42A5F5;
    background-color: #f0f8ff;
}

.dropzone.drag-over {
    border-color: #42A5F5;
    background-color: #e3f2fd;
}

.file-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 10px;
    z-index: 10;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-top: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.dropzone-container {
    grid-column: span 1;
    width: 200px;
    float: right;
    position: relative;
    top: 20px;
    height: 20px !important;
    padding-left: 15px;
}

.borrower-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr 1fr; /* Different sized columns */
    gap: 15px;
}

/* Confidence Indicators */
.confidence-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  margin-top: 2px;
  margin-bottom: 4px;
}

.confidence-text {
  color: #666;
  font-weight: 500;
}

.confidence-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: bold;
}

.confidence-icon.high {
  background-color: #4CAF50;
  color: white;
}

.confidence-icon.medium {
  background-color: #FFC107;
  color: #333;
}

.confidence-icon.low {
  background-color: #FF9800;
  color: white;
}

/* Field Extraction Styling */
input.extracted-high,
textarea.extracted-high {
  border: 2px solid #4CAF50 !important;
  background-color: #f1f8f4 !important;
}

input.extracted-medium,
textarea.extracted-medium {
  border: 2px solid #FFC107 !important;
  background-color: #fffbf0 !important;
}

input.extracted-low,
textarea.extracted-low {
  border: 2px solid #FF9800 !important;
  background-color: #fff5e6 !important;
}

input.extracted-error,
textarea.extracted-error {
  border: 2px solid #f44336 !important;
  background-color: #ffebee !important;
}

/* Smooth transitions */
input, textarea {
  transition: border-color 0.3s ease, background-color 0.3s ease;
}

/* Loading state for form during extraction */
.form-section.extracting {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.form-section.extracting::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* Extraction spinner */
.extraction-spinner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  text-align: center;
}

.extraction-spinner .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007bff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Button confidence indicators */
.type-btn.confidence-high,
.form-btn.confidence-high,
.template-btn.confidence-high,
.option-btn.confidence-high {
    position: relative;
    border-color: #22c55e;
    background-color: rgba(34, 197, 94, 0.1);
}

.type-btn.confidence-high.active,
.form-btn.confidence-high.active,
.template-btn.confidence-high.active,
.option-btn.confidence-high.active {
    background-color: #3b82f6;
    border-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

/* Confidence badge for buttons */
.button-confidence-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #22c55e;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 1;
}

/* Container positioning for buttons with badges */
.transaction-type-buttons,
.options-buttons {
    position: relative;
}

.type-btn,
.form-btn,
.template-btn,
.option-btn {
    position: relative;
}


/* Button confidence indicators - Enhanced */
.type-btn.confidence-high,
.form-btn.confidence-high,
.template-btn.confidence-high,
.option-btn.confidence-high {
    position: relative;
    border: 2px solid #22c55e !important;
    background-color: rgba(34, 197, 94, 0.1) !important;
}

.type-btn.confidence-high.active,
.form-btn.confidence-high.active,
.template-btn.confidence-high.active,
.option-btn.confidence-high.active {
    background-color: #42A5F5 !important;
    border: 2px solid #22c55e !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3) !important;
}

/* Confidence badge for buttons */
.button-confidence-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background-color: #22c55e;
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Ensure button containers don't clip badges */
.transaction-type-buttons,
.options-buttons {
    overflow: visible;
    padding: 8px 8px 4px 4px;
}

/* Make buttons relative for badge positioning */
.type-btn,
.form-btn,
.template-btn,
.option-btn {
    position: relative;
}

.file-list {
    position: absolute;
    top: 100%;
    margin-top: 5px;
    font-size: 10px;
    opacity: 0.3;
}

.file-item {
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
}