/**
 * Dilypse Design System - Composants
 * Composants réutilisables pour l'application
 */

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

/* Shine animation on hover */
.btn::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:hover::before {
  left: 100%;
}

.btn:hover {
  transform: translateY(-2px);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn:disabled::before {
  display: none;
}

/* Button variants */
.btn-primary {
  background: linear-gradient(135deg, #0080ff 0%, #0066cc 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(0, 128, 255, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0090ff 0%, #0073e6 100%);
  box-shadow: 0 6px 20px rgba(0, 128, 255, 0.4);
}

.btn-secondary {
  background: linear-gradient(135deg, #e23d3e 0%, #c62828 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(226, 61, 62, 0.3);
}

.btn-secondary:hover {
  background: linear-gradient(135deg, #f04444 0%, #d63535 100%);
  box-shadow: 0 6px 20px rgba(226, 61, 62, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-outline {
  background: transparent;
  color: var(--dilypse-secondary);
  border: 2px solid var(--dilypse-secondary);
  box-shadow: none;
}

.btn-outline:hover {
  background: rgba(0, 128, 255, 0.05);
  border-color: #0090ff;
}

.btn-ghost {
  background: transparent;
  color: var(--dilypse-primary);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--dilypse-light);
}

/* Button sizes */
.btn-sm {
  padding: 8px 16px;
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: 16px 32px;
  font-size: var(--font-size-lg);
}

.btn-block {
  width: 100%;
}

/* Loading state */
.btn.loading {
  pointer-events: none;
  position: relative;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  top: 50%;
  left: 50%;
  margin-left: -7px;
  margin-top: -7px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn.loading > * {
  opacity: 0;
}

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

/* ============================================
   CARDS
   ============================================ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  transition: var(--transition-base);
}

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

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

.card-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  padding: var(--space-md) 0;
}

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

/* ============================================
   RADIO CARDS
   ============================================ */

.radio-group {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.radio-card {
  flex: 1;
  position: relative;
  min-width: 120px;
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card input[type="radio"] + span {
  display: block;
  padding: var(--space-md);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: var(--transition-base);
  font-weight: var(--font-weight-medium);
  background: var(--bg-card);
}

.radio-card input[type="radio"]:checked + span {
  border-color: var(--dilypse-secondary);
  background: rgba(0, 128, 255, 0.05);
  font-weight: var(--font-weight-semibold);
}

.radio-card input[type="radio"]:hover:not(:checked) + span {
  border-color: var(--border-color-hover);
  background: var(--dilypse-light);
}

.radio-card input[type="radio"]:focus + span {
  outline: 2px solid var(--dilypse-secondary);
  outline-offset: 2px;
}

/* ============================================
   VOICE SELECTOR
   ============================================ */

.voice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.voice-card {
  position: relative;
}

.voice-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.voice-content {
  position: relative;
  padding: 14px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-card);
}

.voice-card input[type="radio"]:checked ~ .voice-content {
  border-color: var(--dilypse-secondary);
  border-width: 3px;
  background: rgba(0, 128, 255, 0.08);
  box-shadow: 0 4px 12px rgba(0, 128, 255, 0.2);
  transform: translateY(-2px);
}

/* Checkmark indicator for selected voice */
.voice-card input[type="radio"]:checked ~ .voice-content::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: var(--dilypse-secondary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(0, 128, 255, 0.3);
}

.voice-card input[type="radio"]:hover:not(:checked) ~ .voice-content {
  border-color: var(--border-color-hover);
  background: var(--dilypse-light);
}

.voice-card input[type="radio"]:focus ~ .voice-content {
  outline: 2px solid var(--dilypse-secondary);
  outline-offset: 2px;
}

.voice-icon {
  font-size: 24px;
  margin-bottom: var(--space-sm);
}

.voice-content h4 {
  color: var(--dilypse-primary);
  margin-bottom: 4px;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
}

.voice-content p {
  font-size: var(--font-size-sm);
  color: var(--dilypse-gray);
  margin-bottom: var(--space-sm);
  line-height: var(--line-height-tight);
}

.voice-language {
  font-size: var(--font-size-xs);
  color: var(--dilypse-secondary);
  font-weight: var(--font-weight-semibold);
}

/* Recommended voice badge */
.voice-card.recommended .voice-content {
  border-color: var(--dilypse-success);
  background: rgba(16, 185, 129, 0.05);
}

.voice-card.recommended .voice-content::before {
  content: '⭐ Recommandé';
  position: absolute;
  top: -8px;
  right: 8px;
  background: linear-gradient(135deg, var(--dilypse-success) 0%, #059669 100%);
  color: white;
  font-size: 9px;
  font-weight: var(--font-weight-bold);
  padding: 3px 8px;
  border-radius: var(--radius-lg);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-success);
}

.voice-card.recommended input[type="radio"]:checked ~ .voice-content {
  border-color: var(--dilypse-success);
  border-width: 3px;
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  transform: translateY(-2px);
}

/* Green checkmark for recommended voice */
.voice-card.recommended input[type="radio"]:checked ~ .voice-content::after {
  background: var(--dilypse-success);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

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

.form-group.full-width {
  grid-column: 1 / -1;
}

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

.hint {
  display: block;
  font-weight: var(--font-weight-normal);
  color: var(--dilypse-gray);
  font-size: var(--font-size-sm);
  margin-top: 4px;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="time"],
textarea,
select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  transition: var(--transition-base);
  background: var(--bg-card);
  color: var(--text-primary);
}

.form-control:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
input[type="time"]:hover,
textarea:hover,
select:hover {
  border-color: var(--border-color-hover);
}

.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--dilypse-secondary);
  box-shadow: 0 0 0 3px rgba(0, 128, 255, 0.1);
}

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

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  white-space: nowrap;
}

.badge-primary {
  background: rgba(0, 128, 255, 0.1);
  color: var(--dilypse-secondary);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--dilypse-success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--dilypse-danger);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--dilypse-warning);
}

.badge-active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--dilypse-success);
}

.badge-inactive {
  background: rgba(107, 114, 128, 0.1);
  color: var(--dilypse-gray);
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border-left: 4px solid;
  margin-bottom: var(--space-md);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--dilypse-success);
  color: #065f46;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--dilypse-danger);
  color: #991b1b;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--dilypse-warning);
  color: #92400e;
}

.alert-info {
  background: rgba(0, 128, 255, 0.1);
  border-color: var(--dilypse-secondary);
  color: #1e40af;
}

/* ============================================
   LOADING / SPINNER
   ============================================ */

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--dilypse-secondary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 4, 33, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  z-index: var(--z-modal);
}

.loading-overlay p {
  color: white;
  font-weight: var(--font-weight-medium);
}

/* ============================================
   RESPONSIVE UTILITIES
   ============================================ */

@media (max-width: 1024px) {
  .voice-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .voice-grid {
    grid-template-columns: 1fr;
  }

  .radio-group {
    flex-direction: column;
  }

  .radio-card {
    min-width: 100%;
  }
}

@media (max-width: 480px) {
  .btn {
    padding: 10px 16px;
    font-size: var(--font-size-sm);
  }

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