/* Tabs Styling */
.tabs {
  overflow: hidden;
  background-color: #f1f1f1;
  margin-bottom: 20px;
  border: 1px solid #ccc;
  border-radius: 4px;
  display: flex;
  flex-wrap: wrap;
}

.tablink {
  flex: 1 1 auto;
  text-align: center;
  background-color: #ffffff;
  border: 1px solid #ccc;
  border-right: none;
  outline: none;
  cursor: pointer;
  padding: 10px;
  transition: 0.3s;
  font-size: 17px;
  font-weight: bold;
  box-sizing: border-box;
  color: #333;
}

.tablink:last-child {
  border-right: 1px solid #ccc;
}

.tablink:hover {
  background-color: #e8f5e9;
}

.tablink.active {
  background-color: #4CAF50;
  color: #ffffff;
  border-color: #4CAF50;
}

/* Tab Content */
.tabcontent {
  display: none;
  padding: 20px;
  border: 1px solid #ccc;
  border-top: none;
}

.tabcontent h2 {
  margin-top: 0;
}

.activeTab {
  display: block;
}

/* New styling for the form */
form#investmentForm,
form#costOfLivingForm {
  display: flex;
  flex-direction: column;
}

form#investmentForm label,
form#investmentForm input,
form#investmentForm button,
form#costOfLivingForm label,
form#costOfLivingForm input,
form#costOfLivingForm select {
  width: 100%;
  margin: 8px 0;
}

form#investmentForm button,
form#costOfLivingForm button {
  width: auto; /* Ensure the button does not take the full width */
  align-self: flex-start; /* Align the button to the start */
}

/* Styles for all tables */
#resultsTable, #withdrawalScheduleTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

#resultsTable th, #resultsTable td,
#withdrawalScheduleTable th, #withdrawalScheduleTable td {
  border: 1px solid #ddd;
  padding: 8px;
}

#resultsTable tr:nth-child(even),
#withdrawalScheduleTable tr:nth-child(even) {
  background-color: #f9f9f9;
}

#resultsTable tr:hover,
#withdrawalScheduleTable tr:hover {
  background-color: #f1f1f1;
}

#resultsTable th,
#withdrawalScheduleTable th {
  padding-top: 12px;
  padding-bottom: 12px;
  text-align: left;
  background-color: #4CAF50;
  color: white;
}
#oneTimeWithdrawals {
  display: flex;
  flex-direction: column;
}

#oneTimeWithdrawals label,
#oneTimeWithdrawals input,
#oneTimeWithdrawals button {
  width: 100%;
  margin: 8px 0;
}

#oneTimeWithdrawals button {
  width: auto;
  align-self: flex-start;
}

.portfolio-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding: 15px;
  max-width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.form-group {
  background: #ffffff;
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.form-group h3 {
  color: #2c3e50;
  margin-bottom: 15px;
  font-size: 1.1em;
  border-bottom: 2px solid #4CAF50;
  padding-bottom: 8px;
}

.form-group input,
.form-group select {
  margin: 8px 0;
  width: 100%;
}

.calculate-button {
  grid-column: 1 / -1;
  padding: 12px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1em;
}

.resource-section {
  margin: 2em 0;
  padding: 1em;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.carousel {
  display: flex;
  overflow-x: auto;
  gap: 1em;
  padding: 1em;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  position: relative;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(90deg, 
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0) 95%,
    rgba(76,175,80,0.2) 100%);
}

.carousel::after {
  content: '→';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #4CAF50;
  font-size: 24px;
  animation: bounce 1s infinite;
  pointer-events: none;
}

@keyframes bounce {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(-5px); }
}

.carousel::-webkit-scrollbar {
  height: 8px;
}

.carousel::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.carousel::-webkit-scrollbar-thumb {
  background: #4CAF50;
  border-radius: 4px;
}

.book-card {
  flex: 0 0 auto;
  width: 200px;
  padding: 15px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.2s;
  scroll-snap-align: start;
  margin-right: 5px;
}

.book-card:hover {
  transform: translateY(-5px);
}

.book-card img {
  width: 100%;
  height: 280px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 10px;
}

.book-card h4 {
  margin: 10px 0 5px;
  color: #2c3e50;
}

.book-card p {
  color: #666;
  margin: 0;
}

.book-card a {
  text-decoration: none;
  color: inherit;
}

.calculate-button:hover {
  background: #45a049;
}

@media (max-width: 768px) {
  .portfolio-form {
    grid-template-columns: 1fr;
  }
  
  .tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  
  .tabs button:nth-child(4) {
    grid-column: 1 / -1;
    width: 100%;
  }
}
/* Responsive Design */
/* Mobile-first base styles */
body {
  font-size: 16px;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

h1 {
  text-align: center;
  background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 2.4em;
  margin: 2rem 0;
  padding: 0 1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  background: rgba(255,255,255,0.5);
  border-radius: 16px;
  margin: 1rem auto;
  max-width: 1000px;
}

.tablink {
  padding: 12px 24px;
  font-size: 15px;
  border: none;
  border-radius: 12px;
  background: white;
  color: #2c3e50;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.tablink:hover {
  background: #f8f9fa;
  transform: translateY(-1px);
}

.tablink.active {
  background: #4CAF50;
  color: white;
  box-shadow: 0 4px 6px rgba(76,175,80,0.2);
}

form#investmentForm,
form#costOfLivingForm,
.portfolio-form {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

input, select {
  height: 44px;
  font-size: 16px;
  padding: 0.75rem 1rem;
  width: 100%;
  margin: 12px 0;
  border-radius: 12px;
  border: 2px solid #e0e0e0;
  background: white;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  display: block;
  box-sizing: border-box;
}

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

button {
  height: 44px;
  font-size: 16px;
  padding: 0 1.5rem;
  border-radius: 12px;
  background: #4CAF50;
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(76,175,80,0.2);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(76,175,80,0.25);
  background: #45a049;
}

button:active {
  transform: translateY(0);
}

button {
  background: #4CAF50;
  color: white;
  border: none;
  font-weight: bold;
}

.table-responsive {
  margin-top: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.07);
  margin: 1.5rem 0;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #eef0f2;
}

th {
  background: #4CAF50;
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

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

tr:hover td {
  background: #f8f9fa;
}

/* Tablet and up */
@media (min-width: 768px) {
  body {
    padding: 20px;
  }

  .tabs {
    flex-direction: row;
  }

  .tablink {
    width: auto;
    margin: 0;
  }

  input, select, button {
    width: auto;
  }

  .portfolio-form {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Touch-friendly styles */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
img {
  max-width: 100%;
  height: auto;
}
.table-responsive {
  overflow-x: auto;
}

.tips-section {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 8px;
  margin: 10px 0;
}

.tips-section ul {
  margin: 0;
  padding-left: 20px;
}

.tips-section ul ul {
  margin: 5px 0;
}

.tips-section li {
  margin-bottom: 8px;
}

.results-container {
  margin-top: 20px;
  padding: 20px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.results-grid {
  display: grid;
  gap: 15px;
  margin: 15px 0;
}

.success-message {
  color: #4CAF50;
  font-weight: bold;
  padding: 10px;
  background: #e8f5e9;
  border-radius: 8px;
  margin-top: 15px;
}

.gap-message {
  color: #f57c00;
  font-weight: bold;
  padding: 10px;
  background: #fff3e0;
  border-radius: 8px;
  margin-top: 15px;
}
@media only screen and (max-width: 480px) {
  .tablink {
    padding: 5px;
    font-size: 13px;
  }

  form#investmentForm label,
  form#investmentForm input,
  form#investmentForm button,
  form#costOfLivingForm label,
  form#costOfLivingForm input,
  form#costOfLivingForm select {
    font-size: 12px;
  }

  #resultsTable th, #resultsTable td {
    padding: 5px;
    font-size: 12px;
  }
}
.share-button {
  background-color: #4CAF50;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin: 10px 0;
}

.share-button:hover {
  background-color: #45a049;
}

form#investmentForm button {
  width: auto;
  align-self: flex-start;
}

.withdrawal-type {
  margin: 8px 0;
}

.withdrawal-type select {
  width: 100%;
  padding: 8px;
  margin-top: 4px;
}

#percentageWithdrawal, #fixedWithdrawal {
  margin: 8px 0;
}

.pdf-button {
  background-color: #4CAF50;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin: 10px 0;
  display: inline-block;
}

.pdf-button:hover {
  background-color: #45a049;
}

@media print {
  body * {
    visibility: hidden;
  }
  .print-section, .print-section * {
    visibility: visible;
  }
  .print-section {
    position: absolute;
    left: 0;
    top: 0;
  }
}
