/**
 * V4 Design System - Components
 * Reusable UI components (buttons, cards, inputs, badges)
 */

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

/* Icon Buttons */
.icon-button-compact {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--surface-store);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-button-compact:active {
    transform: scale(0.92);
}

/* Primary Button */
.btn-primary {
    height: 56px;
    padding: 0 28px;
    border-radius: 14px;
    border: none;
    background: var(--color-action-purple);
    color: var(--text-inverse);
    font-size: 16px;
    font-weight: 800;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

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

.btn-primary:active {
    transform: scale(0.96);
}

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

/* Secondary Button */
.btn-secondary {
    height: 56px;
    padding: 0 28px;
    border-radius: 14px;
    border: 2px solid #e5e7eb;
    background: var(--surface-elevated);
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f3f4f6;
    border-color: var(--text-secondary);
}

.btn-secondary:active {
    transform: scale(0.96);
}

/* Danger Button */
.btn-danger {
    height: 56px;
    padding: 0 28px;
    border-radius: 14px;
    border: none;
    background: var(--color-remove-red);
    color: var(--text-inverse);
    font-size: 16px;
    font-weight: 800;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: var(--color-remove-red-dark);
    transform: translateY(-2px);
}

.btn-danger:active {
    transform: scale(0.96);
}

/* Ghost Button */
.btn-ghost {
    height: 56px;
    padding: 0 28px;
    border-radius: 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.btn-ghost:hover {
    background: var(--surface-store);
}

.btn-ghost:active {
    transform: scale(0.96);
}

/* Back Button (text variant) */
.back-button {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: 2px solid var(--text-secondary);
    background: var(--surface-elevated);
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: var(--surface-store);
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.back-button:active {
    transform: scale(0.96);
}

/* Back Button (icon-only square variant, used in page headers) */
/* DEPRECATED: migrado a .page-back-btn en redesign.css — no usar */
.btn-back {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 2px solid var(--border-color, #e5e7eb);
    background: var(--surface-elevated, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary, #6b7280);
    transition: all 0.2s;
    flex-shrink: 0;
    cursor: pointer;
}

.btn-back:hover {
    border-color: var(--color-price-blue, #3b82f6);
    color: var(--color-price-blue, #3b82f6);
    background: var(--surface-elevated, #fff);
}

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

/* Base Card */
.card {
    background: var(--surface-elevated);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

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

/* Large Card */
.card-lg {
    background: var(--surface-elevated);
    border-radius: var(--radius-2xl);
    padding: 32px;
    box-shadow: var(--shadow-md);
}

/* ===== INPUTS ===== */

/* Text Input */
.input {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-md);
    border: 2px solid #e5e7eb;
    padding: 0 16px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    background: var(--surface-elevated);
    transition: all 0.2s ease;
}

.input:focus {
    outline: none;
    border-color: var(--color-price-blue);
    box-shadow: 0 0 0 3px var(--color-price-blue-light);
}

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

/* Large Input */
.input-lg {
    width: 100%;
    height: 56px;
    border-radius: 14px;
    border: 2px solid #e5e7eb;
    padding: 0 20px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    background: var(--surface-elevated);
    transition: all 0.2s ease;
}

.input-lg:focus {
    outline: none;
    border-color: var(--color-price-blue);
    box-shadow: 0 0 0 3px var(--color-price-blue-light);
}

/* Select Input */
.select {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-md);
    border: 2px solid #e5e7eb;
    padding: 0 16px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    background: var(--surface-elevated);
    cursor: pointer;
    transition: all 0.2s ease;
}

.select:focus {
    outline: none;
    border-color: var(--color-price-blue);
    box-shadow: 0 0 0 3px var(--color-price-blue-light);
}

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

.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 700;
}

.badge-primary {
    background: var(--color-price-blue-light);
    color: var(--color-price-blue-dark);
}

.badge-success {
    background: var(--color-add-green-light);
    color: var(--color-add-green-dark);
}

.badge-warning {
    background: var(--color-warning-yellow-light);
    color: #d97706;
}

.badge-danger {
    background: var(--color-remove-red-light);
    color: var(--color-remove-red-dark);
}

.badge-neutral {
    background: rgba(0, 0, 0, 0.08);
    color: var(--text-secondary);
}

/* Product Badge (circular counter) */
.product-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-add-green);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* ===== CHIPS/TAGS ===== */

.chip,
.filter-chip {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: 2px solid #e5e7eb;
    background: var(--surface-elevated);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    text-decoration: none;
}

.chip.active,
.filter-chip.active {
    background: var(--color-action-purple);
    color: var(--text-inverse);
    border-color: var(--color-action-purple);
}

.chip:hover:not(.active),
.filter-chip:hover:not(.active) {
    border-color: var(--color-action-purple);
    background: var(--color-action-purple-light);
}

/* ===== DIVIDERS ===== */

.divider {
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 24px 0;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 2px;
    background: #e7e5e4;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

/* ===== FORM GROUPS ===== */

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-md);
    border: 2px solid #e5e7eb;
    padding: 0 16px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    background: var(--surface-elevated);
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-price-blue);
    box-shadow: 0 0 0 3px var(--color-price-blue-light);
}

.form-select {
    width: 100%;
    height: 50px;
    border-radius: var(--radius-md);
    border: 2px solid #e5e7eb;
    padding: 0 16px;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    background: var(--surface-elevated);
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-select:focus {
    outline: none;
    border-color: var(--color-price-blue);
    box-shadow: 0 0 0 3px var(--color-price-blue-light);
}

/* ===== TOAST NOTIFICATIONS ===== */

.toast-container {
    position: fixed;
    bottom: calc(80px + 16px); /* above footer nav */
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    pointer-events: none;
}

.toast {
    padding: 14px 24px;
    border-radius: 14px;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
}

.toast-success {
    background: #059669;
    color: white;
}

.toast-error {
    background: #dc2626;
    color: white;
}

/* ============================================================
   KX-* DESIGN SYSTEM — namespace kx-
   Nuevo sistema de componentes reutilizables para modo admin.
   No choca con redesign.css porque usa el prefijo kx-.
   ============================================================ */

/* ===== KX TOOLBAR ===== */
.kx-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.kx-toolbar__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--fg-1, #111827);
    margin: 0;
}
.kx-toolbar__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ===== KX FILTERS ===== */
.kx-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface-2, #f9fafb);
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.kx-filters__search {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.kx-filters__search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.25rem;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--surface-1, #fff);
}
.kx-filters__chips {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

/* ===== KX CHIP ===== */
.kx-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all 0.15s;
    background: var(--surface-1, #fff);
    color: var(--fg-2, #6b7280);
    text-decoration: none;
}
.kx-chip:hover {
    border-color: var(--color-action-purple, #7c3aed);
    color: var(--color-action-purple, #7c3aed);
}
.kx-chip--active {
    background: var(--color-action-purple, #7c3aed);
    color: white !important;
    border-color: var(--color-action-purple, #7c3aed) !important;
}
.kx-chip--warning { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.kx-chip--danger  { background: #fee2e2; color: #991b1b; border-color: #ef4444; }
.kx-chip--success { background: #d1fae5; color: #065f46; border-color: #10b981; }
.kx-chip__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(0,0,0,0.08);
    color: inherit;
    line-height: 1;
    margin-left: 2px;
}
.kx-chip--active .kx-chip__count {
    background: rgba(255,255,255,0.25);
}

/* ===== KX KPI CARD ===== */
.kx-kpi-card {
    background: var(--surface-1, white);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--border, #e5e7eb);
}
.kx-kpi-card__label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--fg-2, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.375rem;
}
.kx-kpi-card__value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--fg-1, #111827);
    line-height: 1.1;
    font-family: 'JetBrains Mono', monospace;
}
.kx-kpi-card__delta {
    font-size: 0.8125rem;
    margin-top: 0.375rem;
    font-weight: 500;
}
.kx-kpi-card__delta--up   { color: var(--color-add-green, #10b981); }
.kx-kpi-card__delta--down { color: #ef4444; }
.kx-kpi-card--purple { border-top: 3px solid var(--color-action-purple, #7c3aed); }
.kx-kpi-card--green  { border-top: 3px solid var(--color-add-green, #10b981); }
.kx-kpi-card--blue   { border-top: 3px solid var(--color-price-blue, #3b82f6); }
.kx-kpi-card--amber  { border-top: 3px solid #f59e0b; }
.kx-kpi-card--red    { border-top: 3px solid #ef4444; }
.kx-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

/* ===== KX TABLE ===== */
.kx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.kx-table thead {
    background: var(--surface-2, #f9fafb);
    border-bottom: 2px solid var(--border, #e5e7eb);
}
.kx-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--fg-2, #6b7280);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.kx-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border, #f3f4f6);
    vertical-align: middle;
}
.kx-table tbody tr:hover { background: var(--surface-2, #f9fafb); }
.kx-table tbody tr:last-child td { border-bottom: none; }
.kx-table__actions {
    display: flex;
    gap: 0.375rem;
    justify-content: flex-end;
}

/* ===== KX PAGINATION ===== */
.kx-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.5rem;
    border-top: 1px solid var(--border, #e5e7eb);
    font-size: 0.875rem;
    color: var(--fg-2, #6b7280);
}
.kx-pagination__pages { display: flex; gap: 0.25rem; }
.kx-pagination__page {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 6px;
    border: 1px solid var(--border, #e5e7eb);
    cursor: pointer;
    text-decoration: none;
    color: var(--fg-1, #111827);
    font-size: 0.875rem;
}
.kx-pagination__page--active {
    background: var(--color-action-purple, #7c3aed);
    color: white;
    border-color: var(--color-action-purple, #7c3aed);
}

/* ===== KX EMPTY STATE ===== */
.kx-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--fg-2, #6b7280);
}
.kx-empty-state__icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}
.kx-empty-state__title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--fg-1, #111827);
    margin-bottom: 0.5rem;
}
.kx-empty-state__body {
    font-size: 0.875rem;
    max-width: 320px;
    margin-bottom: 1.5rem;
}

/* ===== KX BUTTON ===== */
.kx-button {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    text-decoration: none;
    font-family: var(--font-body, 'Inter', sans-serif);
}
.kx-button--primary {
    background: var(--color-action-purple, #7c3aed);
    color: white;
}
.kx-button--primary:hover { background: #6d28d9; }
.kx-button--secondary {
    background: var(--surface-1, #fff);
    color: var(--fg-1, #111827);
    border: 1.5px solid var(--border, #e5e7eb);
}
.kx-button--secondary:hover {
    border-color: var(--color-action-purple, #7c3aed);
    color: var(--color-action-purple, #7c3aed);
}
.kx-button--ghost {
    background: transparent;
    color: var(--fg-2, #6b7280);
}
.kx-button--ghost:hover {
    background: var(--surface-2, #f9fafb);
    color: var(--fg-1, #111827);
}
.kx-button--danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1.5px solid #fca5a5;
}
.kx-button--danger:hover { background: #fca5a5; }
.kx-button--sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.kx-button--icon { padding: 0.5rem; border-radius: 8px; }

/* ===== KX SECTION ===== */
.kx-section {
    background: var(--surface-1, white);
    border-radius: 12px;
    border: 1px solid var(--border, #e5e7eb);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.kx-section__header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border, #e5e7eb);
    font-weight: 600;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kx-section__body { padding: 1.5rem; }

/* ===== KX BADGE ===== */
.kx-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.kx-badge--success { background: #d1fae5; color: #065f46; }
.kx-badge--warning { background: #fef3c7; color: #92400e; }
.kx-badge--danger  { background: #fee2e2; color: #991b1b; }
.kx-badge--neutral { background: #f3f4f6; color: #6b7280; }
.kx-badge--purple  { background: #ede9fe; color: #5b21b6; }

/* ===== KX PAGE — contenedor de ancho estándar ===== */
.kx-page {
    padding: 20px 24px 32px;
    max-width: 1200px;
    margin: 0 auto;
}
.kx-page--wide   { max-width: 1400px; }
.kx-page--narrow { max-width: 640px;  }

/* ===== KX PAGE HEADER ===== */
.kx-page-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
    background: var(--surface-elevated, #fff);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    border: 1px solid var(--border, #e5e7eb);
}
.kx-page-header__back {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1.5px solid var(--border, #e5e7eb);
    background: var(--surface-1, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--fg-1, #18181B);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.kx-page-header__back:hover {
    background: var(--surface-2, #f3f4f6);
    border-color: var(--fg-3, #d1d5db);
}
.kx-page-header__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.kx-page-header__title {
    font-family: var(--font-display, 'Fraunces', Georgia, serif);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--fg-1, #18181B);
    margin: 0;
    line-height: 1.1;
}
.kx-page-header__subtitle {
    font-size: 13px;
    color: var(--fg-2, #5C5C66);
    margin: 0;
}
.kx-page-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ===== KX PAGE — RESPONSIVE ===== */
@media (max-width: 768px) {
    .kx-page {
        padding: 12px 16px 24px;
    }
    .kx-page-header {
        padding: 12px 14px;
        border-radius: 12px;
        margin-bottom: 20px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .kx-page-header__title {
        font-size: 20px;
    }
    .kx-page-header__actions {
        flex-wrap: wrap;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .kx-page {
        padding: 8px 12px 20px;
    }
    .kx-page-header {
        padding: 10px 12px;
        border-radius: 10px;
        margin-bottom: 16px;
    }
    .kx-page-header__title {
        font-size: 18px;
    }
}
