/* ============================================
   DISTRIBUIDORA — Components
   ============================================ */

/* ---- Card ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    transition: all var(--t-base) var(--ease);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.card--accent {
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
}

.card--clickable { cursor: pointer; }

/* ---- KPI Card ---- */
.kpi-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s-4);
}

.kpi-card__info {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}

.kpi-card__label {
    font-size: var(--text-xs);
    color: var(--text-3);
    font-weight: var(--fw-medium);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-card__value {
    font-size: var(--text-2xl);
    font-weight: var(--fw-bold);
    color: var(--text-1);
    line-height: 1;
    letter-spacing: -0.03em;
}

.kpi-card__trend {
    font-size: var(--text-xs);
    color: var(--green);
    font-weight: var(--fw-medium);
    margin-top: 2px;
}

.kpi-card__trend--down { color: var(--red); }

.kpi-card__icon {
    width: 42px;
    height: 42px;
    border-radius: var(--r-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-card__icon svg { width: 20px; height: 20px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: 7px var(--s-4);
    border-radius: var(--r-md);
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    border: none;
    transition: all var(--t-fast) var(--ease);
    white-space: nowrap;
    line-height: 1.5;
    user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn--primary {
    background: var(--accent);
    color: var(--text-inv);
}
.btn--primary:hover { background: var(--accent-hover); }

.btn--secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-1);
    border: 1px solid var(--border);
}
.btn--secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
}

.btn--success {
    background: var(--green-dim);
    color: var(--green);
}
.btn--success:hover { background: rgba(52, 211, 153, 0.18); }

.btn--danger {
    background: var(--red-dim);
    color: var(--red);
}
.btn--danger:hover { background: rgba(248, 113, 113, 0.18); }

.btn--whatsapp {
    background: var(--wa-dim);
    color: var(--wa);
}
.btn--whatsapp:hover { background: rgba(37, 211, 102, 0.18); }

.btn--ghost {
    background: transparent;
    color: var(--text-3);
    padding: var(--s-1) var(--s-2);
}
.btn--ghost:hover {
    color: var(--text-1);
    background: rgba(255, 255, 255, 0.06);
}

.btn--sm { padding: 3px var(--s-2); font-size: var(--text-xs); }
.btn--sm svg { width: 14px; height: 14px; }
.btn--icon { width: 32px; height: 32px; padding: 0; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--r-full);
    font-size: var(--text-xs);
    font-weight: var(--fw-medium);
    letter-spacing: 0.01em;
    line-height: 1.5;
}

.badge--active { background: var(--green-dim); color: var(--green); }
.badge--inactive { background: var(--red-dim); color: var(--red); }
.badge--new { background: var(--blue-dim); color: var(--blue); }
.badge--cigarrillos { background: var(--cat-cig-dim); color: var(--cat-cig); }
.badge--tabaco { background: var(--cat-tab-dim); color: var(--cat-tab); }
.badge--papeles { background: var(--cat-pap-dim); color: var(--cat-pap); }
.badge--filtros { background: var(--cat-fil-dim); color: var(--cat-fil); }
.badge--otros { background: var(--cat-otr-dim); color: var(--cat-otr); }
.badge--withdrawal { background: var(--red-dim); color: var(--red); }
.badge--payment { background: var(--green-dim); color: var(--green); }
.badge--low-stock {
    background: var(--yellow-dim);
    color: var(--yellow);
    animation: pulse 2s infinite;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--t-base) var(--ease);
    padding: var(--s-6);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-xl);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--t-slow) var(--ease-spring);
    box-shadow: var(--shadow-lg);
}

.modal--lg { max-width: 680px; }
.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-5);
    border-bottom: 1px solid var(--border);
}

.modal__header h3 { font-size: var(--text-base); }

.modal__close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    color: var(--text-3);
    cursor: pointer;
    transition: all var(--t-fast);
    background: none;
    border: none;
}
.modal__close:hover {
    color: var(--text-1);
    background: rgba(255, 255, 255, 0.06);
}

.modal__body {
    padding: var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
}

.modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-5);
    border-top: 1px solid var(--border);
}

/* ---- Forms ---- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}

.form-group label {
    font-size: var(--text-xs);
    font-weight: var(--fw-medium);
    color: var(--text-3);
}

.form-group label .required { color: var(--red); margin-left: 2px; }

.form-input {
    width: 100%;
    padding: 8px var(--s-3);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text-1);
    font-size: var(--text-sm);
    transition: all var(--t-fast);
}

.form-input:hover { border-color: var(--border-hover); }

.form-input:focus {
    border-color: var(--accent);
    background: var(--bg-input-focus);
    box-shadow: 0 0 0 3px rgba(224, 168, 60, 0.1);
}

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

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

select.form-input {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2552525b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-3);
}

/* ---- Search ---- */
.search-input { position: relative; }

.search-input svg {
    position: absolute;
    left: var(--s-3);
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--text-3);
    pointer-events: none;
}

.search-input .form-input { padding-left: 36px; }

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    top: var(--s-4);
    right: var(--s-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--r-lg);
    min-width: 280px;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    animation: slideRight var(--t-base) var(--ease);
}

.toast--success { border-left: 3px solid var(--green); }
.toast--error { border-left: 3px solid var(--red); }
.toast--warning { border-left: 3px solid var(--yellow); }
.toast--info { border-left: 3px solid var(--blue); }

.toast__icon { flex-shrink: 0; }
.toast__content { flex: 1; }

.toast__title {
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    color: var(--text-1);
}

.toast__close {
    cursor: pointer;
    color: var(--text-3);
    background: none;
    border: none;
    padding: 2px;
    border-radius: var(--r-sm);
    transition: all var(--t-fast);
}
.toast__close:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.06); }

/* ---- Empty State ---- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--s-12) var(--s-6);
    text-align: center;
    gap: var(--s-3);
}

.empty-state__icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    margin-bottom: var(--s-2);
}

.empty-state__icon svg { width: 24px; height: 24px; }
.empty-state h3 { font-size: var(--text-base); color: var(--text-2); font-weight: var(--fw-medium); }
.empty-state p { font-size: var(--text-sm); color: var(--text-3); max-width: 360px; }

/* ---- Spinner ---- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-12);
}

/* ---- Table ---- */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--bg-card);
}

.table { width: 100%; border-collapse: collapse; }

.table th {
    padding: var(--s-3) var(--s-4);
    text-align: left;
    font-size: var(--text-xs);
    font-weight: var(--fw-medium);
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.01);
}

.table td {
    padding: var(--s-3) var(--s-4);
    font-size: var(--text-sm);
    color: var(--text-1);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tr {
    transition: background var(--t-fast);
}

.table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.table__actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* ---- Filters ---- */
.filters {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-bottom: var(--s-4);
    flex-wrap: wrap;
}

.filter-select {
    padding: 6px var(--s-3);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    color: var(--text-1);
    font-size: var(--text-sm);
    cursor: pointer;
    appearance: none;
    transition: all var(--t-fast);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2552525b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.filter-select:hover { border-color: var(--border-hover); }
.filter-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(224, 168, 60, 0.1); }

/* ---- Confirm ---- */
.confirm-dialog {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--s-3);
    padding: var(--s-4) 0;
}

.confirm-dialog__icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--yellow-dim);
    color: var(--yellow);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Checkbox ---- */
.checkbox {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    cursor: pointer;
}

.checkbox input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-hover);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--t-fast);
    position: relative;
    flex-shrink: 0;
}

.checkbox input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid var(--text-inv);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
