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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

.container {
  display: flex;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  background-color: white;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

.form-section {
  flex: 1;
  padding: 1.5rem;
  background-color: #fafafa;
  border-right: 1px solid #e0e0e0;
  overflow-y: auto;
}

.form-section h1 {
  color: #2c3e50;
  margin-bottom: 1rem;
  font-size: 1.6rem;
  font-weight: 600;
  border-bottom: 3px solid #3498db;
  padding-bottom: 0.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #34495e;
  font-size: 0.9rem;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  background-color: white;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group input.error,
.form-group select.error {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.error-message {
  color: #e74c3c;
  font-size: 0.8rem;
  margin-top: 0.25rem;
  display: block;
}

.button-group {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary {
  background-color: #3498db;
  color: white;
}

.btn-primary:hover {
  background-color: #2980b9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

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

.btn-secondary:hover {
  background-color: #7f8c8d;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(149, 165, 166, 0.3);
}

.preview-section {
  flex: 1;
  padding: 2rem;
  background-color: white;
  overflow-y: auto;
}

.preview-section h2 {
  color: #2c3e50;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  border-bottom: 3px solid #27ae60;
  padding-bottom: 0.5rem;
}

.preview-content {
  background-color: #fdfdfd;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 2rem;
  min-height: 500px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.preview-content pre {
  font-family: 'Times New Roman', serif;
  font-size: 12pt;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
  color: #2c3e50;
}

.highlighted-text {
  background-color: #fff9c4;
  padding: 2px 4px;
  border-radius: 3px;
  animation: highlight-fade 2s ease-out;
  border: 1px solid #f39c12;
}

@keyframes highlight-fade {
  0% {
    background-color: #f39c12;
    color: white;
  }
  100% {
    background-color: #fff9c4;
    color: #2c3e50;
  }
}

/* Tablet optimization (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .container {
    max-width: 100%;
    margin: 0;
    height: 100vh;
  }
  
  .form-section {
    padding: 1rem;
  }
  
  .preview-section {
    padding: 1rem;
  }
  
  .form-group {
    margin-bottom: 0.8rem;
  }
  
  .help-section {
    padding: 0.8rem;
    margin-bottom: 0.8rem;
  }
  
  .form-group input,
  .form-group select {
    padding: 0.6rem;
    font-size: 0.95rem;
  }
  
  .btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
  }
}

/* Mobile phone optimization (up to 768px) */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
    height: auto;
    max-width: 100%;
    margin: 0;
    box-shadow: none;
  }
  
  .form-section {
    padding: 1rem;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
  
  .preview-section {
    padding: 1rem;
    max-height: 60vh;
    overflow-y: auto;
  }
  
  .form-group {
    margin-bottom: 0.8rem;
  }
  
  .form-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .button-group {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .btn {
    width: 100%;
    padding: 0.8rem;
    font-size: 0.95rem;
  }
  
  .help-section {
    padding: 0.8rem;
    margin-bottom: 0.8rem;
  }
  
  .form-group input,
  .form-group select {
    padding: 0.8rem;
    font-size: 1rem;
  }
  
  .form-group label {
    font-size: 0.9rem;
  }
  
  .treaty-info {
    font-size: 0.85rem;
  }
  
  .preview-content {
    padding: 1rem;
    font-size: 0.9rem;
  }
  
  .preview-content pre {
    font-size: 10pt;
  }
}

/* Extra small phones (up to 480px) */
@media (max-width: 480px) {
  .form-section {
    padding: 0.8rem;
  }
  
  .preview-section {
    padding: 0.8rem;
    max-height: 50vh;
  }
  
  .form-group {
    margin-bottom: 0.6rem;
  }
  
  .help-section {
    padding: 0.6rem;
    margin-bottom: 0.6rem;
  }
  
  .form-group input,
  .form-group select {
    padding: 0.7rem;
    font-size: 0.95rem;
  }
  
  .btn {
    padding: 0.7rem;
    font-size: 0.9rem;
  }
  
  .preview-content {
    padding: 0.8rem;
  }
  
  .preview-content pre {
    font-size: 9pt;
    line-height: 1.4;
  }
  
  .lang-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
  }
}

/* Print styles */
@media print {
  .form-section {
    display: none;
  }
  
  .preview-section {
    padding: 0;
  }
  
  .preview-content {
    border: none;
    box-shadow: none;
    padding: 0;
  }
}

/* Scrollbar styling for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Focus styles for accessibility */
.btn:focus,
input:focus,
select:focus {
  outline: 2px solid #3498db;
  outline-offset: 2px;
}

/* Loading state for buttons */
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Enhanced form styling */
.form-group input::placeholder,
.form-group select option {
  color: #95a5a6;
}

.form-group select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

/* Enhanced visual feedback */
.form-group input:valid {
  border-color: #27ae60;
}

.form-group input:invalid:not(:placeholder-shown) {
  border-color: #e74c3c;
}

/* Smooth transitions */
* {
  transition: all 0.2s ease;
}

/* Better spacing for treaty information display */
.treaty-info {
  background-color: #ecf0f1;
  padding: 1rem;
  border-radius: 6px;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #2c3e50;
}

/* Enhanced button hover effects */
.btn:active {
  transform: translateY(0);
}

/* Better visual hierarchy */
.form-section h1::after {
  content: '';
  display: block;
  width: 50px;
  height: 3px;
  background-color: #3498db;
  margin-top: 0.5rem;
}

.preview-section h2::after {
  content: '';
  display: block;
  width: 50px;
  height: 3px;
  background-color: #27ae60;
  margin-top: 0.5rem;
}

/* Help section styling */
.help-section {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.help-section h3 {
  color: #2c3e50;
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.help-section p {
  color: #555;
  margin-bottom: 1rem;
  line-height: 1.6;
}

.help-section ol,
.help-section ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.help-section li {
  margin-bottom: 0.5rem;
  color: #555;
}

.help-section a {
  color: #3498db;
  text-decoration: none;
  font-weight: 500;
}

.help-section a:hover {
  text-decoration: underline;
  color: #2980b9;
}

/* Tooltip styling */
.tooltip {
  position: relative;
  display: inline-block;
  margin-left: 0.5rem;
  cursor: help;
  font-size: 0.9rem;
  color: #3498db;
}

.tooltip:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #2c3e50;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 0.8rem;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tooltip:hover::before {
  content: '';
  position: absolute;
  bottom: 115%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #2c3e50;
  z-index: 1000;
}

/* Field help text */
.field-help {
  margin-top: 0.25rem;
}

.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.toggle-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.3s ease, background-color 0.3s ease;
  font-size: 0.9rem;
  color: #34495e;
}

.toggle-option input {
  margin: 0;
}

.toggle-option.active {
  border-color: #3498db;
  background-color: rgba(52, 152, 219, 0.12);
  color: #2c3e50;
}

.income-type-toggle .toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  color: #34495e;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.field-help small {
  color: #7f8c8d;
  font-size: 0.8rem;
  font-style: italic;
}

/* Treaty info styling */
.treaty-info {
  background-color: #e8f5e8;
  border: 1px solid #27ae60;
  border-radius: 6px;
  padding: 1rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #2c3e50;
}

.treaty-info strong {
  color: #27ae60;
  display: block;
  margin-bottom: 0.5rem;
}

.treaty-info p {
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.treaty-info a {
  color: #27ae60;
  text-decoration: none;
  font-weight: 500;
}

.treaty-info a:hover {
  text-decoration: underline;
  color: #229954;
}

/* Enhanced button styling */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: none;
  letter-spacing: normal;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Header section with language toggle */
.header-section {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.language-toggle {
  display: flex;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.lang-btn {
  background: white;
  border: none;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.lang-btn:hover {
  background-color: #f8f9fa;
}

.lang-btn.active {
  background-color: #3498db;
  color: white;
}

.lang-btn.active:hover {
  background-color: #2980b9;
}

/* Touch-friendly interactions for mobile */
@media (max-width: 768px) {
  .header-section {
    justify-content: center;
    margin-bottom: 1rem;
  }
  
  .language-toggle {
    align-self: center;
  }
  
  /* Larger touch targets */
  .lang-btn {
    min-height: 44px;
    min-width: 60px;
  }
  
  .btn {
    min-height: 44px;
  }
  
  .form-group input,
  .form-group select {
    min-height: 44px;
  }
  
  /* Better focus states for mobile */
  .form-group input:focus,
  .form-group select:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
  }
  
  .btn:active {
    transform: scale(0.98);
  }
}

/* Contingent Interest Info Styles */
.contingent-interest-info {
  margin-top: 1rem;
  border-top: 1px solid #dee2e6;
  padding-top: 1rem;
}

.learn-more-btn {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #495057;
  font-weight: 500;
  width: 100%;
  text-align: left;
  justify-content: space-between;
}

.learn-more-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.learn-more-btn:focus {
  outline: 2px solid #007bff;
  outline-offset: 2px;
}

.contingent-details {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 1rem;
  margin-top: 0.5rem;
  animation: slideDown 0.3s ease-out;
}

.contingent-details h4 {
  color: #495057;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.contingent-details p {
  margin-bottom: 0.75rem;
  color: #6c757d;
  font-size: 0.9rem;
  line-height: 1.5;
}

.contingent-details ul {
  margin: 0.5rem 0 1rem 1.5rem;
  color: #6c757d;
  font-size: 0.9rem;
}

.contingent-details li {
  margin-bottom: 0.25rem;
}

@keyframes slideDown {
  0% {
    opacity: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
  100% {
    opacity: 1;
    max-height: 300px;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
}

/* Mobile styles for contingent interest info */
@media (max-width: 768px) {
  .contingent-details {
    padding: 0.8rem;
    font-size: 0.85rem;
  }
  
  .contingent-details h4 {
    font-size: 0.95rem;
  }
  
  .learn-more-btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
}

/* Accessibility improvements for all devices */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
