:root {
  --primary-color: #0064B3;
  --primary-dark-color: #0056b3;
  --secondary-color: #e9f2fb;
  --secondary-dark-color: #d0e0f3;
  --danger-color: #e74c3c;
  --danger-dark-color: #c0392b;
  --background-color: #f8f9fa;
  --container-bg-color: #ffffff;
  --text-color: #343a40;
  --secondary-text-color: #6c757d;
  --border-color: #dee2e6;
  --shadow-color: rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root, .app-container {
  width: 100%;
  min-height: 100vh;
}

/* --- Login View --- */
.auth-container {
    max-width: 400px;
    margin: 40px auto;
    padding: 30px;
    background: var(--container-bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 15px var(--shadow-color);
    text-align: center;
}

.auth-container h1 {
    font-size: 1.8rem;
    margin-bottom: 25px;
}

.form .input-group {
    margin-bottom: 20px;
    text-align: left;
}

.form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--secondary-text-color);
}

.form input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.button-group button {
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.button-group button:disabled {
    background-color: var(--secondary-color) !important;
    color: #a9c5e2 !important;
    cursor: not-allowed;
    border: none;
}

.button-group button:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
}

.button-group button.secondary:not(:disabled) {
    background-color: var(--container-bg-color);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}


/* --- Main App Layout & Header --- */
.main-app-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  padding: 10px 0;
  margin-bottom: 24px;
  position: relative;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1;
}

.back-button-header {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-right: 8px;
  display: flex;
  align-items: center;
}

.back-button-header svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-color);
}


.hamburger-menu {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.hamburger-menu svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-color);
}

/* --- Category Selection View --- */
.category-selection-container {
  display: grid;
  gap: 20px;
}

.category-card {
  background: var(--container-bg-color);
  border-radius: 12px;
  box-shadow: 0 4px 15px var(--shadow-color);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.category-card-icon {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.category-icon {
  width: 100%;
  height: 100%;
  display: flex;
  flex-wrap: wrap;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.category-icon.color .cmyk {
  width: 50%;
  height: 50%;
}
.category-icon.color .c { background-color: #00aef0; }
.category-icon.color .m { background-color: #ec008c; }
.category-icon.color .y { background-color: #fff200; }
.category-icon.color .k { background-color: #000000; }

.category-icon.bw .cmyk {
  width: 100%;
  height: 100%;
  background-color: #000000;
}

.category-card-actions {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-card-actions button {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.category-card-actions button.active {
  background-color: var(--primary-color);
  color: white;
}

.category-card-actions button.active:hover {
  background-color: var(--primary-dark-color);
}

.category-card-actions button.inactive {
  background-color: var(--secondary-color);
  color: #a9c5e2;
  cursor: not-allowed;
}


/* --- Model Selection View --- */
.model-filter-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.model-filter-buttons button {
  flex-grow: 1;
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  background-color: var(--container-bg-color);
  color: var(--primary-color);
}

.model-filter-buttons button.active {
  background-color: var(--primary-color);
  color: white;
}

.model-list {
  display: grid;
  gap: 20px;
}

.model-card {
  background: var(--container-bg-color);
  border-radius: 12px;
  box-shadow: 0 4px 15px var(--shadow-color);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.model-card-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.model-image {
  flex-shrink: 0;
  width: 100px;
  height: 100px;
  background-color: #e9ecef;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.model-image img, .model-image svg {
  width: 60%;
  height: 60%;
  object-fit: contain;
  color: var(--border-color);
}

.model-info {
  flex-grow: 1;
  text-align: center;
}

.model-info h2 {
  font-size: 1.25rem;
  margin-bottom: 0;
}

.model-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.model-actions button {
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  flex-grow: 1;
}

.model-actions button.active {
  background-color: var(--primary-color);
  color: white;
}

.model-actions button.active:hover {
  background-color: var(--primary-dark-color);
}

.model-actions button.inactive {
  background-color: var(--secondary-dark-color);
  color: white;
  cursor: not-allowed;
}

/* --- Code List View --- */
.code-list-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1; /* Fill available vertical space */
}

.search-bar {
  position: relative;
  margin-bottom: 24px;
  flex-shrink: 0; /* Prevent search from shrinking */
}

.search-bar input {
  width: 100%;
  padding: 14px 14px 14px 40px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background-color: var(--container-bg-color); /* Explicitly white background */
}

.search-bar svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--secondary-text-color);
  width: 20px;
  height: 20px;
}

.code-list {
  flex-grow: 1; /* Allow list to fill space */
  overflow-y: auto; /* Enable scrolling */
  display: grid;
  gap: 12px; /* Space between cards */
  padding: 2px; /* Padding to avoid shadow clipping */
  align-content: start;
}

/* Light scrollbar styling */
.code-list::-webkit-scrollbar {
  width: 8px;
}

.code-list::-webkit-scrollbar-track {
  background: transparent;
}

.code-list::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 4px;
}

.code-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--secondary-text-color);
}

.code-item {
  padding: 16px 20px;
  cursor: pointer;
  background: var(--container-bg-color);
  border-radius: 8px;
  box-shadow: 0 2px 5px var(--shadow-color);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.code-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.code-item h3 {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.code-item p {
  color: var(--secondary-text-color);
  font-size: 0.9rem;
}

/* --- Code Detail View --- */
.code-detail-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-header {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 10px;
}

.detail-card {
  background: var(--container-bg-color);
  border-radius: 12px;
  box-shadow: 0 4px 15px var(--shadow-color);
  padding: 20px;
}

.detail-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-color);
}

.detail-card p, .detail-card span {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--secondary-text-color);
}

/* --- Generic & Utility Classes --- */
.loader {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 40px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.error-message {
  color: var(--danger-color);
  margin-top: 15px;
  padding: 15px;
  background-color: rgba(231, 76, 60, 0.1);
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
}

.info-message {
  color: var(--secondary-text-color);
  margin-top: 15px;
  padding: 20px;
  background-color: #f1f3f5;
  border-radius: 8px;
  font-size: 1rem;
  text-align: center;
  line-height: 1.5;
}

/* --- Dropdown Menu --- */
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--container-bg-color);
  border-radius: 8px;
  box-shadow: 0 4px 15px var(--shadow-color);
  border: 1px solid var(--border-color);
  z-index: 1000;
  overflow: hidden;
  min-width: 180px;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-color);
  transition: background-color 0.2s ease;
}

.dropdown-menu button:hover {
  background-color: #f1f3f5;
}

.dropdown-menu button:first-child {
  border-bottom: 1px solid var(--border-color);
}