/*
    Prefix Converter - Application Styles
    Uses robonxt design system tokens and components.
    The v2 stylesheet is loaded from index.html.
*/

/*-------------------------------------------*/
/* APP LAYOUT                                */
/*-------------------------------------------*/
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

main.container {
  padding-top: var(--space-md);
  padding-bottom: var(--space-xl);
}

/*-------------------------------------------*/
/* HEADER                                    */
/*-------------------------------------------*/
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-sm);
  background-color: var(--color-surface);
  border-bottom: var(--stroke-sm) solid var(--color-border-default);
  border-radius: var(--radius-lg);
  position: sticky;
  top: 0;
  margin-top: 0;
  z-index: 10;
  transition: background-color var(--duration-medium), box-shadow var(--duration-medium), border-color var(--duration-medium);
}

@media (min-width: 640px) {
  .app-header {
    padding: var(--space-sm) var(--space-md);
  }
}

.header-brand {
  font: var(--font-h3);
  color: var(--color-text-high);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/*-------------------------------------------*/
/* FORM LAYOUT                               */
/*-------------------------------------------*/
.form-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* Form-style dropdown trigger (full-width, input-like).
   <rx-dropdown> handles open/close; this only styles the trigger button. */
rx-dropdown {
  display: block;
  width: 100%;
}

.btn-dropdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font: var(--font-body);
  padding: var(--space-xs) var(--space-sm);
  border: var(--stroke-sm) solid var(--color-border-default);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-high);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--duration-quick) var(--easing);
}

.btn-dropdown:hover {
  border-color: var(--color-text-medium);
}

.btn-dropdown:focus-visible {
  outline: none;
  border-width: var(--stroke-md);
  border-color: var(--color-border-focus);
}

.btn-dropdown .dropdown-value {
  flex: 1;
}

.btn-dropdown .material-symbols-rounded {
  font-size: 20px;
  color: var(--color-text-medium);
  transition: transform var(--duration-quick) var(--easing);
}

.btn-dropdown[aria-expanded="true"] .material-symbols-rounded {
  transform: rotate(180deg);
}

/*-------------------------------------------*/
/* BUTTON OVERRIDES                          */
/* Ensure all buttons have borders            */
/*-------------------------------------------*/
.btn,
.btn-ghost,
.btn-outline,
.btn-danger,
.btn-primary,
.btn-secondary {
  border: var(--stroke-sm) solid var(--color-border-default) !important;
  border-radius: var(--radius-md);
}

.btn:hover,
.btn-ghost:hover,
.btn-outline:hover,
.btn-danger:hover,
.btn-primary:hover,
.btn-secondary:hover {
  border-color: var(--color-text-medium) !important;
}

.btn:focus-visible,
.btn-ghost:focus-visible,
.btn-outline:focus-visible,
.btn-danger:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
  outline: none;
  border-width: var(--stroke-md) !important;
  border-color: var(--color-border-focus) !important;
}

rx-dropdown .dropdown-menu {
  width: 100%;
  max-height: 320px;
  overflow-y: auto;
}

.dropdown-item:hover,
.dropdown-item.active {
  background-color: var(--color-surface-hover);
}

.dropdown-item.active {
  font-weight: var(--font-weight-medium);
}

/*-------------------------------------------*/
/* THEME TOGGLE BUTTON                       */
/*-------------------------------------------*/
/* Show only the appropriate icon based on current theme */
[data-color-scheme="light"] #btn-toggle-theme .material-symbols-rounded:first-child {
  display: none;
  /* Hide light_mode icon in light theme */
}

[data-color-scheme="dark"] #btn-toggle-theme .material-symbols-rounded:last-of-type {
  display: none;
  /* Hide dark_mode icon in dark theme */
}

/*-------------------------------------------*/
/* CARDS & SECTIONS                          */
/*-------------------------------------------*/
.section-stack {
  display: grid;
  gap: var(--space-md);
}

.card {
  background-color: var(--color-surface);
  border: var(--stroke-sm) solid var(--color-border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-md);
  transition: box-shadow var(--duration-quick) var(--easing);
  min-width: 0;
}

.card h2 {
  margin-bottom: var(--space-sm);
}

/*-------------------------------------------*/
/* BEST FORM                                 */
/*-------------------------------------------*/
.best-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.best-field {
  flex: 1;
  font: var(--font-body);
  color: var(--color-text-high);
  background: var(--color-background);
  border: var(--stroke-sm) solid var(--color-border-default);
  border-radius: var(--radius-md);
  padding: calc(var(--space-xs) - 1px) var(--space-sm);
  line-height: var(--line-height-body);
  min-height: 40px;
  display: flex;
  align-items: center;
  white-space: normal;
  word-break: break-word;
}

#btn-copy-best {
  flex-shrink: 0;
  padding: var(--space-xs);
  min-width: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/*-------------------------------------------*/
/* TABLE                                     */
/*-------------------------------------------*/
.table-wrapper {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
}

.conversion-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font: var(--font-body);
  color: var(--color-text-high);
}

.conversion-table thead th {
  text-align: left;
  font: var(--font-label);
  color: var(--color-text-medium);
  border-bottom: var(--stroke-sm) solid var(--color-border-default);
  padding: var(--space-xs) var(--space-sm);
  background-color: var(--color-background);
  position: sticky;
  top: 0;
}

.conversion-table tbody td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: var(--stroke-sm) solid var(--color-border-default);
}

.conversion-table tbody tr {
  transition: background-color var(--duration-quick) var(--easing);
}

.conversion-table tbody tr:hover {
  background: var(--color-surface-hover);
}

.conversion-table tbody tr.row-selected {
  background: color-mix(in srgb, var(--color-primary) 10%, var(--color-background));
  font-weight: var(--font-weight-medium);
}

/*-------------------------------------------*/
/* INFO LIST                                 */
/*-------------------------------------------*/
.info-list {
  list-style: none;
  padding: 0;
  margin: var(--space-sm) 0;
  display: grid;
  gap: var(--space-xs);
}

.info-list li {
  padding-left: var(--space-md);
  position: relative;
  line-height: var(--line-height-body);
}

.info-list li::before {
  content: '•';
  position: absolute;
  left: var(--space-xs);
  color: var(--color-primary);
  font-weight: var(--font-weight-bold);
}

/*-------------------------------------------*/
/* MODAL ENHANCEMENTS                        */
/*-------------------------------------------*/
.modal-body p {
  margin-bottom: var(--space-sm);
}

.modal-body h3 {
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
}

.modal-body a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-quick) var(--easing);
}

.modal-body a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

/* Settings Modal */
.settings-container {
  display: grid;
  gap: var(--space-md);
}

.btn-settings {
  width: 100%;
  justify-content: center;
}

/*-------------------------------------------*/
/* RESPONSIVE ADJUSTMENTS                    */
/*-------------------------------------------*/
@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: var(--space-sm);
  }

  .conversion-table thead th,
  .conversion-table tbody td {
    padding: var(--space-xs);
    font-size: var(--font-size-caption);
  }
}