/* === Reset and Base Styles === */
body,
.container,
input,
textarea,
select,
button,
#goProButton,
.footer {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: #f1f3f7;
  color: #333;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Page Layout === */
.page-wrapper {
  display: flex;
  flex: 1;
}

/* Sidebar - Light and Dark Mode */
.sidebar {
  width: 200px;
  background-color: #ffffff; /* Light mode sidebar background */
  border-right: 1px solid #ccc;
  color: #000000;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 1rem;
  z-index: 1000;
  position: relative;
  transition: width 0.4s ease, background-color 0.4s ease, color 0.4s ease;
}

body.dark .sidebar {
  border-right: 1px solid #333;
  background-color: #1e1e1e;
  color: white;
}

/* Sidebar links */
.sidebar a {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0;
  width: 100%;
  text-align: right;
  transition: color 0.3s ease;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}

.sidebar a:hover {
  color: #dd8d;
}

body.dark .sidebar a {
  color: #f0f0f0;
}

/* Toggle icon inside sidebar */
.sidebar .toggle-icon {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.25rem;
  color: inherit;
  cursor: pointer;
  transition: color 0.3s ease;
}

.sidebar .toggle-icon:hover {
  color: #dd8d;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
  width: 48px;
  align-items: center;
}

/* Hide nav text when collapsed */
.sidebar.collapsed a {
  opacity: 0;
  transform: translateX(20px);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Light Mode Download Button */
#downloadBtn {
  background-color: white;
  color: black;
  border: 2px solid #888;
  font-weight: bold;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
  align-self: stretch;
}

#downloadBtn:hover {
  background-color: #dd8d;
  color: white;
}

/* Dark Mode Download Button */
body.dark #downloadBtn {
  background-color: #2a2a2a;
  color: #f0f0f0;
  border: 2px solid #888;
}

body.dark #downloadBtn:hover {
  background-color: #dd8d;
  color: white;
}

/* Dark Mode Sidebar */
body.dark .sidebar {
  background-color: #1e1e1e;
}

body.dark .sidebar a {
  color: #f0f0f0;
}

body.dark .sidebar a:hover {
  color: #dd8d;
}

body.dark .sidebar .toggle-btn {
  color: #f0f0f0;
}

body.dark .sidebar .toggle-btn:hover i {
  color: #dd8d;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center; /* Center container horizontally */
  justify-content: center; /* Center container vertically if needed */
  padding: 2rem; /* Equal padding on all sides */
}

/* === Dark Mode === */
body.dark {
  background: #121212;
  color: #f0f0f0;
}

body.dark .container {
  background: #1e1e1e;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
}

body.dark input,
body.dark textarea,
body.dark select,
body.dark button,
body.dark .dropdown,
body.dark input[type="file"] {
  background: #2a2a2a;
  color: #f0f0f0;
  border-color: #555;
}

body.dark input:focus,
body.dark textarea:focus,
body.dark select:focus {
  border-color: #66b2ff;
  box-shadow: 0 0 0 2px rgba(102, 178, 255, 0.2);
}

body.dark h1,
body.dark h3,
body.dark label,
body.dark p {
  color: #f0f0f0;
}

body.dark .footer {
  background: #1e1e1e;
  border-top: 1px solid #333;
  color: #ffffff;
}

body.dark .footer a {
  color: #ffffff;
}

body.dark .footer a:hover {
  color: #dd8d;
}

/* === Container Layout === */
.container {
  background: #ffffff;
  padding: 1.5rem;
  margin-top: 0;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  width: 95%;
  height: 100%;
  transition: all 0.4s ease;
}

#goProButton {
  background-color: #ffae00;
  color: #000000;
  border: none;
  padding: 0.6rem 1.4rem;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(255, 174, 0, 0.6);
  transition: transform 0.2s ease, box-shadow 0.3s ease;
}

#goProButton:hover {
  transform: scale(1.05);
  box-shadow: 0 0 14px rgba(255, 174, 0, 0.9);
}

/* === Form Layout === */
form h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.row {
  display: flex;
  gap: 0.5rem;           /* Reduced spacing */
  margin-bottom: 0.3rem; /* Less vertical margin */
  flex-wrap: wrap;
}

.col {
  flex: 1;
  min-width: 200px;       /* Tighter layout */
  display: flex;
  flex-direction: column;
  gap: 0.25rem;           /* Less spacing between label/input */
}

input,
select,
textarea {
  padding: 0.4rem;
  border-radius: 4px;
  border: 1px solid #ccc;
  font-size: 0.9rem;
}

textarea {
  min-height: 50px;
  width: 50%;
  resize: vertical;
}

input[type="file"] {
  padding: 0.3rem;
  background: white;
}

body.dark input[type="file"] {
  background: #2a2a2a;
  color: #f0f0f0;
  border: 1px solid #555;
}

button[type="submit"],
button {
  margin-top: 1.25rem;
  border: 2px solid #888;
  color: black;
  border: none;
  cursor: pointer;
  transition: background-color 0.4s ease;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  border-radius: 6px;
  font-weight: bold;
  background-color: white;
  width: fit-content;
}

/* Consistent button style in dark mode too */
body.dark button {
  background-color: #333;
  border: 2px solid #888;
  color: white;
}

body.dark button:hover {
  background-color: #dd8d;
}

/* === Footer === */
.footer {
  margin-top: auto;
  width: 100%;
  padding: 1rem;
  background: #fff;
  border-top: 1px solid #ccc;
  text-align: center;
  color: #000000;
  z-index: 1001;
  position: relative; /* <--- Changed from sticky/fixed */
}

.footer a {
  color: #000000;
  margin: 0 0.5rem;
  text-decoration: none;
}

.footer a:hover {
  color: #dd8d;
}

body.dark .footer {
  background: #1e1e1e;
  border-color: #444;
  color: #ffffff;
}

body.pro-enabled .pro-only {
  display: flex;
}

/* === Responsive === */
@media (max-width: 768px) {
  .row {
    flex-direction: column;
  }

  .sidebar {
    display: none;
  }
}

/* === Line Items === */
.line-item-row {
  margin-bottom: 0.3rem;
}

/* === Animate Pro Feature Toggle === */
.pro-only {
  gap: 0.3rem;
  display: flex;
  flex-direction: column;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.4s ease, max-height 0.4s ease;
}

body.pro-enabled .pro-only {
  opacity: 1;
  max-height: 1000px;
}

/* === Add Line Item Button === */
#addLineItemBtn {
  background-color: white;
  color: black;
  border: 2px solid #888;
  font-weight: bold;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease;
  width: fit-content;
}

#addLineItemBtn:hover {
  background-color: #dd8d;
  color: white;
}

/* === Dark Mode Add Line Item Button === */
body.dark #addLineItemBtn {
  background-color: #2a2a2a;
  color: #f0f0f0;
  border: 2px solid #888;
}

body.dark #addLineItemBtn:hover {
  background-color: #dd8d;
  color: white;
}

body.dark .main-content {
  background-color: #202020; /* Match the dark background or adjust if you want a distinct grey */
}

/* === Fixed Height for Additional Notes === */
textarea#additionalNotes {
  resize: none;       /* Disable manual resizing */
  height: 120px;       /* Fixed height */
  width: 50%;        /* Full width of container */
}

/* === Scrollable Table Layout for Line Items (After 2 Items) === */
#lineItemsWrapper {
  max-height: 25rem; /* or however tall you want before scroll appears */
  height: 25rem;
  overflow-y: auto;
  overflow-x: auto;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: white;
  display: inline-block; /* <--- key for width to fit content */
  white-space: nowrap;
}

body.dark #lineItemsWrapper {
  background-color: #2a2a2a;
  border-color: #555;
}

/* Line items styled like table rows */
.line-item-grid {
  grid-template-columns: 2fr 1fr 1fr 1fr auto; /* auto is for the remove button */
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
  position: relative;
}

.line-item-grid.first .remove-btn {
  visibility: hidden; /* Keeps the space reserved */
}

.remove-btn.invisible {
  visibility: hidden;
}

.line-item-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e0e0e0;
  align-items: center;
  flex-wrap: wrap;
}

body.dark .line-item-row {
  border-bottom: 1px solid #444;
}

.line-item-row .col {
  flex: 1;
  min-width: 140px;
}

.line-item-row .col.description {
  flex: 2;
}

.line-item-row .col.quantity {
  flex: 0.5;
  max-width: 100px;
}

.line-item-row .col.rate,
.line-item-row .col.tax-rate {
  flex: 0.75;
  max-width: 120px;
}

.line-item-row input {
  width: 100%;
}

.line-item-number {
  left: -30px;
  top: 0;
  font-weight: bold;
  font-size: 1rem;
  width: 20px;
}

body.dark .line-item-number {
  color: #ccc;
}

/* Invoice details take less space and stay on the same row */
.invoice-details-row {
  flex-wrap: nowrap;
  gap: 1rem;
  justify-content: space-between;
}

.invoice-details-row .col.small {
  flex: 1;
  min-width: 160px;
}

/* Force all client info into one scrollable row on small screens if needed */
.client-info-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 1rem;
  align-items: flex-end;
}

/* Allows all sender fields to appear in one row */
.sender-info-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 1rem;
  align-items: flex-end;
}

.header-with-pro {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
}

#goProButton.highlight-pro {
  background-color: #ff5722;
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.3s ease;
}

#goProButton.highlight-pro:hover {
  background-color: #e64a19;
}

.pro-description {
  margin-top: 4px;
  color: #666;
  max-width: 220px;
  font-size: 0.75rem;
  opacity: 0.8;
}

.go-pro-wrapper {
  padding-left: 100px;
  flex-direction: column;
  align-items: left;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

#goProButton {
  padding: 6px 16px;
  font-size: 0.9rem;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  box-shadow: 0 0 0px 1000px white inset !important;
  -webkit-box-shadow: 0 0 0px 1000px white inset !important;
  -webkit-text-fill-color: #000000 !important;
  transition: background-color 5000s ease-in-out 0s;
}

body.dark input:-webkit-autofill,
body.dark textarea:-webkit-autofill,
body.dark select:-webkit-autofill {
  box-shadow: 0 0 0px 1000px #2a2a2a inset !important;
  -webkit-box-shadow: 0 0 0px 1000px #2a2a2a inset !important;
  -webkit-text-fill-color: #f0f0f0 !important;
}

/* Contact page CSS */
/* Contact Page Styling */
.page-wrapper-2 {
  width: 100%;
  height: 100%;
  display: flex;
  flex: 1;
  background-color: var(--card-bg, #ffffff);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  transition: background-color 0.3s;
}

.page-wrapper-2 h2 {
  margin-bottom: 0.25rem;
  font-size: 2rem;
}

.page-wrapper-2 p {
  margin-bottom: 1.5rem;
  font-size: 1rem;
  color: var(--text-muted, #666);
}

#contactForm .row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

#contactForm .col {
  flex: 1 1 100%;
}

@media (min-width: 600px) {
  #contactForm .col {
    flex: 1 1 calc(50% - 0.5rem);
  }

  #contactForm textarea {
    width: 100%;
  }
}

#contactForm label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

#contactForm input,
#contactForm textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.3s, background-color 0.3s;
  background-color: var(--input-bg, #fff);
  color: var(--text, #000);
}

#contactForm input:focus,
#contactForm textarea:focus {
  border-color: var(--primary, #007BFF);
  outline: none;
}

#contactForm button {
  background-color: white;
  color: black;
  border: 2px solid #888;
  font-weight: bold;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}

#contactForm button:hover {
  background-color: #dd8d;
  color: white;
}

body.dark #contactForm button {
  background-color: #2a2a2a;
  color: #f0f0f0;
  border: 2px solid #888;
}

body.dark #contactForm button:hover {
  background-color: #dd8d;
  color: white;
}

#contactStatus {
  font-size: 0.95rem;
  font-weight: 500;
}

/* Dark mode overrides */
body.dark .page-wrapper-2 {
  background-color: #1e1e1e;
}

body.dark #contactForm input,
body.dark #contactForm textarea {
  background-color: #2a2a2a;
  color: #fff;
  border-color: #444;
}

body.dark #contactForm label {
  color: #ccc;
}

body.dark #contactStatus {
  color: #ccc;
}

.captcha-and-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem; /* Even vertical spacing between captcha and button */
  margin-top: 1rem;
  width: 100%;
}

.captcha-wrapper {
  display: inline-block;
}

#errorDisplay {
  display: none; /* Start hidden */
  color: red;
  font-weight: bold;
  margin-bottom: 1rem;
  padding: 0.5rem;
  border: 1px solid red;
  background-color: #ffe6e6;
  border-radius: 4px;
  opacity: 1;
  transition: opacity 0.5s ease;
}

body.dark #errorDisplay {
  background-color: #440000;
  color: #ffcccc;
  border-color: #aa0000;
}

#invoiceForm {
  width: 100%;        /* Take up all the container width */
  height: 100%;
  max-width: 100%;    /* Don't let it grow beyond container */
  box-sizing: border-box; /* Include padding/borders in width calc */
}
