/*
 * 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.
 */

/*
 *= require_self
 *= require_tree .
 */

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f7fa;
  padding: 20px;
}

/* Navigation bar */
.user-nav {
  background-color: white;
  padding: 1rem;
  margin: -20px -20px 20px -20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}

.user-nav form {
  margin: 0;
  display: inline-block;
}

.user-nav button {
  background: none;
  border: none;
  color: #e53e3e;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.user-nav button:hover {
  background-color: #fff5f5;
}

/* Flash messages */
.notice, .alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  font-weight: 500;
}

.notice {
  background-color: #e6fffa;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.alert {
  background-color: #fff5f5;
  color: #e53e3e;
  border: 1px solid #fca5a5;
}

/* Main container styling */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 600;
  color: #1a202c;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.5rem;
  font-weight: 500;
  color: #2d3748;
  margin: 1.5rem 0 1rem;
}

/* Links */
a {
  color: #3182ce;
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: #2c5282;
  text-decoration: underline;
}

/* Forms */
/* Form layout */
.recommendation-form {
  max-width: 300px;
  margin: 0 auto;
}

.form-field {
  position: relative;
  margin-bottom: 1rem;
  width: 100%;
  max-width: 300px;
  /* margin: 0 auto; /* Center align the form fields */
}

/* Search input styling */
.form-field input[type="text"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  font-size: 1rem;
  /* margin: 0 auto; /* Center align the search input */
}

/* New item section */
.new-item-section {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  background-color: #f8fafc;
}

/* Form inputs */
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  max-width: 300px;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 1rem;
  transition: border-color 0.2s;
  box-sizing: border-box;
  /* margin: 0 auto; /* Center align the form inputs */
}

/* Style labels consistently */
.form-field label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #1a202c;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

/* Search results dropdown */
.search-results {
  position: absolute;
  z-index: 1000;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
  left: 0;
}

.search-result {
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.search-result:hover {
  background-color: #f7fafc;
}

/* Preferences page styling */
.preferences-section {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background-color: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.preferences-section h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
  color: #1a202c;
}

.current-email {
  margin-bottom: 1.5rem;
  padding: 0.75rem;
  background-color: white;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

/* Checkbox field styling */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.checkbox-input {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.checkbox-label {
  display: inline;
  margin: 0;
  font-weight: 500;
  color: #1a202c;
  cursor: pointer;
}

/* Form inputs in preferences */
.preferences-section .form-field input[type="password"],
.preferences-section .form-field input[type="email"],
.preferences-section .form-field select {
  max-width: 100%;
  width: 100%;
}

.preferences-section .form-field {
  max-width: 100%;
}

.form-select {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 1rem;
  background-color: white;
}

.form-input {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 1rem;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

/* Form actions */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  align-items: center;
}

.form-actions input[type="submit"] {
  background-color: #3182ce;
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.form-actions input[type="submit"]:hover {
  background-color: #2c5282;
}

.form-actions a {
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  background-color: #e2e8f0;
  color: #4a5568;
  transition: background-color 0.2s;
}

.form-actions a:hover {
  background-color: #cbd5e0;
  text-decoration: none;
}

.search-result.selected {
  background-color: #e5edff;
  color: #1a365d;
  font-weight: 600;
  border-left: 2px solid #3b82f6;
}

/* Remove any animation on selection */
.search-result.selected {
  animation: none;
}

/* Accessibility improvements */
.search-result {
  position: relative;
  outline: none;
}

.search-result:focus-visible {
  box-shadow: 0 0 0 2px #3b82f6;
}

/* Search field wrapper */
.search-field-wrapper {
  position: relative;
  width: 100%;
}

/* Clear button positioning */
.search-clear-button {
  position: absolute;
  right: 8px;
  top: 50%;
  /*transform: translateY(-1%);*/
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  width: 20px;
  border-radius: 50%;
  z-index: 2;
}

.search-clear-button:hover {
  background-color: #f1f5f9;
  color: #475569;
}

.search-clear-button:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Loading state */
.search-loading {
  padding: 8px 12px;
  color: #64748b;
  font-style: italic;
}

/* No results state */
.search-no-results {
  padding: 8px 12px;
  color: #64748b;
  font-style: italic;
}

/* Keyboard shortcut hints */
.keyboard-hint {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 0.75rem;
  pointer-events: none;
}

/* Error messages */
.error-messages {
  width: 100%;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background-color: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 4px;
  box-sizing: border-box;
}

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

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

.error-messages li {
  margin: 0.25rem 0;
}

/* Page header and footer */
.page-header,
.page-footer {
  text-align: center;
  margin: 0 auto;
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 600;
  color: #1a202c;
  margin-bottom: 1.5rem;
}

.page-footer a {
  color: #3182ce;
  text-decoration: none;
  transition: color 0.2s;
}

.page-footer a:hover {
  color: #2c5282;
  text-decoration: underline;
}

/* ISBN field styling */
.isbn-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.isbn-status {
  font-size: 0.9rem;
}

.isbn-status.loading {
  color: #4a5568;
}

.isbn-status.success {
  color: #047857;
}

.isbn-status.error {
  color: #dc2626;
}

/* User search specific styling */
[data-controller="search"] {
  position: relative;
  width: 100%
  max-width: 300px;
}

[data-controller="search"] input[type="text"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  font-size: 1rem;
}

[data-controller="search"] .search-results {
  position: absolute;
  z-index: 1000;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
  left: 0;
}

/* Item search specific styling */
[data-controller="item-search"] {
  position: relative;
  width: 100%;
  max-width: 300px; /* Adjusted to 300px */
}

[data-controller="item-search"] input[type="text"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  font-size: 1rem;
}

[data-controller="item-search"] .search-results {
  position: absolute;
  z-index: 1000;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
  left: 0;
}

.search-result {
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.search-result:hover,
.search-result.selected {
  background-color: #f7fafc;
}

/* Adjust input padding to accommodate clear button */
[data-controller="search"] input[type="text"],
[data-controller="item-search"] input[type="text"] {
  padding-right: 32px;
}

.user-recommendations {
  padding: 20px;
}

.recommendations-section {
  margin-bottom: 30px;
}

.recommendations-list {
  display: grid;
  gap: 15px;
  margin-top: 10px;
}

.recommendation-item {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 15px;
}

.recommendation-date {
  color: #6c757d;
  font-size: 0.9em;
  margin-top: 5px;
}

.user-link {
  color: #0d6efd;
  text-decoration: none;
  font-weight: 500;
}

.user-link:hover {
  text-decoration: underline;
}

/* Modal styles */
.modal-backdrop {
  position: fixed !important;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 9999 !important;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: white !important;
  border-radius: 12px !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
  width: 90% !important;
  max-width: 600px !important;
  margin: 2rem !important;
  position: relative !important;
  overflow: hidden !important;
  animation: slideIn 0.2s ease-out;
}

.modal-header {
  background: #f8f9fa !important;
  padding: 1rem 1.5rem !important;
  border-bottom: 1px solid #e9ecef !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.modal-title {
  margin: 0 !important;
  font-size: 1.25rem !important;
  font-weight: 600 !important;
  color: #1a1a1a !important;
}

.modal-close {
  background: none !important;
  border: none !important;
  font-size: 1.5rem !important;
  padding: 0.5rem !important;
  cursor: pointer !important;
  color: #666 !important;
  width: 2.5rem !important;
  height: 2.5rem !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s !important;
  margin: -0.5rem -0.5rem -0.5rem auto !important;
}

.modal-close:hover {
  background-color: #f3f4f6 !important;
  color: #1a1a1a !important;
}

.modal-body {
  padding: 1.5rem !important;
  max-height: calc(100vh - 200px) !important;
  overflow-y: auto !important;
}

/* Item details styling */
.modal-body p {
  margin-bottom: 1rem !important;
  line-height: 1.5 !important;
}

.modal-body strong {
  color: #4a5568 !important;
  font-weight: 600 !important;
  display: inline-block !important;
  width: 120px !important;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

