/**
 * Therapy POS — Reusable UI components
 */

/* Buttons */
.tp-btn,
body.therapy-app .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--tp-space-2);
    min-height: var(--tp-touch);
    padding: 0 var(--tp-space-5);
    font-family: var(--tp-font);
    font-size: var(--tp-text-sm);
    font-weight: 600;
    line-height: 1;
    border-radius: var(--tp-radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--tp-duration) var(--tp-ease),
        border-color var(--tp-duration) var(--tp-ease),
        color var(--tp-duration) var(--tp-ease),
        box-shadow var(--tp-duration) var(--tp-ease);
    white-space: nowrap;
}

.tp-btn--primary,
body.therapy-app .btn-primary {
    background: var(--tp-primary);
    color: var(--tp-text-inverse);
    border-color: var(--tp-primary);
    box-shadow: var(--tp-shadow-xs);
}

.tp-btn--primary:hover,
body.therapy-app .btn-primary:hover {
    background: var(--tp-primary-hover);
    border-color: var(--tp-primary-hover);
    color: var(--tp-text-inverse);
}

.tp-btn--secondary,
body.therapy-app .btn-ghost {
    background: var(--tp-surface);
    color: var(--tp-text);
    border-color: var(--tp-border);
}

.tp-btn--secondary:hover,
body.therapy-app .btn-ghost:hover {
    background: var(--tp-surface-hover);
    border-color: var(--tp-border-strong);
    color: var(--tp-text);
}

.tp-btn--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--tp-text-secondary);
}

.tp-btn--ghost:hover {
    background: var(--tp-bg);
    color: var(--tp-text);
}

.tp-btn--sm,
body.therapy-app .btn-small,
body.therapy-app .btn-small {
    min-height: 36px;
    padding: 0 var(--tp-space-3);
    font-size: var(--tp-text-xs);
}

.tp-btn--lg {
    min-height: 52px;
    padding: 0 var(--tp-space-6);
    font-size: var(--tp-text-base);
}

.tp-btn--block,
body.therapy-app .btn-block {
    width: 100%;
}

.tp-btn--icon {
    width: var(--tp-touch);
    padding: 0;
}

.tp-btn:disabled,
body.therapy-app .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Cards */
.tp-card,
body.therapy-app .panel {
    background: var(--tp-surface);
    border: 1px solid var(--tp-border);
    border-radius: var(--tp-radius-lg);
    box-shadow: var(--tp-shadow-sm);
    padding: var(--tp-space-6);
    margin-bottom: var(--tp-space-5);
}

/* Vertical rhythm in app-page-body is gap-based (layout_shell.css) */
.app-page-body > .tp-card,
.app-page-body > .panel,
.app-page-body > section.panel {
    margin-bottom: 0;
}

.tp-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--tp-space-4);
    margin-bottom: var(--tp-space-4);
}

.tp-card__title {
    margin: 0;
    font-size: var(--tp-text-lg);
}

.tp-card__subtitle {
    margin: var(--tp-space-1) 0 0;
    font-size: var(--tp-text-sm);
    color: var(--tp-text-muted);
}

.tp-card__body--flush {
    margin: calc(var(--tp-space-6) * -1);
    margin-top: 0;
    padding: 0;
    border-radius: 0 0 var(--tp-radius-lg) var(--tp-radius-lg);
    overflow: hidden;
}

/* Badges */
.tp-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--tp-space-1);
    padding: 0.2em 0.65em;
    font-size: var(--tp-text-xs);
    font-weight: 600;
    line-height: 1.4;
    border-radius: var(--tp-radius-full);
    white-space: nowrap;
}

.tp-badge--success { background: var(--tp-success-soft); color: var(--color-success); }
.tp-badge--warning { background: var(--tp-warning-soft); color: #b45309; }
.tp-badge--danger { background: var(--tp-danger-soft); color: #b91c1c; }
.tp-badge--info { background: var(--tp-info-soft); color: #1d4ed8; }
.tp-badge--neutral { background: var(--tp-bg); color: var(--tp-text-secondary); }
.tp-badge--primary { background: var(--tp-primary-soft); color: var(--tp-primary-active); }

/* Search & filters */
.tp-search {
    position: relative;
    max-width: 320px;
}

.tp-search__input {
    width: 100%;
    min-height: var(--tp-touch);
    padding: 0 var(--tp-space-4) 0 2.5rem;
    font-family: var(--tp-font);
    font-size: var(--tp-text-sm);
    border: 1px solid var(--tp-border);
    border-radius: var(--tp-radius-sm);
    background: var(--tp-surface);
    color: var(--tp-text);
}

.tp-search__icon {
    position: absolute;
    left: var(--tp-space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--tp-text-muted);
    pointer-events: none;
}

.tp-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--tp-space-2);
}

.tp-pill {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 var(--tp-space-4);
    font-size: var(--tp-text-sm);
    font-weight: 500;
    color: var(--tp-text-secondary);
    background: var(--tp-surface);
    border: 1px solid var(--tp-border);
    border-radius: var(--tp-radius-full);
    cursor: pointer;
    transition: all var(--tp-duration) var(--tp-ease);
}

.tp-pill:hover {
    border-color: var(--tp-primary-muted);
    color: var(--tp-primary);
}

.tp-pill.is-active {
    background: var(--tp-primary-soft);
    border-color: var(--tp-primary);
    color: var(--tp-primary-active);
}

/* Empty state */
.tp-empty {
    text-align: center;
    padding: var(--tp-space-10) var(--tp-space-6);
    border: 1px dashed var(--tp-border);
    border-radius: var(--tp-radius-lg);
    background: var(--tp-surface);
}

.tp-empty__icon {
    font-size: 2.5rem;
    margin-bottom: var(--tp-space-4);
    opacity: 0.5;
}

.tp-empty__title {
    margin: 0 0 var(--tp-space-2);
    font-size: var(--tp-text-lg);
}

/* Toasts (therapy + legacy) */
.therapy-toast {
    border-radius: var(--tp-radius) !important;
    background: var(--tp-surface) !important;
    border: 1px solid var(--tp-border) !important;
    color: var(--tp-text) !important;
    box-shadow: var(--tp-shadow-lg) !important;
}

.therapy-toast--success { border-left: 4px solid var(--tp-success) !important; }
.therapy-toast--error { border-left: 4px solid var(--tp-danger) !important; }
.therapy-toast--info { border-left: 4px solid var(--tp-primary) !important; }

/* Alerts */
body.therapy-app .alert {
    padding: var(--tp-space-4);
    border-radius: var(--tp-radius);
    margin-bottom: var(--tp-space-4);
    font-size: var(--tp-text-sm);
}

body.therapy-app .alert-error {
    background: var(--tp-danger-soft);
    color: #991b1b;
    border: 1px solid #fecaca;
}

body.therapy-app .form-error {
    color: var(--tp-danger);
    font-size: var(--tp-text-sm);
}

body.therapy-app .form-success {
    color: var(--tp-success);
    font-size: var(--tp-text-sm);
}

/* Icon action */
.tp-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--tp-touch);
    height: var(--tp-touch);
    padding: 0;
    border: none;
    border-radius: var(--tp-radius-sm);
    background: transparent;
    color: var(--tp-text-secondary);
    cursor: pointer;
    transition: background var(--tp-duration) var(--tp-ease);
}

.tp-icon-btn:hover {
    background: var(--tp-bg);
    color: var(--tp-primary);
}
