/**
 * HK Smart Tools — Component Styles
 * Modern buttons, layered cards, interactive form controls, and search
 */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.65rem 1.35rem;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  line-height: 1.25;
  min-height: 44px;
  user-select: none;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--gradient-primary);
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 14px 0 rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  background: var(--gradient-primary-hover);
  color: #ffffff;
  box-shadow: 0 6px 20px 0 rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-medium);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  border-color: var(--primary-600);
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: var(--text-xs);
  min-height: 34px;
}

.btn-lg {
  padding: 0.85rem 1.85rem;
  font-size: var(--text-base);
  min-height: 52px;
  border-radius: var(--radius-lg);
}

.btn-block {
  width: 100%;
}

/* Form Controls & Inputs */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.form-label .optional {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 400;
}

.form-control,
.form-select {
  width: 100%;
  padding: 0.7rem 0.95rem;
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  appearance: none;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748B'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1.2em 1.2em;
  padding-right: 2.75rem;
  cursor: pointer;
}

.form-control:focus,
.form-select:focus {
  background-color: var(--bg-input-focus);
  border-color: var(--primary-600);
  box-shadow: var(--shadow-focus);
  outline: none;
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 4px var(--danger-border);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-1);
  display: none;
}

.form-error.visible {
  display: block;
}

/* Input Group with Prefix / Suffix Units */
.input-group {
  display: flex;
  position: relative;
  width: 100%;
}

.input-group .form-control {
  position: relative;
  flex: 1 1 auto;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group-addon {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-medium);
  border-left: 0;
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  user-select: none;
}

/* Generic Card */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* Modern Tool Card */
.tool-card {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: var(--space-6);
  text-decoration: none;
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  position: relative;
  height: 100%;
  box-shadow: var(--shadow-xs);
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-card-hover);
  text-decoration: none;
}

.tool-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--gradient-subtle-blue);
  border: 1px solid rgba(37, 99, 235, 0.15);
  color: var(--primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.tool-card-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2px;
}

[data-theme="dark"] .tool-card-icon {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
  color: var(--accent-400);
}

.tool-card:hover .tool-card-icon {
  transform: scale(1.08);
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: #ffffff;
}

[data-theme="dark"] .tool-card:hover .tool-card-icon {
  background: var(--primary-500);
  border-color: var(--primary-500);
  color: #ffffff;
}

.tool-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  line-height: 1.35;
  transition: color var(--transition-fast);
}

.tool-card:hover .tool-card-title {
  color: var(--primary-600);
}

[data-theme="dark"] .tool-card:hover .tool-card-title {
  color: var(--accent-400);
}

.tool-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1 1 auto;
  margin-bottom: var(--space-4);
}

.tool-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.tool-card-action {
  color: var(--primary-600);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform var(--transition-fast);
}

[data-theme="dark"] .tool-card-action {
  color: var(--accent-400);
}

.tool-card:hover .tool-card-action {
  transform: translateX(4px);
}

/* Category Card */
.category-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: var(--space-5);
  text-decoration: none;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-xs);
}

.category-card:hover {
  border-color: var(--border-card-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  text-decoration: none;
}

.category-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--gradient-subtle-blue);
  border: 1px solid rgba(37, 99, 235, 0.15);
  color: var(--primary-600);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.category-icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 2px;
}

[data-theme="dark"] .category-icon {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(59, 130, 246, 0.25);
  color: var(--accent-400);
}

.category-card:hover .category-icon {
  transform: scale(1.08);
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: #ffffff;
}

[data-theme="dark"] .category-card:hover .category-icon {
  background: var(--primary-500);
  border-color: var(--primary-500);
  color: #ffffff;
}

.category-info h3 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-1) 0;
}

.category-info p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin: 0;
}

/* Prominent Result Panel */
.result-card {
  background-color: var(--bg-surface);
  border: 2px solid var(--primary-200);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  margin-top: var(--space-6);
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .result-card {
  border-color: var(--primary-800);
}

.result-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.result-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--primary-600);
  margin: 0;
}

.result-main-value {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
  letter-spacing: -0.025em;
  margin-bottom: var(--space-2);
  word-break: break-word;
}

.result-caption {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-5);
  line-height: 1.5;
}

.result-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.result-breakdown-item {
  display: flex;
  flex-direction: column;
}

.result-breakdown-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.result-breakdown-val {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.25rem 0.7rem;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1;
}

.badge-primary {
  background-color: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
}

[data-theme="dark"] .badge-primary {
  background-color: rgba(37, 99, 235, 0.2);
  color: var(--accent-400);
  border-color: rgba(37, 99, 235, 0.4);
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-warning {
  background-color: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-danger {
  background-color: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-neutral {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.alert-info {
  background-color: var(--info-bg);
  border-color: var(--info-border);
  color: #0369a1;
}

.alert-warning {
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
  color: #92400e;
}

.alert-danger {
  background-color: var(--danger-bg);
  border-color: var(--danger-border);
  color: #991b1b;
}

/* Accordion (FAQ) */
.accordion {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-top: var(--space-4);
  background: var(--bg-surface);
}

.accordion-item {
  border-bottom: 1px solid var(--border-subtle);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  background: var(--bg-surface);
  border: none;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.accordion-trigger:hover {
  background-color: var(--bg-surface-subtle);
}

.accordion-chevron {
  transition: transform var(--transition-fast);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.accordion-trigger[aria-expanded="true"] .accordion-chevron {
  transform: rotate(180deg);
  color: var(--primary-600);
}

.accordion-content {
  padding: 0 var(--space-6) var(--space-5);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.65;
}

.accordion-content[hidden] {
  display: none;
}

/* Search Box & Dropdown Suggestions */
.search-container {
  position: relative;
  width: 100%;
  max-width: 620px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: var(--space-5);
  color: var(--primary-600);
  pointer-events: none;
  width: 22px;
  height: 22px;
}

[data-theme="dark"] .search-icon {
  color: var(--accent-400);
}

.search-input {
  width: 100%;
  height: 56px;
  padding: 0 3.2rem 0 3.4rem;
  font-size: var(--text-base);
  background-color: var(--bg-surface);
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15), 0 8px 24px -4px rgba(37, 99, 235, 0.12);
}

[data-theme="dark"] .search-input:focus {
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25), 0 8px 24px -4px rgba(0, 0, 0, 0.4);
}

.search-shortcut {
  position: absolute;
  right: var(--space-4);
  padding: 0.2rem 0.55rem;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  font-weight: 600;
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  pointer-events: none;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: 1100;
  max-height: 420px;
  overflow-y: auto;
  display: none;
  text-align: left;
}

.search-results-dropdown.visible {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color var(--transition-fast);
}

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

.search-result-item:hover,
.search-result-item.highlighted {
  background-color: var(--bg-surface-subtle);
  text-decoration: none;
}

.search-result-title {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.search-result-category {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}
