/* CSS Variables for consistent theming */
:root {
  --bg-color: #1a1e28; /* Very dark blue-gray */
  --card-bg: #282d3a; /* Dark blue-gray for cards */
  --text-color: #e0e6ed; /* Light blue-gray text */
  --primary-color: #6a82a0; /* Muted, slightly desaturated blue */
  --secondary-color: #b33939; /* Deeper, more sophisticated red */
  --accent-color: #e65c5c; /* A slightly brighter, but still soft red for highlights */
  --border-color: #40485a; /* Darker border */
  --input-bg: #323846; /* Darker input background */
  --input-text: #e0e6ed; /* Light input text */
  --button-hover: #5a6e88; /* Darker primary for hover */
  --danger-color: #d64545; /* Standard danger red */
  --danger-hover: #c23b3b; /* Darker danger red */
  --shadow: rgba(0, 0, 0, 0.6); /* Slightly stronger shadow for depth */
  --tab-inactive-bg: #212631; /* Even darker for inactive tabs */
  --tab-border: #40485a; /* Consistent with main border */
  --sub-tab-bg: #323846; /* Consistent with input background */
  --sub-tab-border: #505a6e; /* Slightly lighter sub-tab border */
  --sub-tab-active-bg: #282d3a; /* Consistent with card background */
}

/* Base body styling */
body {
  font-family: 'Montserrat', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  box-sizing: border-box;
}

.container {
  background-color: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 8px 20px var(--shadow);
  padding: 30px;
  width: 100%;
  max-width: 800px;
  box-sizing: border-box;
}

h1, h2, h3 {
  color: var(--primary-color);
  text-align: center;
  margin-bottom: 25px;
  font-weight: 700; /* Increased font-weight */
}

h1 {
  font-size: 2.4em; /* Slightly larger */
  margin-bottom: 30px;
}

h2 {
  font-size: 2em; /* Slightly larger */
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  margin-top: 30px;
  margin-bottom: 20px;
}

h3 {
  font-size: 1.5em; /* Slightly larger */
  color: var(--text-color);
  margin-top: 20px;
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-color);
  font-weight: 600; /* Increased font-weight */
  font-size: 0.95em;
}

input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea { /* Added textarea */
  width: calc(100% - 20px);
  padding: 12px 10px;
  margin-bottom: 15px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--input-bg);
  color: var(--input-text);
  font-family: 'Montserrat', sans-serif;
  font-size: 1em;
  box-sizing: border-box;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus { /* Added textarea */
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(106, 130, 160, 0.3); /* Use primary color for focus shadow */
  outline: none;
}

/* Error styling for inputs */
input.error, select.error, textarea.error { /* Added textarea */
  border-color: var(--danger-color);
  box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.3); /* Use danger color for error shadow */
}

button {
  background-color: var(--primary-color);
  color: #ffffff; /* White text for buttons */
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease; /* Added box-shadow transition */
  box-shadow: 0 4px 8px var(--shadow); /* Use variable for shadow */
  margin-top: 10px;
}

button:hover {
  background-color: var(--button-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35); /* Slightly stronger shadow on hover */
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.danger-button {
  background-color: var(--danger-color);
}

.danger-button:hover {
  background-color: var(--danger-hover);
}

.tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 25px;
  border-bottom: 2px solid var(--tab-border);
  flex-wrap: wrap; /* Allow tabs to wrap on smaller screens */
  gap: 5px; /* Gap between tabs */
}

.tab-button {
  background: linear-gradient(145deg, var(--tab-inactive-bg), #1e222d); /* Subtle gradient */
  color: var(--text-color);
  padding: 12px 20px;
  border: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  transition: all 0.3s ease; /* Smooth transition for all properties */
  flex-grow: 1; /* Allow tabs to grow and fill space */
  text-align: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* Subtle shadow */
  position: relative;
  overflow: hidden; /* For pseudo-elements */
}

.tab-button:before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.05); /* Light overlay */
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

.tab-button:hover:not(.active):before {
  transform: scaleX(1);
}

.tab-button.active {
  background: var(--card-bg); /* Solid background for active tab */
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); /* More prominent shadow for active */
  z-index: 1; /* Bring active tab to front */
  transform: translateY(-2px); /* Slightly lift active tab */
}

.tab-button:hover:not(.active) {
  background-color: var(--input-bg); /* Darker hover for inactive */
  color: var(--accent-color); /* Change text color on hover */
}

.tab-content {
  display: none;
  padding: 20px 0;
}

.tab-content.active {
  display: block;
}

.sub-tabs {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--sub-tab-border);
  padding-bottom: 5px;
  overflow-x: auto; /* Enable horizontal scrolling for many sub-tabs */
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  flex-wrap: wrap; /* Allow sub-tabs to wrap */
  gap: 5px; /* Gap between sub-tabs */
}

.sub-tab-button {
  background-color: var(--sub-tab-bg);
  color: var(--text-color);
  padding: 8px 15px;
  border: 1px solid var(--sub-tab-border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 400;
  transition: all 0.3s ease; /* Smooth transition for all properties */
  white-space: nowrap; /* Prevent text wrapping */
  flex-grow: 1; /* Allow sub-tabs to grow */
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}

.sub-tab-button.active {
  background-color: var(--sub-tab-active-bg);
  color: var(--secondary-color);
  border-color: var(--secondary-color);
  font-weight: 500;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* More prominent shadow for active */
  transform: translateY(-1px); /* Slightly lift active sub-tab */
}

.sub-tab-button:hover:not(.active) {
  background-color: var(--input-bg);
  color: var(--accent-color); /* Change text color on hover */
}

.print-entry {
  background-color: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  position: relative;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Lighter shadow */
}

.remove-btn {
  background-color: var(--danger-color);
  color: white;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.2em;
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 0;
  line-height: 1;
  box-shadow: none;
  z-index: 1; /* Ensure it's above other content */
}

.remove-btn:hover {
  background-color: var(--danger-hover);
  transform: scale(1.1);
}

.section-divider {
  border-top: 1px dashed var(--border-color);
  padding-top: 20px;
  margin-top: 20px;
}

.section-divider h2 {
  margin-top: 0;
  margin-bottom: 15px;
  padding-bottom: 0;
  border-bottom: none;
  font-size: 1.5em;
  text-align: left;
}

.logo-upload-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap; /* Allow wrapping */
}

.logo-upload-group input[type="file"] {
  display: none; /* Hide default file input */
}

.custom-file-upload {
  background-color: var(--secondary-color);
  color: #ffffff; /* White text for buttons */
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 600;
  transition: background-color 0.3s ease;
  flex-shrink: 0; /* Prevent shrinking */
}

.custom-file-upload:hover {
  background-color: #a52a22; /* Darker shade of new secondary */
}

.logo-upload-group button {
  margin-top: 0;
  padding: 10px 15px;
  font-size: 0.9em;
  flex-shrink: 0;
}

.logo-preview-container {
  margin-top: 15px;
  margin-bottom: 20px;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
  background-color: rgba(0, 0, 0, 0.05); /* Lighter background */
}

.logo-preview-img {
  max-width: 100%;
  max-height: 150px; /* Limit height for preview */
  display: none; /* Hidden by default */
  border-radius: 4px;
}

.global-actions {
  background-color: var(--card-bg);
  border-radius: 12px; /* Rounded corners on all sides */
  box-shadow: 0 4px 10px var(--shadow); /* Standard shadow */
  padding: 20px;
  width: 100%;
  max-width: 800px;
  position: relative; /* Changed from fixed to relative */
  margin-top: 30px; /* Add margin to separate from content above */
  margin-bottom: 20px; /* Add margin below if needed */
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1; /* Adjust z-index if needed, no longer fixed */
  box-sizing: border-box;
}

.global-actions h2 {
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.6em;
  border-bottom: none;
  padding-bottom: 0;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  width: 100%;
}

.button-group button {
  flex-grow: 1;
  min-width: 150px;
  max-width: 250px;
  margin: 0; /* Override default button margin */
}

/* Invoice Output Styles */
#invoice-output-content {
  background-color: #ffffff; /* White background for print */
  color: #333333; /* Dark text for readability */
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  font-family: 'Montserrat', sans-serif;
  line-height: 1.6;
  max-width: 800px;
  margin: 0 auto;
  box-sizing: border-box;
}

#invoice-output-content h2 {
  color: #2c3e50;
  text-align: center;
  margin-bottom: 25px;
  font-size: 2em;
  border-bottom: 2px solid #eeeeee;
  padding-bottom: 10px;
}

#invoice-output-content .invoice-placeholder-message {
  text-align: center;
  color: #777;
  font-style: italic;
  padding: 50px 20px;
  background-color: #f8f8f8;
  border-radius: 8px;
  border: 1px dashed #ccc;
}

#invoice-output-content .invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 20px;
}

#invoice-output-content .company-info,
#invoice-output-content .invoice-info {
  flex: 1;
  min-width: 250px;
}

#invoice-output-content .company-info {
  text-align: left;
}

#invoice-output-content .invoice-info {
  text-align: right;
}

#invoice-output-content .invoice-logo {
  max-width: 150px;
  max-height: 100px;
  margin-bottom: 10px;
  border-radius: 4px;
}

#invoice-output-content .invoice-header p {
  margin: 5px 0;
  font-size: 0.95em;
}

#invoice-output-content .invoice-header strong {
  color: #444;
}

#invoice-output-content .invoice-items {
  margin-top: 20px;
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
}

#invoice-output-content .invoice-item-group-header {
  display: flex;
  justify-content: space-between;
  background-color: #f0f0f0;
  padding: 12px 20px;
  font-weight: 600;
  border-bottom: 1px solid #e0e0e0;
  color: #333;
}

/* Added for right alignment in invoice header */
.text-right {
    text-align: right;
}

#invoice-output-content .invoice-item-group {
  padding: 15px 20px;
  border-bottom: 1px solid #f5f5f5;
}

#invoice-output-content .invoice-item-group:last-child {
  border-bottom: none;
}

#invoice-output-content .invoice-item-group h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #2c3e50;
  font-size: 1.1em;
  text-align: left;
}

#invoice-output-content .invoice-item-detail {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 0.9em;
}

#invoice-output-content .invoice-item-detail .detail-label {
  color: #555;
}

#invoice-output-content .invoice-item-detail .detail-value {
  font-weight: 500;
  color: #333;
}

#invoice-output-content .invoice-item-subtotal {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #eee;
  font-size: 0.95em;
  color: #2c3e50;
}

#invoice-output-content .invoice-summary {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed #eee;
  font-size: 0.95em;
}

#invoice-output-content .invoice-summary:last-of-type {
  border-bottom: none;
}

#invoice-output-content .invoice-summary p {
  margin: 0;
}

#invoice-output-content .invoice-total {
  text-align: right;
  font-size: 1.5em;
  font-weight: 700;
  margin-top: 25px;
  padding-top: 15px;
  border-top: 2px solid #e0e0e0;
  color: #2c3e50;
}

#invoice-output-content .final-price-value {
  color: var(--primary-color);
}

.invoice-disclaimer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed #eee;
    font-size: 0.85em;
    color: #666;
    text-align: center;
    font-style: italic;
}

.message-box-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.message-box-overlay.show {
  opacity: 1;
  visibility: visible;
}

.message-box {
  background-color: var(--card-bg);
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 8px 25px var(--shadow);
  max-width: 450px;
  text-align: center;
  transform: translateY(-20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.message-box-overlay.show .message-box {
  transform: translateY(0);
  opacity: 1;
}

.message-box h3 {
  color: var(--primary-color);
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 1.5em;
}

.message-box p {
  color: var(--text-color);
  margin-bottom: 25px;
  line-height: 1.5;
}

.message-box button {
  background-color: var(--primary-color);
  color: #ffffff; /* White text for buttons */
  padding: 10px 25px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: none;
}

.message-box button:hover {
  background-color: var(--button-hover);
  transform: none;
}

.input-group.full-width {
  width: 100%;
}

.input-group.print-time-group {
  display: flex;
  gap: 15px;
  flex-wrap: wrap; /* Allow wrapping for time inputs */
}

.input-group.print-time-group > div {
  flex: 1;
  min-width: 120px; /* Ensure inputs don't get too small */
}

.header-with-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.header-with-info h2,
.header-with-info h3 {
  margin: 0;
  padding: 0;
  border: none;
  font-size: 1.5em;
  color: var(--primary-color);
}

.header-with-info .info-button {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: none;
  margin-top: 0;
}

.header-with-info .info-button:hover {
  background-color: rgba(106, 130, 160, 0.1); /* Use primary color for hover */
  transform: scale(1.05);
}

/* Filament Item Specific Styles */
.filament-items-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
  padding: 15px;
  background-color: var(--input-bg); /* Use input-bg for this inner container */
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.filament-item {
  display: flex;
  align-items: flex-end; /* Align inputs and button at the bottom */
  gap: 10px;
  background-color: var(--bg-color); /* Lighter background for individual items */
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  position: relative;
  flex-wrap: wrap; /* Allow filament items to wrap */
}

.filament-item .input-group {
  flex: 1; /* Distribute space evenly */
  margin-bottom: 0; /* Remove default margin-bottom from input-group */
  min-width: 120px; /* Ensure inputs don't get too small */
}

.filament-item .input-group label {
  margin-bottom: 5px; /* Smaller margin for labels within filament item */
  font-size: 0.85em;
}

.filament-item input,
.filament-item select {
  width: 100%; /* Ensure inputs take full width of their flex item */
  margin-bottom: 0; /* Remove default margin-bottom */
  padding: 8px 10px; /* Smaller padding */
  font-size: 0.9em;
}

.remove-filament-item-btn {
  background-color: var(--danger-color);
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1em;
  padding: 0;
  line-height: 1;
  box-shadow: none;
  margin-top: 0; /* Override default button margin */
  flex-shrink: 0; /* Prevent shrinking */
  align-self: center; /* Center vertically with inputs */
}

.remove-filament-item-btn:hover {
  background-color: var(--danger-hover);
  transform: scale(1.1);
}

.add-filament-item-btn {
  background-color: var(--secondary-color);
  color: #ffffff; /* White text for buttons */
  padding: 8px 15px;
  font-size: 0.9em;
  margin-top: 15px;
  width: auto; /* Allow button to size naturally */
  align-self: flex-start; /* Align to the left */
}

.add-filament-item-btn:hover {
  background-color: #a52a22; /* Darker secondary for hover */
}

/* Saved Invoices List Styles */
#savedInvoicesList {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px 0;
}

.saved-invoice-item {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.saved-invoice-item .invoice-details h3 {
    margin: 0 0 5px 0;
    color: var(--primary-color);
    font-size: 1.2em;
    text-align: left;
    border-bottom: none;
    padding-bottom: 0;
}

.saved-invoice-item .invoice-details p {
    margin: 3px 0;
    font-size: 0.9em;
    color: var(--text-color);
}

.saved-invoice-item .invoice-actions {
    display: flex;
    gap: 10px;
}

.saved-invoice-item .invoice-actions button {
    margin-top: 0;
    padding: 8px 15px;
    font-size: 0.9em;
    flex-shrink: 0;
}

/* Utility class to hide elements */
.hidden {
    display: none !important;
}

/* New styles for input grid layout */
.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Responsive columns */
    gap: 15px; /* Gap between grid items */
    margin-bottom: 20px;
}

.input-group.full-width {
    grid-column: 1 / -1; /* Make it span all columns */
}

/* Customer Management Section Specific Styles */
.customer-management-section {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.customer-management-section h3 {
    text-align: left;
    color: var(--secondary-color); /* Use accent color for this sub-heading */
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 10px;
}

.customer-management-section .button-group {
    justify-content: flex-start; /* Align buttons to the left */
    margin-top: 15px;
}

.customer-management-section .button-group button {
    flex-grow: 0; /* Prevent buttons from growing too much */
    min-width: unset; /* Remove min-width constraint */
    width: auto; /* Auto width based on content */
    padding: 10px 18px; /* Slightly more padding */
    font-size: 0.9em;
}

/* Styles for search and pagination in Saved Invoices tab */
.search-and-pagination-container {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background-color: var(--input-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

#invoiceSearchInput {
    flex-grow: 1; /* Allow search input to take available space */
    min-width: 200px; /* Ensure it doesn't get too small */
    margin-bottom: 0; /* Override default input margin */
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap; /* Allow buttons to wrap */
}

.pagination-controls button {
    margin-top: 0; /* Override default button margin */
    padding: 8px 15px;
    font-size: 0.9em;
}

.pagination-controls span {
    color: var(--text-color);
    font-weight: 500;
    white-space: nowrap; /* Prevent page text from wrapping */
}

/* New styles for customer search results */
.customer-search-results {
    /* Changed from relative to absolute positioning within a relative parent */
    position: absolute; /* Position absolutely to overlay other content */
    top: calc(100% + 5px); /* Position below the input, with a small gap */
    left: 0;
    width: 100%; /* Match parent width */
    max-height: 200px; /* Limit height and add scroll */
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 100; /* Ensure it appears above other elements */
    padding: 5px 0;
    /* Hide by default, shown by JS when typing */
    display: none; /* Controlled by JS based on search input */
}

/* Parent of customer search results needs relative positioning */
.customer-management-section .input-group.full-width {
    position: relative;
    margin-bottom: 0; /* Remove bottom margin to align with search results better */
}
/* Adjust margin for the input itself within this group */
.customer-management-section .input-group.full-width input {
    margin-bottom: 15px; /* Restore margin for the input itself */
}


.customer-search-item {
    padding: 10px 15px;
    cursor: pointer;
    color: var(--input-text);
    transition: background-color 0.2s ease;
    font-size: 0.95em;
    display: flex; /* Use flexbox for layout */
    justify-content: space-between; /* Space out content and button */
    align-items: center; /* Vertically align items */
}

.customer-search-item .customer-display-text {
    flex-grow: 1; /* Allow text to take up available space */
    padding-right: 10px; /* Space between text and button */
}

.customer-search-item:hover {
    background-color: var(--button-hover);
    color: #ffffff;
}

.customer-search-item.no-results {
    padding: 10px 15px;
    color: #aaa;
    font-style: italic;
    text-align: center;
    cursor: default;
}

.delete-customer-btn {
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 24px; /* Smaller button */
    height: 24px; /* Smaller button */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.9em; /* Smaller font */
    padding: 0;
    line-height: 1;
    box-shadow: none;
    margin-top: 0; /* Override default button margin */
    flex-shrink: 0; /* Prevent shrinking */
}

.delete-customer-btn:hover {
  background-color: var(--danger-hover);
  transform: scale(1.1);
}


/* Responsive Adjustments */
@media (max-width: 768px) {
  body {
    padding: 15px; /* Slightly less padding on smaller screens */
  }
  .container {
    padding: 25px;
  }
  h1 {
    font-size: 1.8em;
  }
  h2 {
    font-size: 1.5em;
  }
  .tabs {
    flex-wrap: wrap;
    justify-content: center; /* Center tabs on smaller screens */
    gap: 8px; /* Slightly larger gap for touch targets */
  }
  .tab-button {
    flex-basis: calc(50% - 8px); /* Two tabs per row */
    margin: 0; /* Remove individual margins, use gap */
    border-radius: 8px; /* Full rounded corners for stacked tabs */
    padding: 10px 15px; /* Adjust padding */
    font-size: 0.95em; /* Slightly smaller font */
  }
  .tab-button.active {
    transform: translateY(-4px); /* More pronounced lift for active tab */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4); /* Stronger shadow */
  }
  .sub-tabs {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px; /* Slightly larger gap for touch targets */
  }
  .sub-tab-button {
    flex-basis: calc(50% - 8px); /* Two sub-tabs per row */
    margin: 0; /* Remove individual margins, use gap */
    border-radius: 8px; /* Full rounded corners for stacked sub-tabs */
    padding: 8px 12px; /* Adjust padding */
    font-size: 0.85em; /* Slightly smaller font */
  }
  .sub-tab-button.active {
    transform: translateY(-2px); /* More pronounced lift for active sub-tab */
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3); /* Stronger shadow */
  }
  .global-actions {
    padding: 15px;
    position: relative; /* Ensure it's not fixed */
    transform: translateX(0); /* Remove center transform for smaller screens */
    left: auto;
    bottom: auto;
    border-radius: 12px; /* Ensure full rounding */
    margin-top: 20px; /* Add some space above */
    box-shadow: 0 4px 10px var(--shadow); /* Keep shadow */
  }
  .button-group {
    flex-direction: column; /* Stack buttons vertically */
    gap: 10px;
  }
  .button-group button {
    width: 100%; /* Full width for buttons */
    max-width: unset; /* Remove max-width constraint */
  }

  /* Invoice Output Responsive */
  #invoice-output-content {
      padding: 20px;
  }
  #invoice-output-content .invoice-header {
      flex-direction: column;
      align-items: center;
  }
  #invoice-output-content .invoice-header div {
      min-width: unset;
      text-align: center !important;
      width: 100%; /* Take full width */
  }
  /* Removed invoice-actions specific media query as global-actions now handles it */

  /* Print Entry Filament Items Responsive */
  .filament-item {
    flex-direction: column; /* Stack items vertically on small screens */
    align-items: stretch; /* Stretch items to fill width */
  }
  .filament-item .input-group {
    width: 100%; /* Full width for input groups */
  }
  .remove-filament-item-btn {
    position: absolute; /* Position remove button top-right */
    top: 5px;
    right: 5px;
  }

  /* Saved Invoice Item Responsive */
  .saved-invoice-item {
      flex-direction: column;
      align-items: flex-start;
  }
  .saved-invoice-item .invoice-details {
      width: 100%;
      text-align: left;
  }
  .saved-invoice-item .invoice-actions {
      width: 100%;
      justify-content: flex-start;
  }

  /* Input Grid for smaller screens */
  .input-grid {
    grid-template-columns: 1fr; /* Single column on small screens */
  }

  /* Search and Pagination Responsive */
  .search-and-pagination-container {
    flex-direction: column; /* Stack search and pagination vertically */
    align-items: stretch; /* Stretch items */
  }
  #invoiceSearchInput {
    width: 100%; /* Full width for search input */
  }
  .pagination-controls {
    width: 100%; /* Full width for pagination controls */
    justify-content: center; /* Center pagination buttons */
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px; /* Even less padding on very small screens */
  }
  .container {
    padding: 15px;
  }
  h1 {
    font-size: 1.6em;
  }
  h2 {
    font-size: 1.3em;
  }
  .tabs {
    gap: 5px; /* Smaller gap for very small screens */
  }
  .tab-button {
    flex-basis: 100%; /* One tab per row */
    font-size: 0.9em;
    padding: 10px 12px;
  }
  .sub-tabs {
    gap: 5px; /* Smaller gap for very small screens */
  }
  .sub-tab-button {
    flex-basis: 100%; /* One sub-tab per row */
    font-size: 0.8em;
    padding: 8px 10px;
  }
  /* Button group already handled by 768px query for full width */

  /* Invoice Output Specifics for very small screens */
  #invoice-output-content .invoice-item-detail .detail-label {
      text-align: left; /* Reset alignment for header */
  }
  #invoice-output-content .invoice-item-detail .detail-value {
      text-align: left; /* Align value left below label */
  }
  #invoice-output-content .invoice-item-subtotal {
      flex-direction: column; /* Stack subtotal label and value */
      align-items: flex-start;
  }
}

/* Styles for headers within the About tab */
#aboutTab h3,
#aboutTab h4 {
  color: var(--secondary-color); /* Use secondary color for these headers */
  text-align: left; /* Align these headers to the left */
  margin-top: 25px; /* Add some top margin */
  margin-bottom: 10px; /* Add some bottom margin */
  border-bottom: 1px solid var(--border-color); /* Add a subtle border */
  padding-bottom: 5px; /* Padding below the border */
}

#aboutTab h2 {
  color: var(--primary-color); /* Keep main H2 primary color */
}

/* Styles to make the invoice output content look like the print version on screen */
#invoice-output-content.invoice-display-mode-styles {
  background-color: #ffffff; /* White background */
  color: #000000; /* Black text */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* Keep shadow for screen */
  border-radius: 8px; /* Keep rounded corners for screen */
  font-family: 'Roboto Mono', monospace; /* Use monospace for invoice details */
  font-size: 10pt; /* A good base font size */
  line-height: 1.4;
  padding: 30px; /* Standard padding for screen display */
}

#invoice-output-content.invoice-display-mode-styles .invoice-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: nowrap;
}

#invoice-output-content.invoice-display-mode-styles .invoice-header-top .company-info {
    flex: 1;
    text-align: left;
    padding-right: 10mm;
}

#invoice-output-content.invoice-display-mode-styles .invoice-header-top .invoice-title-and-customer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#invoice-output-content.invoice-display-mode-styles .invoice-main-title {
    text-align: right;
    font-size: 2em;
    color: #2c3e50;
    margin-bottom: 5px;
    width: 100%;
}

#invoice-output-content.invoice-display-mode-styles .invoice-info {
    text-align: right;
    padding-left: 10mm;
    width: 100%;
}

#invoice-output-content.invoice-display-mode-styles .invoice-info p {
    margin: 2px 0;
    font-size: 0.9em;
}

#invoice-output-content.invoice-display-mode-styles .bill-to-label {
    margin-top: 10px;
    margin-bottom: 2px;
}

#invoice-output-content.invoice-display-mode-styles .invoice-logo {
    max-width: 100px;
    max-height: 70px;
    margin-bottom: 10px;
}

#invoice-output-content.invoice-display-mode-styles p,
#invoice-output-content.invoice-display-mode-styles li,
#invoice-output-content.invoice-display-mode-styles .invoice-item-detail,
#invoice-output-content.invoice-display-mode-styles .invoice-item-subtotal,
#invoice-output-content.invoice-display-mode-styles .invoice-summary p {
    font-size: 0.9em;
    line-height: 1.3;
}

#invoice-output-content.invoice-display-mode-styles .invoice-item-group-header {
    padding: 8px 10px;
    font-size: 0.9em;
}

#invoice-output-content.invoice-display-mode-styles .invoice-item-group {
    padding: 10px 10px;
}

#invoice-output-content.invoice-display-mode-styles .invoice-item-group h3 {
    font-size: 1.05em;
}

#invoice-output-content.invoice-display-mode-styles .invoice-total {
    font-size: 1.3em;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

#invoice-output-content.invoice-display-mode-styles .invoice-summary {
    border-bottom: none;
    padding: 2px 0;
    margin-bottom: 0;
}

#invoice-output-content.invoice-display-mode-styles .invoice-summary-section {
    margin-top: 15px;
    padding-top: 10px;
    border-top: none;
}


/* Print-specific styles to ensure only invoice content is printed */
@media print {
  /* Define page size and margins for A4 */
  @page {
    size: A4;
    margin: 10mm; /* Reduced margins for more content space */
  }

  /* Hide everything in the body by default */
  body {
    visibility: hidden;
    overflow: hidden; /* Hide scrollbars during print */
  }

  /* Make the invoice output content visible and apply display mode styles */
  #invoice-output-content {
    visibility: visible;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto;
    margin: 0;
    padding: 10mm; /* Apply padding here for the invoice content */
    background-color: #ffffff; /* Ensure white background */
    color: #000000; /* Ensure black text */
    box-shadow: none; /* No shadow on print */
    border-radius: 0; /* No border-radius on print */
    font-family: 'Roboto Mono', monospace; /* Use monospace for invoice details */
    font-size: 10pt; /* A good base font size for print */
    line-height: 1.4;
  }

  /* Ensure all children of invoice-output-content are also visible */
  #invoice-output-content * {
    visibility: visible;
    color: inherit; /* Inherit color from parent */
    background-color: inherit; /* Inherit background from parent */
  }

  /* Print-specific overrides for layout that might differ slightly or need !important */
  .invoice-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px !important;
    flex-wrap: nowrap !important;
  }

  .invoice-header-top .company-info {
    flex: 1;
    text-align: left !important;
    padding-right: 10mm !important;
  }

  .invoice-header-top .invoice-title-and-customer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end !important;
  }

  .invoice-main-title {
    text-align: right !important;
    font-size: 2em !important;
    color: #2c3e50 !important;
    margin-bottom: 5px !important;
    width: 100% !important;
  }

  #invoice-output-content .invoice-info {
    text-align: right !important;
    padding-left: 10mm !important;
    width: 100% !important;
  }

  #invoice-output-content .invoice-info p {
    margin: 2px 0 !important;
    font-size: 0.9em !important;
  }

  .bill-to-label {
    margin-top: 10px !important;
    margin-bottom: 2px !important;
  }

  #invoice-output-content .invoice-logo {
    max-width: 100px !important;
    max-height: 70px !important;
    margin-bottom: 10px !important;
  }

  #invoice-output-content p,
  #invoice-output-content li,
  #invoice-output-content .invoice-item-detail,
  #invoice-output-content .invoice-item-subtotal,
  #invoice-output-content .invoice-summary p {
    font-size: 0.9em !important;
    line-height: 1.3 !important;
  }

  #invoice-output-content .invoice-item-group-header {
    padding: 8px 10px !important;
    font-size: 0.9em !important;
  }

  #invoice-output-content .invoice-item-group {
    padding: 10px 10px !important;
  }

  #invoice-output-content .invoice-item-group h3 {
    font-size: 1.05em !important;
  }

  #invoice-output-content .invoice-total {
    font-size: 1.3em !important;
    margin-top: 20px !important;
    padding-top: 10px !important;
    border-top: 1px solid #e0e0e0 !important;
  }

  /* Remove borders from invoice summary items */
  #invoice-output-content .invoice-summary {
    border-bottom: none !important;
    padding: 2px 0 !important;
    margin-bottom: 0 !important;
  }

  #invoice-output-content .invoice-summary-section {
    margin-top: 15px !important;
    padding-top: 10px !important;
    border-top: none !important;
  }

  /* Page break control */
  .invoice-item-group,
  .invoice-summary {
    page-break-inside: avoid !important;
  }

  #invoice-output-content h2,
  #invoice-output-content .invoice-header {
    page-break-after: avoid !important;
  }

  html, body {
    height: auto !important;
    overflow: visible !important;
  }
}
