/* Button Component */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow-md), 0 0 0 0 rgba(var(--primary-rgb), 0.4);
}

.btn--primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(var(--primary-rgb), 0.4);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn--secondary:hover:not(:disabled) {
  background: rgba(var(--primary-rgb), 0.1);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn--danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
}

.btn--danger:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(239, 68, 68, 0.4);
}

.btn--success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
}

.btn--success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(16, 185, 129, 0.4);
}

.btn--lg {
  padding: var(--space-lg) var(--space-xl);
  font-size: var(--text-lg);
  border-radius: var(--radius-xl);
}

.btn--sm {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
}

.btn--full {
  width: 100%;
}

.btn--icon {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
}

.btn--icon.btn--sm {
  width: 36px;
  height: 36px;
}

/* Input Component */

.input-group {
  position: relative;
  margin-bottom: var(--space-md);
}

.input-field {
  width: 100%;
  padding: var(--space-lg) var(--space-md) var(--space-sm);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: all var(--transition-fast);
}

.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.input-field::placeholder {
  color: transparent;
}

.input-label {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--text-base);
  pointer-events: none;
  transition: all var(--transition-fast);
}

.input-field:focus ~ .input-label,
.input-field:not(:placeholder-shown) ~ .input-label {
  top: var(--space-sm);
  transform: translateY(0);
  font-size: var(--text-xs);
  color: var(--primary);
}

.input-group--error .input-field {
  border-color: var(--danger);
}

.input-group--error .input-label {
  color: var(--danger);
}

.input-error {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--danger);
}

.input-hint {
  display: block;
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Select Component */

.select-field {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--text-base);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  padding-right: calc(var(--space-md) + 24px);
}

.select-field:focus {
  border-color: var(--primary);
  outline: none;
}

/* Checkbox Component */

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  cursor: pointer;
}

.checkbox-input {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  transition: all var(--transition-fast);
}

.checkbox-input:checked {
  background: var(--primary);
  border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.checkbox-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.checkbox-label a {
  color: var(--primary);
  text-decoration: underline;
}

/* Card Component */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  transition: all var(--transition-fast);
}

.card--interactive {
  cursor: pointer;
}

.card--interactive:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card--interactive:active {
  transform: translateY(0);
}

.card--selected {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.1);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.card-body {
  color: var(--text-secondary);
}

.card-footer {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* Modal Component */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
}

.modal-body {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: var(--space-lg);
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Toast Component */

#toast-container {
  position: fixed;
  top: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  width: calc(100% - var(--space-xl));
  max-width: 400px;
}

.toast {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: var(--shadow-xl);
  transform: translateY(-100%);
  opacity: 0;
  transition: all var(--transition-normal);
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.toast--success {
  border-left: 4px solid var(--success);
}

.toast--success .toast-icon {
  color: var(--success);
}

.toast--error {
  border-left: 4px solid var(--danger);
}

.toast--error .toast-icon {
  color: var(--danger);
}

.toast--warning {
  border-left: 4px solid var(--warning);
}

.toast--warning .toast-icon {
  color: var(--warning);
}

.toast--info {
  border-left: 4px solid var(--info);
}

.toast--info .toast-icon {
  color: var(--info);
}

/* Progress Bar */

.progress {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress--warning .progress-bar {
  background: linear-gradient(90deg, var(--warning), #f97316);
}

.progress--danger .progress-bar {
  background: linear-gradient(90deg, var(--danger), #f97316);
}

/* List */

.list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.list-item--interactive {
  cursor: pointer;
}

.list-item--interactive:hover {
  border-color: var(--primary);
  background: rgba(var(--primary-rgb), 0.05);
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.list-item-action {
  flex-shrink: 0;
}

/* Empty State */

.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: var(--space-lg);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-sm);
}

.empty-state-description {
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* Tabs */

.tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-xs);
  gap: var(--space-xs);
}

.tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  background: var(--primary);
  color: white;
}

/* Header */

.header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  margin-bottom: var(--space-md);
}

.header-back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: 50%;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header-back:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.header-title {
  flex: 1;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.header-action {
  color: var(--primary);
  font-weight: var(--font-medium);
  cursor: pointer;
}

/* Bottom Nav */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md);
  padding-bottom: calc(var(--safe-bottom) + var(--space-sm));
  display: flex;
  justify-content: space-around;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item .icon {
  font-size: var(--text-xl);
}

/* Floating Action Button */

.fab {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 80px);
  right: var(--space-md);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  font-size: var(--text-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xl), var(--shadow-glow);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.fab:hover {
  transform: scale(1.1);
}

.fab:active {
  transform: scale(0.95);
}

/* ===== COMPACT MODE - Small height screens (< 800px) ===== */

@media (max-height: 799px) {
  /* Buttons */
  .btn {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
  }

  .btn--lg {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-base);
  }

  /* Inputs */
  .input-group {
    margin-bottom: var(--space-sm);
  }

  .input-field {
    padding: var(--space-md) var(--space-md) var(--space-sm);
    font-size: var(--text-sm);
  }

  .select-field {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
  }

  /* Cards */
  .card {
    padding: var(--space-md);
  }

  /* Modal */
  .modal {
    padding: var(--space-lg);
  }

  .modal-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-sm);
  }

  .modal-title {
    font-size: var(--text-lg);
  }

  /* Header */
  .header {
    padding: var(--space-sm) 0;
    margin-bottom: var(--space-sm);
  }

  .header-back {
    width: 36px;
    height: 36px;
    font-size: var(--text-base);
  }

  .header-title {
    font-size: var(--text-base);
  }

  /* Section */
  .section-title {
    font-size: var(--text-base);
    margin-bottom: var(--space-sm);
  }

  /* List items */
  .list-item {
    padding: var(--space-sm) var(--space-md);
  }

  /* Empty state */
  .empty-state {
    padding: var(--space-lg) var(--space-md);
  }

  .empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
  }

  /* Avatar */
  .avatar {
    width: 40px;
    height: 40px;
    font-size: var(--text-base);
  }

  .avatar--lg {
    width: 56px;
    height: 56px;
    font-size: var(--text-lg);
  }
}
