/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

:root {
  --brown-1: #fffbef;
  --brown-2: #dddad1;
  --brown-3: #af9c8d;
  --brown-4: #9f8c7d;
  --black: #242223;
}

body {
  font-family: "Inter", sans-serif;
  color: var(--black);
  background-color: var(--brown-1);
  margin: 0;
  padding: 0;
}

.content {
  padding: 1rem;
}

.filters {
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.filter-form .form-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  flex-wrap: nowrap;
}

.filter-form label {
  font-size: 0.85rem;
  margin: 0;
}

.filter-form select {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  min-width: 8rem;
}

.filter-form .filter-label {
  white-space: nowrap;
}

.filter-form .button-secondary {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.filter-form .filter-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: none;
  border: none;
  color: #c00;
  font-weight: 600;
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.filter-form .filter-clear:hover {
  background-color: transparent;
  text-decoration: none;
  color: #900;
}

.filter-form .filter-reset-link {
  font-size: 0.85rem;
  color: #c00;
  text-decoration: none;
  white-space: nowrap;
}

.filter-form .filter-reset-link:hover {
  color: #900;
  text-decoration: underline;
}

/* Menu bar */
header.menu-bar {
  background-color: var(--black);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.menu-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.menu-logo {
  display: flex;
  align-items: center;
  margin-right: 1rem;
}

header.menu-bar img.crown {
  width: 40px;
  height: 40px;
  display: block;
}

.menu-link {
  color: var(--brown-1);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.menu-link:hover {
  color: var(--brown-1);
  text-decoration: none;
  background-color: rgba(255, 251, 239, 0.1);
}

.menu-link.active {
  background-color: rgba(255, 251, 239, 0.15);
  color: var(--brown-1);
}

header.menu-bar .header-search {
  flex: 1;
  max-width: 600px;
  position: relative;
}

.search-form-header {
  margin: 0;
  max-width: none;
  display: flex;
  gap: 0.5rem;
}

.search-input-header {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--brown-2);
  border-radius: 20px !important;
  font-family: inherit;
  font-size: 1rem;
  background-color: white;
  box-sizing: border-box;
}

.search-input-header:focus {
  outline: none;
  border-color: var(--brown-4);
}

/* Live search dropdown */
.live-search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.5rem;
  background-color: white;
  border: 1px solid var(--brown-2);
  border-radius: 4px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-height: 500px;
  overflow-y: auto;
  z-index: 1000;
}

.live-search-results .search-results {
  margin-top: 0;
}

.live-search-results .search-result-group {
  margin-bottom: 0;
  border-bottom: 1px solid var(--brown-2);
}

.live-search-results .search-result-group:last-child {
  border-bottom: none;
}

.live-search-results .no-results {
  padding: 1rem;
  margin: 0;
}

a {
  color: var(--brown-4);
  text-decoration: none;
}

a:hover {
  color: var(--brown-3);
  text-decoration: underline;
}

/* Page header with aligned title and button */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h1 {
  margin: 0;
}

/* Primary button styling */
.button-primary {
  background-color: var(--brown-4);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s;
  display: inline-block;
}

.button-primary:hover {
  background-color: var(--brown-3);
  color: white;
  text-decoration: none;
}

footer {
  margin-top: 2rem;
  padding: 1rem;
  border-top: 1px solid var(--brown-2);
  background-color: var(--brown-1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

footer .footer-left {
  text-align: left;
}

footer .footer-right {
  text-align: right;
}

footer form {
  display: inline;
  margin: 0;
}

footer .logout-button {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  color: var(--brown-4);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}

footer .logout-button:hover {
  color: var(--brown-3);
  text-decoration: underline;
}

/* Backup Status Styles */
.backup-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
}

.backup-status .backup-icon {
  font-size: 1rem;
}

.backup-status.backup-ok {
  background-color: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

.backup-status.backup-warning {
  background-color: #fff3e0;
  color: #e65100;
  border: 1px solid #ffe0b2;
  font-weight: 600;
}

.backup-status.backup-critical {
  background-color: #ffebee;
  color: #c62828;
  border: 2px solid #ef5350;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.6rem 1rem;
  animation: pulse 2s infinite;
}

.backup-status.backup-unknown {
  background-color: #f5f5f5;
  color: #616161;
  border: 1px solid #e0e0e0;
}

@keyframes pulse {
  0%, 100% {
    border-color: #ef5350;
  }
  50% {
    border-color: #c62828;
  }
}

/* Horizontally scrollable table with sticky first column */
.table-wrapper {
  overflow-x: auto;
  position: relative;
  max-width: 100%;
}

/* Custom scrollbar styling */
.table-wrapper::-webkit-scrollbar {
  height: 12px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: var(--brown-1);
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--brown-2);
  border-radius: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--brown-3);
}

/* Firefox scrollbar styling */
.table-wrapper {
  scrollbar-width: thin;
  scrollbar-color: var(--brown-2) var(--brown-1);
}

.data-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

.data-table th,
.data-table td {
  padding: 0.5rem 1rem;
  border: 1px solid var(--brown-2);
  white-space: nowrap;
  background-color: var(--brown-1);
}

.data-table th {
  font-weight: 600;
  text-align: left;
  background-color: var(--brown-2);
}

/* Sticky first column (Name) */
.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

.data-table th:first-child {
  z-index: 3;
}

/* Right-align numeric columns */
.data-table td.numeric,
.data-table th.numeric {
  text-align: right;
}

/* Form styling */
form {
  max-width: 1400px;
}

form .form-field {
  margin-bottom: 1.5rem;
}

/* Form with sidebar layout */
.form-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.form-sidebar {
  flex: 0 0 320px;
  position: sticky;
  top: 1rem;
}

.form-main {
  flex: 1;
  min-width: 0;
}

@media (max-width: 1024px) {
  .form-with-sidebar {
    flex-direction: column;
  }

  .form-sidebar {
    position: static;
    width: 100%;
  }
}

/* Sidebar sections */
.sidebar-section {
  background-color: white;
  border: 1px solid var(--brown-2);
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.sidebar-title {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brown-4);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.sidebar-subtitle {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brown-4);
}

.button-icon {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--brown-4);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.button-icon:hover {
  background-color: var(--brown-1);
}

.client-details {
  margin: 0 0 1rem 0;
}

.field-missing {
  color: #999;
  font-style: italic;
}

.client-details dt {
  font-weight: 600;
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.client-details dt:first-child {
  margin-top: 0;
}

.client-details dd {
  margin: 0;
  font-size: 0.95rem;
}

.sidebar-link {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--brown-4);
  text-decoration: none;
  font-weight: 600;
}

.sidebar-link:hover {
  color: var(--brown-3);
  text-decoration: underline;
}

.matters-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.matters-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--brown-1);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.matters-list li:last-child {
  border-bottom: none;
}

.matters-list li a {
  font-weight: 600;
}

.matter-number {
  font-size: 0.85rem;
  color: #666;
}

.matter-remarks {
  color: #666;
}

.matters-summary {
  font-weight: 600;
  font-size: 1.1rem;
}

.no-other-matters {
  margin: 0;
  color: #666;
  font-style: italic;
  font-size: 0.9rem;
}

/* Client inline form */
.client-inline-form {
  margin: 0;
  max-width: none;
}

.form-field-compact {
  margin-bottom: 1rem;
}

.form-field-compact label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.form-field-compact input[type="text"],
.form-field-compact input[type="date"],
.form-field-compact textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--brown-2);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.inline-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.button-primary-small {
  background-color: var(--brown-4);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.button-primary-small:hover {
  background-color: var(--brown-3);
}

.button-secondary-small {
  background-color: transparent;
  color: var(--brown-4);
  border: 1px solid var(--brown-2);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.button-secondary-small:hover {
  background-color: var(--brown-1);
  border-color: var(--brown-3);
}

/* Form sections */
.form-section {
  margin-bottom: 2rem;
  background-color: white;
  border: 1px solid var(--brown-2);
  border-radius: 4px;
  padding: 1.5rem;
}

.form-section-title {
  margin: 0 0 1.5rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brown-4);
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--brown-2);
}

.form-section-content {
  margin-top: 1.5rem;
}

/* Form grid for dense layout */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 100%;
}

.form-grid .form-field {
  margin-bottom: 0;
}

.form-grid .form-field-full {
  grid-column: 1 / -1;
}

@media (min-width: 900px) {
  .form-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--black);
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="date"],
form select,
form textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--brown-2);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  background-color: white;
  color: var(--black);
  box-sizing: border-box;
}

form input[type="date"]:not(:focus):invalid,
form input[type="date"]:not(:focus):placeholder-shown {
  background-color: #fafafa;
  color: #999;
}

form input[type="date"].input-empty,
form select.input-empty {
  color: #999;
}

form input[type="date"]::-webkit-datetime-edit-text,
form input[type="date"]::-webkit-datetime-edit-month-field,
form input[type="date"]::-webkit-datetime-edit-day-field,
form input[type="date"]::-webkit-datetime-edit-year-field {
  color: inherit;
}

form input[type="text"]:focus,
form input[type="email"]:focus,
form input[type="password"]:focus,
form input[type="number"]:focus,
form input[type="date"]:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: var(--brown-4);
}

/* Modified field indicator */
form input[type="text"].input-modified,
form input[type="email"].input-modified,
form input[type="password"].input-modified,
form input[type="number"].input-modified,
form input[type="date"].input-modified,
form select.input-modified,
form textarea.input-modified {
  border-left: 4px solid var(--brown-4);
  padding-left: calc(0.75rem - 3px);
}

form input[type="checkbox"].input-modified {
  outline: 2px solid var(--brown-4);
  outline-offset: 2px;
}

/* Previous value hint */
.previous-value-hint {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.previous-value-hint em {
  font-style: italic;
}

.previous-value-text {
  flex: 1;
}

.undo-change-button {
  background: none;
  border: none;
  color: var(--brown-4);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  border-radius: 3px;
  transition: background-color 0.2s;
}

.undo-change-button:hover {
  background-color: var(--brown-1);
}

form select {
  cursor: pointer;
}

form .form-field input[type="submit"],
form .form-field button[type="submit"] {
  background-color: var(--brown-4);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

form .form-field input[type="submit"]:hover,
form .form-field button[type="submit"]:hover {
  background-color: var(--brown-3);
}

.error-messages {
  background-color: #fee;
  border: 1px solid #fcc;
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.error-messages h2 {
  color: #c00;
  font-size: 1rem;
  margin: 0 0 0.5rem 0;
}

.error-messages ul {
  margin: 0;
  padding-left: 1.5rem;
}

.error-messages li {
  color: #c00;
}

.help-text {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: #666;
}

.related-list {
  margin-top: 1rem;
  padding-left: 1.5rem;
}

/* Client search picker */
.client-picker {
  position: relative;
}

.client-search-input-wrapper {
  position: relative;
  display: flex;
  gap: 0.5rem;
}

.client-search-input-wrapper input[type="text"] {
  flex: 1;
}

.button-new-client {
  background-color: var(--brown-4);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.button-new-client:hover {
  background-color: var(--brown-3);
}

.client-search-results {
  display: none;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--brown-2);
  border-top: none;
  background-color: white;
  border-radius: 0 0 4px 4px;
  margin-top: -4px;
}

.client-search-result {
  padding: 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--brown-1);
}

.client-search-result:hover {
  background-color: var(--brown-1);
}

.client-search-result:last-child {
  border-bottom: none;
}

.client-selected {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background-color: var(--brown-1);
  border: 1px solid var(--brown-2);
  border-radius: 4px;
}

.client-selected span {
  flex: 1;
  font-weight: 600;
}

.client-deselect {
  background: none;
  border: none;
  color: #c00;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.client-deselect:hover {
  background-color: #fee;
}

.inline-client-form {
  padding: 1rem;
  background-color: var(--brown-1);
  border: 1px solid var(--brown-2);
  border-radius: 4px;
}

.inline-client-form h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.inline-client-form .form-field {
  margin-bottom: 1rem;
}

.inline-client-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.inline-client-form input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--brown-2);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  background-color: white;
  box-sizing: border-box;
}

.inline-client-form-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

.button-secondary {
  background-color: transparent;
  color: var(--brown-4);
  border: 1px solid var(--brown-2);
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.button-secondary:hover {
  background-color: var(--brown-1);
  border-color: var(--brown-3);
}

/* Action links styling */
.actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.actions a {
  color: var(--brown-4);
}

.actions button {
  background: none;
  border: none;
  color: #c00;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  text-decoration: none;
}

.actions button:hover {
  color: #900;
  text-decoration: underline;
}

.actions form {
  display: inline;
  margin: 0;
  max-width: none;
}

/* Search form styling */
.search-form {
  margin-bottom: 2rem;
  max-width: none;
}

.search-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--brown-2);
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  background-color: white;
  box-sizing: border-box;
}

.search-input:focus {
  outline: none;
  border-color: var(--brown-4);
}

.search-summary {
  margin-bottom: 1.5rem;
  color: #666;
}

.no-results {
  margin: 2rem 0;
  color: #666;
  font-style: italic;
}

/* Search results */
.search-results {
  margin-top: 2rem;
}

.search-result-group {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background-color: white;
  border: 1px solid var(--brown-2);
  border-radius: 4px;
}

.search-result-client {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.search-result-client h3 {
  margin: 0;
  font-size: 1.2rem;
}

.search-match-badge {
  background-color: var(--brown-3);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.search-result-matters {
  list-style: none;
  padding: 0;
  margin: 0;
}

.search-result-matters li {
  padding: 0.75rem;
  border-bottom: 1px solid var(--brown-1);
}

.search-result-matters li:last-child {
  border-bottom: none;
}

.search-result-matters li:hover {
  background-color: var(--brown-1);
}

.matter-date {
  color: #666;
  font-size: 0.9rem;
}

.no-matters {
  color: #666;
  font-style: italic;
  margin: 0;
}

/* Floating save bar */
.floating-save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: white;
  border-top: 3px solid var(--brown-4);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  padding: 1rem;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.floating-save-bar.hidden {
  transform: translateY(100%);
}

.floating-save-bar-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.modified-fields-message {
  font-size: 1rem;
  color: var(--black);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modified-fields-message span {
  font-weight: 700;
  color: var(--brown-4);
  font-size: 1.1rem;
}

.floating-save-button {
  background-color: var(--brown-4);
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 4px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

.floating-save-button:hover {
  background-color: var(--brown-3);
}
