/* ============================================
   PERFIL.CSS - Perfil de Usuario
   ProfitHustler Dark Theme v2
   ============================================ */

/* === MAIN LAYOUT === */
.perfil-main {
  padding-top: 8rem;
  padding-bottom: 4rem;
  min-height: 100vh;
}

.perfil-container {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .perfil-container {
    flex-direction: row;
  }
}

/* === SIDEBAR === */
.perfil-sidebar {
  width: 100%;
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .perfil-sidebar {
    width: 14rem;
  }
}

.sidebar-nav {
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.sidebar-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1.125rem;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.sidebar-item:hover {
  background-color: rgba(10, 10, 10, 0.5);
  color: var(--foreground);
}

.sidebar-item.active {
  background-color: rgba(10, 10, 10, 0.8);
  border-left-color: var(--primary);
  color: var(--foreground);
}

.sidebar-item.active svg {
  color: var(--primary);
}

.sidebar-item.logout {
  color: #ef4444;
}

.sidebar-item.logout:hover {
  color: #f87171;
}

.sidebar-item.logout.active {
  border-left-color: #ef4444;
}

.sidebar-item svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

/* === CONTENT === */
.perfil-content {
  flex: 1;
  min-width: 0;
}

.tab-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* === SECTION HEADER === */
.section-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--foreground);
  margin: 0;
}

.section-desc {
  color: var(--muted-foreground);
  margin: 0;
  font-size: 0.9375rem;
}

/* === PROFILE HEADER === */
.section-header-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.profile-avatar {
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--primary);
  border-radius: 50%;
}

.profile-avatar svg {
  width: 1.75rem;
  height: 1.75rem;
  color: white;
}

.profile-info h1 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--foreground);
  margin: 0;
}

.profile-info p {
  color: var(--muted-foreground);
  margin: 0.125rem 0 0;
  font-size: 0.9375rem;
}

/* === CARDS === */
.card {
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* Cards que contienen tablas - compensar padding para scroll completo */
.card > .table-wrapper {
  margin: 0 -1.5rem -1.25rem;
  width: calc(100% + 3rem);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 1.25rem;
}

.card-title svg {
  width: 1.125rem;
  height: 1.125rem;
  color: var(--primary);
}

/* === INFO ROW === */
.info-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.info-row svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--primary);
}

.info-label {
  color: var(--muted-foreground);
}

.info-value {
  color: var(--foreground);
}

/* === FORMS === */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
}

.form-group input {
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--foreground);
  background-color: var(--background);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group input::placeholder {
  color: var(--muted-foreground);
}

.form-actions {
  grid-column: 1 / -1;
  padding-top: 0.25rem;
}

/* === BUTTONS === */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-foreground);
  background-color: var(--primary);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary svg {
  width: 0.875rem;
  height: 0.875rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
  background-color: var(--secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background-color: rgba(38, 38, 38, 0.8);
  border-color: var(--border);
}

/* === EMAIL PREFS === */
.email-pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pref-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--foreground);
  font-size: 0.875rem;
}

.pref-info svg {
  width: 1.125rem;
  height: 1.125rem;
  color: var(--muted-foreground);
}

.pref-status {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.pref-hint {
  color: var(--muted-foreground);
  font-size: 0.75rem;
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 2.75rem;
  height: 1.5rem;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  transition: 0.3s;
}

.slider::before {
  position: absolute;
  content: "";
  height: 1rem;
  width: 1rem;
  left: 0.2rem;
  bottom: 0.19rem;
  background-color: var(--foreground);
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

input:checked + .slider::before {
  transform: translateX(1.25rem);
  background-color: white;
}

/* === TABLES === */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  max-width: 100%;
  width: 100%;
  display: block;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.data-table th {
  padding: 0.875rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--foreground);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tbody tr:hover {
  background-color: rgba(38, 38, 38, 0.3);
}

.sub-id {
  font-size: 0.6875rem;
  font-family: monospace;
  color: var(--muted-foreground);
}

.amount {
  font-weight: 600;
  color: var(--primary);
}

.invoice-link {
  color: var(--primary);
  text-decoration: none;
}

.invoice-link:hover {
  text-decoration: underline;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
}

.status-active,
.status-paid {
  background-color: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.status-trialing {
  background-color: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

.status-canceled,
.status-past_due {
  background-color: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.status-cancel {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.btn-cancel {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cancel:hover {
  background-color: rgba(239, 68, 68, 0.2);
}

/* === UPGRADE === */
.upgrade-banner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background-color: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-xl);
}

@media (min-width: 640px) {
  .upgrade-banner {
    flex-direction: row;
    align-items: center;
  }
}

.upgrade-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background-color: var(--primary);
  border-radius: var(--radius-lg);
  flex-shrink: 0;
}

.upgrade-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  color: white;
}

.upgrade-content {
  flex: 1;
}

.upgrade-content h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 0.25rem;
}

.upgrade-content p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.btn-upgrade {
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-foreground);
  background-color: var(--primary);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.btn-upgrade:hover {
  background-color: var(--primary-hover);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  width: 100%;
  max-width: 30rem;
  max-height: 90vh;
  overflow-y: auto;
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
}

.modal-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 1rem;
}

.modal-content > p {
  color: var(--muted-foreground);
  margin: 0 0 1.5rem;
}

.upgrade-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.upgrade-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background-color: var(--background);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.upgrade-option:hover {
  border-color: var(--border);
}

.upgrade-option.selected {
  border-color: var(--primary);
  background-color: rgba(34, 197, 94, 0.1);
}

.option-info strong {
  display: block;
  color: var(--foreground);
  margin-bottom: 0.25rem;
}

.option-info span {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.option-arrow {
  color: var(--primary);
  font-weight: 600;
}

.upgrade-preview {
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: var(--background);
  border-radius: var(--radius-lg);
}

.upgrade-preview p {
  margin: 0.25rem 0;
  color: var(--foreground);
}

.preview-total {
  font-size: 1.125rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.modal-actions button {
  flex: 1;
}

/* === AFFILIATES === */
.affiliate-code-card {
  background-color: var(--card);
  border: 1px solid var(--primary);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  text-align: center;
}

.code-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-foreground);
  margin: 0 0 0.75rem;
}

.code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.code-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  letter-spacing: 0.1em;
  color: var(--foreground);
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  background-color: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copy:hover {
  background-color: rgba(34, 197, 94, 0.2);
  border-color: var(--primary);
}

.btn-copy svg {
  width: 0.875rem;
  height: 0.875rem;
}

.copy-status {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  color: var(--primary);
  min-height: 1.25rem;
}

.affiliate-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 640px) {
  .affiliate-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--foreground);
}

.stat-pending .stat-value {
  color: #fbbf24;
}

.stat-available .stat-value {
  color: var(--primary);
}

.affiliate-info-box {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background-color: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: var(--radius-xl);
  padding: 1rem 1.25rem;
}

.affiliate-info-box .info-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.affiliate-info-box .info-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--primary);
}

.affiliate-info-box p {
  margin: 0;
  color: var(--foreground);
  font-size: 0.875rem;
  line-height: 1.5;
}

.affiliate-info-box strong {
  color: var(--primary);
}

.btn-affiliate-panel {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-foreground);
  background-color: var(--primary);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.btn-affiliate-panel:hover {
  background-color: var(--primary-hover);
}

/* === LOGOUT === */
.logout-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 3rem 2rem;
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.logout-icon {
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(239, 68, 68, 0.1);
  border-radius: 50%;
  margin-bottom: 1.5rem;
}

.logout-icon svg {
  width: 2rem;
  height: 2rem;
  color: #ef4444;
}

.logout-card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 0.5rem;
}

.logout-card p {
  color: var(--muted-foreground);
  margin: 0 0 1.5rem;
}

.btn-logout {
  padding: 0.75rem 2rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: white;
  background-color: #ef4444;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-logout:hover {
  background-color: #dc2626;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .perfil-main {
    padding-top: 7rem;
  }
  
  .section-header-profile {
    flex-direction: column;
    text-align: center;
  }
  
  .email-pref-row {
    flex-direction: column;
    align-items: flex-start;
  }
}
/* === PROMO CODE === */
.promo-hint {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin: 0 0 1rem;
}

.promo-form {
  margin: 0;
}

.promo-input-group {
  display: flex;
  gap: 0.75rem;
}

.promo-input-group input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--foreground);
  background-color: var(--background);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: border-color 0.2s ease;
}

.promo-input-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.promo-input-group input::placeholder {
  color: var(--muted-foreground);
  text-transform: none;
  letter-spacing: normal;
}

.promo-input-group .btn-primary {
  flex-shrink: 0;
}

.promo-msg {
  margin: 0.75rem 0 0;
  font-size: 0.8125rem;
  min-height: 1.25rem;
}

.promo-msg.success {
  color: var(--primary);
}

.promo-msg.error {
  color: #ef4444;
}
/* === AFFILIATE JOIN CTA (No afiliado) === */
.affiliate-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--muted-foreground);
  gap: 1rem;
}

.affiliate-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.affiliate-join-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2.5rem 2rem;
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.affiliate-join-card .join-icon {
  width: 4rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(34, 197, 94, 0.1);
  border-radius: 50%;
  margin-bottom: 1.25rem;
}

.affiliate-join-card .join-icon svg {
  width: 2rem;
  height: 2rem;
  color: var(--primary);
}

.affiliate-join-card h2 {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--foreground);
  margin: 0 0 0.375rem;
}

.affiliate-join-card .join-subtitle {
  color: var(--muted-foreground);
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
}

.join-benefits {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.join-benefit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.join-benefit .benefit-percent {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.join-benefit .benefit-text {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-join-affiliate {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--primary-foreground);
  background-color: var(--primary);
  border: none;
  border-radius: var(--radius-lg);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.btn-join-affiliate:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-join-affiliate svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* Asegurar que el contenedor de afiliado use flex-direction column */
#affWidgetAffiliate {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}