/* Componentes Base del Sistema de Diseño Distrimayor */
/* Requiere ds-tokens.css */

/* BOTONES */
.ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--ds-font-family);
    font-weight: 500;
    padding: var(--ds-space-2) var(--ds-space-4);
    border-radius: var(--ds-radius-md);
    transition: all var(--ds-transition-fast);
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
}
.ds-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ds-btn-primary {
    background-color: var(--ds-primary);
    color: var(--ds-surface);
}
.ds-btn-primary:hover:not(:disabled) {
    background-color: var(--ds-secondary);
    box-shadow: var(--ds-shadow-md);
    transform: translateY(-1px);
    color: var(--ds-surface);
}

.ds-btn-secondary {
    background-color: var(--ds-primary-light);
    color: var(--ds-primary);
}
.ds-btn-secondary:hover:not(:disabled) {
    background-color: #dbeafe;
    color: var(--ds-primary);
}

.ds-btn-outline {
    background-color: transparent;
    border-color: var(--ds-border-color);
    color: var(--ds-text-main);
}
.ds-btn-outline:hover:not(:disabled) {
    background-color: var(--ds-background);
    border-color: var(--ds-primary);
    color: var(--ds-primary);
}

.ds-btn-danger {
    background-color: var(--ds-danger);
    color: var(--ds-surface);
}
.ds-btn-danger:hover:not(:disabled) {
    background-color: #b91c1c;
    box-shadow: var(--ds-shadow-md);
    transform: translateY(-1px);
    color: var(--ds-surface);
}

/* CARDS */
.ds-card {
    margin-bottom: var(--ds-space-6);
    background-color: var(--ds-surface);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-sm);
    border: 1px solid var(--ds-border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ds-card-header {
    padding: 22px 24px;
    border-bottom: 1px solid var(--ds-border-color);
    font-weight: 600;
    color: var(--ds-text-main);
    background-color: var(--ds-surface);
}
.ds-card-body {
    padding: 24px;
    color: var(--ds-text-main);
}

/* FORMULARIOS */
.ds-input, .ds-select {
    width: 100%;
    padding: var(--ds-space-2) var(--ds-space-3);
    border: 1px solid var(--ds-border-color);
    border-radius: var(--ds-radius-md);
    font-family: var(--ds-font-family);
    color: var(--ds-text-main);
    background-color: var(--ds-surface);
    transition: border-color var(--ds-transition-fast), box-shadow var(--ds-transition-fast);
}
.ds-input:focus, .ds-select:focus {
    outline: none;
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px var(--ds-primary-light);
}

/* TABLAS */
.ds-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--ds-font-family);
}
.ds-table th {
    text-align: left;
    padding: var(--ds-space-3) var(--ds-space-4);
    background-color: var(--ds-background);
    color: var(--ds-text-main);
    font-weight: 600;
    border-bottom: 1px solid var(--ds-border-color);
}
.ds-table td {
    padding: var(--ds-space-3) var(--ds-space-4);
    border-bottom: 1px solid var(--ds-border-color);
    color: var(--ds-text-main);
}
.ds-table tbody tr:hover {
    background-color: var(--ds-primary-light);
}

/* BADGES */
.ds-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: var(--ds-radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.ds-badge[data-state="success"] { background-color: #D1FAE5; color: #065F46; }
.ds-badge[data-state="warning"] { background-color: #FEF3C7; color: #92400E; }
.ds-badge[data-state="danger"] { background-color: #FEE2E2; color: #991B1B; }
.ds-badge[data-state="info"] { background-color: #DBEAFE; color: #1E40AF; }

/* ALERTAS */
.ds-alert {
    padding: var(--ds-space-4);
    border-radius: var(--ds-radius-md);
    margin-bottom: var(--ds-space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--ds-space-3);
}

/* MODALES */
.ds-modal {
    background-color: var(--ds-surface);
    border-radius: var(--ds-radius-xl);
    box-shadow: var(--ds-shadow-lg);
    border: 1px solid var(--ds-border-color);
}

/* EMPTY STATE */
.ds-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--ds-space-8);
    text-align: center;
    color: var(--ds-text-muted); /* Placeholder value since --ds-text-muted is not defined in tokens, defaulting to gray */
    background-color: var(--ds-background);
    border-radius: var(--ds-radius-lg);
    border: 1px dashed var(--ds-border-color);
}

/* SKELETON */
.ds-skeleton {
    background-color: var(--ds-border-color);
    border-radius: var(--ds-radius-sm);
    animation: ds-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes ds-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* AVATARS */
.ds-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ds-radius-full);
    font-weight: 700;
    font-family: var(--ds-font-family);
    overflow: hidden;
}
.ds-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
}
.ds-avatar-md {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}
.ds-avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
}
.ds-avatar-primary {
    background-color: var(--ds-primary);
    color: var(--ds-surface);
}
.ds-avatar-danger {
    background-color: var(--ds-danger);
    color: var(--ds-surface);
}
.ds-avatar-muted {
    background-color: var(--ds-border-color);
    color: var(--ds-text-main);
}

/* ICON BOXES */
.ds-icon-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--ds-radius-lg);
    padding: var(--ds-space-3);
    transition: background-color var(--ds-transition-fast);
}
.ds-icon-box-primary {
    background-color: var(--ds-primary-light);
    color: var(--ds-primary);
}
.ds-icon-box-danger {
    background-color: #FDE8E8;
    color: var(--ds-danger);
}
.ds-icon-box-muted {
    background-color: var(--ds-background);
    color: var(--ds-text-main);
}


/* LAYOUT GLOBAL Y NORMALIZACIÓN */
.ds-page {
    min-height: 100vh;
    background-color: var(--ds-background);
    padding: var(--ds-space-6) 0;
}

/* Modificado: Layout SaaS ancho optimizado */
.ds-page.ds-page-container {
    width: min(100%, 1720px);
    max-width: 1720px;
    margin-inline: auto;
    padding-inline: clamp(12px, 1.4vw, 24px);
}

.ds-page-container {
    width: calc(100% - 48px);
    max-width: 1680px;
    margin-inline: auto;
    padding-inline: clamp(16px, 2vw, 32px);
}

@media (min-width: 1400px) {
  .ds-page-container {
    max-width: 1720px;
  }
}

.ds-page-header {
    padding: 24px 28px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
}

.ds-page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ds-text-main);
    margin: 0;
    line-height: 1.2;
}

.ds-page-subtitle {
    font-size: 1rem;
    color: #64748B;
    margin: 0;
}

.ds-section {
    margin-bottom: var(--ds-space-8);
}

.ds-section-header {
    margin-bottom: var(--ds-space-4);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--ds-text-main);
}

.ds-content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

/* NORMALIZACIÓN TABS */
.ds-tabs {
    display: flex;
    gap: 8px;
    background-color: var(--ds-background);
    border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0;
    padding: 8px 12px 0 12px;
    border-bottom: 1px solid var(--ds-border-color);
    margin-bottom: 24px;
    overflow-x: auto;
    align-items: flex-end;
}

.ds-tab {
    padding: 10px 18px;
    border-radius: 10px 10px 0 0;
    color: #64748B;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--ds-transition-fast);
    white-space: nowrap;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -1px;
}

.ds-tab:hover {
    color: var(--ds-text-main);
    background-color: rgba(0, 0, 0, 0.03);
}

.ds-tab-active,
.ds-tab.active {
    background-color: var(--ds-surface);
    color: var(--ds-primary);
    font-weight: 700;
    border: 1px solid var(--ds-border-color);
    border-bottom: 1px solid var(--ds-surface);
    border-top: 3px solid var(--ds-primary);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.02);
}

/* NORMALIZACIÓN FORMULARIOS HORIZONTALES */
.ds-form-horizontal {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
}
@media (max-width: 768px) {
  .ds-form-horizontal {
    flex-direction: column;
    align-items: stretch;
  }
}


/* SECCIONES INTERNAS DE CARDS */
.ds-card-section {
    padding: 20px 24px;
    border-top: 1px solid var(--ds-border-color);
}

/* TABLAS OPTIMIZADAS (sin pegarse a bordes) */
.ds-card .ds-table {
    margin: 8px 0;
    border-radius: var(--ds-radius-md);
    overflow: hidden;
    border: 1px solid var(--ds-border-color);
}
.ds-card .table-responsive {
    padding: 0 4px;
}

/* FORMULARIOS INTERNOS EN CARDS */
.ds-card form,
.ds-card .ds-form-horizontal {
    padding: 8px 0;
}

/* SAFE PADDING FOR DIRECT CARD CHILDREN */
.ds-card > form,
.ds-card > .table-responsive,
.ds-card > .chart-stage,
.ds-card > .list-unstyled,
.ds-card > .mt-4.pt-3,
.ds-card > .alert {
    padding-inline: 24px;
    margin-bottom: 24px;
}
.ds-card > .ds-card-header + form,
.ds-card > .ds-card-header + .table-responsive {
    margin-top: 0;
}
