/*
 * Global styles for the rental bill application.  The design focuses on
 * clarity and ease of use, taking cues from the sample bill provided by
 * the user.  Elements are grouped logically with generous spacing and
 * neutral colours.  Thai fonts are not explicitly specified; the
 * browser will choose an appropriate default font for Thai text.
 */

body {
  margin: 0;
  padding: 0;
  font-family: 'Noto Sans Thai', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: #f9f9f9;
  color: #333;
}

header {
  background: #4a76a8;
  color: #fff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

header nav a {
  color: #fff;
  text-decoration: none;
  margin-left: 1rem;
  font-size: 0.9rem;
}

header nav a:hover {
  text-decoration: underline;
}

main {
  padding: 1rem 2rem;
}

/* Home page */
.home {
  text-align: center;
  margin-top: 3rem;
}

.home-buttons {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.button {
  display: inline-block;
  background: #4a76a8;
  color: #fff;
  padding: 1rem 2rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 1.2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: background 0.2s ease;
}

.button:hover {
  background: #395c84;
}

/* Create page layout: stack preview above form */
.create-page {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-section h2,
.preview-section h2 {
  margin-top: 0;
}

/* Tidy form */
form label {
  display: block;
  margin-bottom: 0.75rem;
}

form label span {
  display: inline-block;
  min-width: 150px;
  vertical-align: top;
}

form input[type="text"],
form input[type="number"],
form input[type="month"],
form input[type="date"],
form textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
  background: #fff;
}

form textarea {
  height: 70px;
  resize: vertical;
}

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

form .button-group button {
  flex: 1;
  padding: 0.7rem 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.07);
}

form .button-group button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

form .button-primary { background: #2563eb; }
form .button-secondary { background: #6b7280; }

/* Invoice preview styling */
.invoice {
  border: 1px solid #e5e7eb;
  padding: 1rem 1.25rem;
  background: #fff;
  max-width: 720px;
  margin: 0 auto;
  font-size: 0.95rem;
  color: #333;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.07);
}
.invoice-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.invoice-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
}
.invoice-title { display: flex; flex-direction: column; }
.invoice-title h3 { margin: 0; font-size: 1.1rem; }
.invoice-title small { color: #6b7280; }

.invoice table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.invoice table thead th { background: #f3f4f6; padding: 0.4rem; border: 1px solid #e5e7eb; }

.invoice table td { padding: 0.4rem; border: 1px solid #e5e7eb; text-align: center; }

.invoice .total-row td {
  font-weight: bold;
}

.invoice .note {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.invoice .bank-info {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

/* Disabled controls appear grey */
input:disabled, select:disabled, textarea:disabled {
  background: #f3f4f6;
  color: #6b7280;
}

/* Settings: brand/logo row */
.brand-settings .logo-row { display:flex; gap:1rem; align-items:flex-end; flex-wrap:wrap; }
.brand-settings .logo-controls { flex: 2 1 260px; }
.brand-settings .logo-preview { flex: 1 1 180px; display:flex; flex-direction:column; gap:6px; }

/* Responsive tweaks */
@media (max-width: 768px) {
  header { padding: 0.8rem 1rem; }
  main { padding: 1rem; }
  .invoice { max-width: 100%; }
}

/* Dashboard styling */
.dashboard .summary-section,
.dashboard .list-section,
.dashboard .expenses-section {
  margin-bottom: 2rem;
}

/* Tabs (settings) */
.tabs { margin-top: 0.5rem; }
.tab-list { display: flex; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid #e5e7eb; }
.tab-list .tab {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-bottom: none;
  padding: 0.5rem 0.75rem;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
  cursor: pointer;
}
.tab-list .tab.active {
  background: #fff;
  color: #111827;
  box-shadow: 0 -1px 0 0 #e5e7eb inset;
}
.tab-panels { border: 1px solid #e5e7eb; border-radius: 0 8px 8px 8px; padding: 1rem; background:#fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.dashboard h2 {
  margin-top: 1rem;
}

.dashboard table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.dashboard table thead th {
  background: #e0e0e0;
  padding: 0.4rem;
  border: 1px solid #999;
}

.dashboard table tbody td {
  padding: 0.4rem;
  border: 1px solid #999;
  text-align: left;
}

.dashboard canvas {
  background: #fff;
  border: 1px solid #ccc;
  margin-top: 1rem;
}

/* Expense form styling */
.expenses-section form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.expenses-section form label {
  flex: 1 1 150px;
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
}

.expenses-section form button {
  padding: 0.6rem 1rem;
  border: none;
  background: #4a76a8;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  align-self: flex-end;
}

#settingsLogoPreview {
  max-width: 160px;
  max-height: 160px;
  width: auto;
  height: auto;
  aspect-ratio: 1/1;
  border: 1px dashed #ccc;
  background: #fff;
  padding: 4px;
  object-fit: contain;
}