/**
 * Component Styles
 */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-error {
  background: var(--color-error);
  color: white;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: auto;
  min-height: auto;
  background: transparent;
  width: auto;
  height: auto;
}

.btn-icon.btn-secondary {
  border: none;
}

.btn-icon.btn-primary {
  border: none;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-icon svg,
.btn-icon i {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cards */
.card {
  position: relative;
  background: var(--surface-glass);
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  box-shadow: var(--elevation-card);
  backdrop-filter: blur(var(--surface-blur));
  padding: var(--space-lg);
  margin-top: var(--space-lg);
  transition: all var(--transition-base);
  overflow: hidden;
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-glow);
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--elevation-card-hover);
}

.card:hover::after {
  opacity: 0.4;
}

.card-header {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.card-title {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.card-subtitle {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.card-body {
  margin-bottom: var(--space-md);
}

.card-footer {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* Forms */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-input::placeholder {
  color: var(--color-text-secondary);
}

.form-textarea {
  min-height: 100px;
  resize: vertical;
}

.form-error {
  color: var(--color-error);
  font-size: 0.875rem;
  margin-top: var(--space-xs);
}

.form-help {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-top: var(--space-xs);
}

.form-checkbox,
.form-radio {
  margin-right: var(--space-sm);
}

.link-button {
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  text-decoration: underline;
}

.link-button:hover {
  color: var(--color-primary-dark);
}

.slider-field {
  margin-top: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.slider-field input[type="range"] {
  width: 100%;
  appearance: none;
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.slider-field input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 3px solid var(--color-primary);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.slider-field input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 3px solid var(--color-primary);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.slider-field input[type="range"]:hover::-webkit-slider-thumb,
.slider-field input[type="range"]:hover::-moz-range-thumb {
  transform: scale(1.05);
}

.slider-field input[type="range"][data-active="false"] {
  opacity: 0.5;
}

.slider-value {
  margin-top: var(--space-xs);
  font-weight: 600;
  color: var(--color-text);
}

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

.form-toggle {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.form-toggle input[type="checkbox"] {
  position: relative;
  width: 20px;
  height: 20px;
  margin-top: 4px;
  margin-right: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.form-toggle input[type="checkbox"]:hover {
  border-color: var(--color-info);
}

.form-toggle input[type="checkbox"]:checked {
  background: var(--color-info);
  border-color: var(--color-info);
}

.form-toggle input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  box-sizing: border-box;
}

.form-toggle-label {
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.form-toggle-description {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-primary {
  background: var(--color-primary-light);
  color: white;
}

.badge-success {
  background: var(--color-success);
  color: white;
}

.badge-warning {
  background: var(--color-warning);
  color: white;
}

.badge-error {
  background: var(--color-error);
  color: white;
}

.badge-secondary {
  background: var(--color-border);
  color: var(--color-text);
}

/* Avatar */
.avatar {
  display: inline-block;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.5rem;
}

.avatar-xl {
  width: 96px;
  height: 96px;
  font-size: 2rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal-backdrop);
  padding: var(--space-lg);
  animation: fadeIn 0.2s ease-out;
}

.modal {
  background: var(--surface-glass-strong);
  border-radius: var(--radius-xl);
  border: 1px solid var(--surface-border-strong);
  box-shadow: var(--elevation-modal);
  backdrop-filter: blur(calc(var(--surface-blur) + 8px));
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
  overflow: hidden;
  position: relative;
}

.modal-header {
  padding: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.5rem;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.modal-body {
  padding: var(--space-xl);
}

.modal-footer {
  padding: var(--space-xl);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* Toast */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  --toast-accent: var(--color-primary);
  position: relative;
  background: var(--surface-glass);
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  box-shadow: var(--elevation-toast);
  padding: var(--space-lg);
  min-width: 320px;
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  animation: slideDown 0.3s ease-out;
  backdrop-filter: blur(calc(var(--surface-blur) - 4px));
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--toast-accent), transparent 70%);
  opacity: 0.15;
  pointer-events: none;
}

.toast::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 6px;
  background: var(--toast-accent);
  opacity: 0.9;
}

.toast-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--toast-accent), rgba(255, 255, 255, 0.2));
  color: #fff;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.toast-success { --toast-accent: var(--color-success); }
.toast-error { --toast-accent: var(--color-error); }
.toast-warning { --toast-accent: var(--color-warning); }
.toast-info { --toast-accent: var(--color-info); }

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.toast-message {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}

/* Loading */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

.loading-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(250, 250, 250, 0.75);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-xl);
  color: var(--color-text-secondary);
}

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

.empty-state-title {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
  color: var(--color-text);
}

.empty-state-message {
  margin-bottom: var(--space-lg);
}

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  z-index: var(--z-fixed);
}

.navbar-container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--color-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.navbar-menu-toggle {
  display: block;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text);
}

.navbar-nav {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(-100%);
  opacity: 0;
  transition: all var(--transition-base);
  pointer-events: none;
  list-style: none;
}

.navbar-nav.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

.nav-item {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.navbar-link {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  width: 100%;
  text-align: center;
}

.navbar-link:hover,
.navbar-link.active {
  color: var(--color-primary);
  background: rgba(216, 67, 21, 0.1);
}

.dropdown {
  gap: var(--space-xs);
}

.dropdown-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}

.dropdown-caret {
  font-size: 0.75rem;
}

.dropdown-menu {
  position: static;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: none;
  flex-direction: column;
  padding: var(--space-xs);
  margin-top: var(--space-xs);
  gap: var(--space-xs);
  z-index: var(--z-dropdown);
}

.dropdown.open .dropdown-menu {
  display: flex;
}

.dropdown-link {
  display: flex;
  width: 100%;
  justify-content: center;
}

.dropdown-action {
  width: 100%;
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.dropdown-action:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

@media (min-width: 769px) {
  .navbar-menu-toggle {
    display: none;
  }

  .navbar-nav {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: var(--space-md);
    padding: 0;
    box-shadow: none;
    transform: none;
    opacity: 1;
    pointer-events: all;
    display: flex;
    height: 100%;
  }

  .nav-item {
    width: auto;
    flex-direction: row;
    align-items: center;
    display: flex;
    height: 100%;
  }

  .navbar-link {
    width: auto;
    text-align: left;
    display: inline-flex;
    align-items: center;
  }

  .nav-item .btn {
    margin: 0;
    align-self: center;
    height: auto;
  }

  .dropdown {
    gap: 0;
    align-items: center;
  }

  .dropdown-toggle {
    width: auto;
    justify-content: flex-start;
  }

  .dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 220px;
    width: max-content;
    padding: var(--space-xs);
    margin-top: 0;
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow-lg);
  }

  .dropdown-link,
  .dropdown-action {
    justify-content: flex-start;
    text-align: left;
  }
}

/* Divider */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-lg) 0;
}

/* Stats */
.stat {
  text-align: center;
  padding: var(--space-md);
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  color: var(--color-primary);
  margin-bottom: var(--space-xs);
}

.stat-label {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Rank badge */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--gradient-primary);
  color: white;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.rank-badge-sm {
  width: 32px;
  height: 32px;
  font-size: 1rem;
}

.rank-badge-lg {
  width: 64px;
  height: 64px;
  font-size: 2rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--space-sm);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-lg);
}

.tab {
  padding: var(--space-md) var(--space-lg);
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast);
}

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

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

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
}
