/* ===== BUTTON COMPONENTS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
  min-height: 44px; /* Touch-friendly */
}

.btn:focus {
  outline: 2px solid var(--electric-blue);
  outline-offset: 2px;
}

/* Button Sizes */
.btn-small {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  min-height: 36px;
}

.btn-large {
  padding: var(--space-4) var(--space-8);
  font-size: var(--font-size-base);
  min-height: 56px;
}

.btn-full {
  width: 100%;
}

/* Button Variants */
.btn-primary {
  background: linear-gradient(135deg, var(--electric-blue) 0%, var(--accent-orange) 100%);
  color: var(--white);
  border-color: var(--electric-blue);
  font-weight: var(--font-weight-semibold);
  box-shadow: 0 4px 20px rgba(0, 102, 255, 0.4);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-orange) 0%, var(--electric-blue) 100%);
  border-color: var(--accent-orange);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(255, 107, 53, 0.4);
}

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

.btn-outline {
  background: transparent;
  color: var(--electric-blue);
  border-color: var(--electric-blue);
}

.btn-outline:hover {
  background: var(--electric-blue);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

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

.btn-success:hover {
  background: #38a169;
  border-color: #38a169;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-warning {
  background: var(--warning-yellow);
  color: var(--gray-900);
  border-color: var(--warning-yellow);
}

.btn-warning:hover {
  background: #ecc94b;
  border-color: #ecc94b;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

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

.btn-danger:hover {
  background: #c53030;
  border-color: #c53030;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

/* Disabled State */
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ===== CARD COMPONENTS ===== */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-base);
}

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

.card-header {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--gray-200);
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--gray-900);
  margin-bottom: var(--space-2);
}

.card-subtitle {
  color: var(--gray-600);
  font-size: var(--font-size-sm);
}

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

.card-footer {
  padding-top: var(--space-4);
  border-top: 1px solid var(--gray-200);
}

/* ===== BADGE COMPONENTS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

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

.badge-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

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

.badge-warning {
  background: var(--warning-yellow);
  color: var(--gray-900);
}

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

.badge-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

/* ===== FORM COMPONENTS ===== */
.form-group {
  margin-bottom: var(--space-6);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  background: var(--white);
  transition: var(--transition-base);
  min-height: 44px; /* Touch-friendly */
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--electric-blue);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.form-input.error,
.form-textarea.error,
.form-select.error {
  border-color: var(--error-red);
}

.form-input.success,
.form-textarea.success,
.form-select.success {
  border-color: var(--success-green);
}

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

.form-help {
  font-size: var(--font-size-xs);
  color: var(--gray-500);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--font-size-xs);
  color: var(--error-red);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.form-success {
  font-size: var(--font-size-xs);
  color: var(--success-green);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* Checkbox and Radio */
.form-checkbox,
.form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.form-checkbox input,
.form-radio input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.form-checkbox label,
.form-radio label {
  font-size: var(--font-size-sm);
  color: var(--gray-700);
  cursor: pointer;
  margin-bottom: 0;
}

/* ===== ALERT COMPONENTS ===== */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.alert-success {
  background: #f0fff4;
  border: 1px solid #9ae6b4;
  color: #276749;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #f6e05e;
  color: #744210;
}

.alert-error {
  background: #fed7d7;
  border: 1px solid #feb2b2;
  color: #742a2a;
}

.alert-info {
  background: #ebf8ff;
  border: 1px solid #90cdf4;
  color: #2a4365;
}

.alert-icon {
  font-size: var(--font-size-lg);
  margin-top: 2px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-1);
}

.alert-message {
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* ===== LOADING COMPONENTS ===== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-300);
  border-radius: var(--radius-full);
  border-top-color: var(--electric-blue);
  animation: spin 1s ease-in-out infinite;
}

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

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

.loading-dots {
  display: inline-flex;
  gap: var(--space-1);
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--electric-blue);
  animation: pulse 1.4s ease-in-out infinite both;
}

.loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  40% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* ===== MODAL COMPONENTS ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: var(--space-4);
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--gray-500);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: var(--transition-colors);
}

.modal-close:hover {
  color: var(--gray-700);
  background: var(--gray-100);
}

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

.modal-footer {
  padding: var(--space-6);
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ===== TOOLTIP COMPONENTS ===== */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip-content {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: var(--white);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  white-space: nowrap;
  z-index: 1000;
  transition: var(--transition-base);
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--gray-900);
}

.tooltip:hover .tooltip-content {
  visibility: visible;
  opacity: 1;
}

/* ===== DROPDOWN COMPONENTS ===== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 1000;
  padding: var(--space-2) 0;
}

.dropdown.active .dropdown-content {
  display: block;
}

.dropdown-item {
  display: block;
  padding: var(--space-3) var(--space-4);
  color: var(--gray-700);
  text-decoration: none;
  transition: var(--transition-colors);
}

.dropdown-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.dropdown-divider {
  height: 1px;
  background: var(--gray-200);
  margin: var(--space-2) 0;
}

/* ===== PROGRESS COMPONENTS ===== */
.progress {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--electric-blue);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-bar.success {
  background: var(--success-green);
}

.progress-bar.warning {
  background: var(--warning-yellow);
}

.progress-bar.danger {
  background: var(--error-red);
}

/* ===== AVATAR COMPONENTS ===== */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  font-weight: var(--font-weight-medium);
  color: var(--gray-700);
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: var(--font-size-xs);
}

.avatar-md {
  width: 40px;
  height: 40px;
  font-size: var(--font-size-sm);
}

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

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

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}