/**
 * CliniCore - Core Components (Buttons, Fields, Modals, Dialogs, Tables & Toasts)
 */

/* Botões */
.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: .73rem;
    font-weight: 680;
    gap: 7px;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
    white-space: nowrap;
}

.button:hover {
    transform: translateY(-1px);
}

.button svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.button-primary {
    color: white;
    background: var(--primary);
    box-shadow: 0 5px 16px rgba(20, 125, 120, .18);
}

.button-primary:hover {
    background: var(--primary-deep);
    box-shadow: 0 8px 22px rgba(20, 125, 120, .24);
}

.button-soft {
    border-color: var(--line);
    color: var(--text);
    background: var(--surface);
}

.button-soft:hover {
    border-color: var(--line-strong);
    background: var(--surface-soft);
}

.button-success {
    color: #fff;
    background: var(--green);
}

.button-danger-soft {
    border-color: transparent;
    color: var(--red);
    background: var(--red-soft);
}

.button-small {
    min-height: 34px;
    padding: 0 12px;
    font-size: .67rem;
}

.button-tiny {
    min-height: 26px;
    padding: 0 8px;
    font-size: .62rem;
    font-weight: 600;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.button-full {
    width: 100%;
}

.text-button {
    border: 0;
    color: var(--primary);
    background: transparent;
    cursor: pointer;
    font-size: .67rem;
    font-weight: 700;
}

.text-button:hover span {
    display: inline-block;
    transform: translateX(2px);
}

.mini-action {
    min-height: 31px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    font-size: .63rem;
    font-weight: 680;
}

.mini-action:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.mini-action.primary {
    border-color: var(--primary);
    color: #fff;
    background: var(--primary);
}

.icon-button {
    display: inline-grid;
    flex: 0 0 auto;
    width: 37px;
    height: 37px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text-soft);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, background .15s ease, transform .15s ease;
}

.icon-button:hover {
    border-color: var(--line-strong);
    color: var(--primary);
    background: var(--surface-soft);
    transform: translateY(-1px);
}

.icon-button svg {
    width: 17px;
    height: 17px;
}

.icon-button-dark {
    width: 29px;
    height: 29px;
    margin-left: auto;
    border-color: rgba(255, 255, 255, .08);
    color: rgba(255, 255, 255, .52);
    background: rgba(255, 255, 255, .05);
}

.icon-button-dark:hover {
    border-color: rgba(255, 255, 255, .14);
    color: white;
    background: rgba(255, 255, 255, .08);
}

/* Formulários & Campos */
.field-group {
    margin-bottom: 15px;
}

.field-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: .65rem;
    font-weight: 680;
}

.field-group label em {
    color: var(--red);
    font-style: normal;
}

.field {
    width: 100%;
    min-height: 41px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    color: var(--text);
    background: var(--surface);
    font-size: .71rem;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.field:focus {
    border-color: rgba(20, 125, 120, .45);
    box-shadow: 0 0 0 4px rgba(20, 125, 120, .07);
}

textarea.field {
    min-height: 80px;
    resize: vertical;
    line-height: 1.55;
}

.field::placeholder,
.inline-search input::placeholder {
    color: var(--text-muted);
}

.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.field-label-row label {
    margin-bottom: 0 !important;
}

.field-inline-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
}

.form-grid-three {
    grid-template-columns: repeat(3, 1fr);
}

.form-grid-four {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 11px;
}

.form-span-two {
    grid-column: span 2;
}

.form-section-label {
    margin: 4px 0 13px;
    padding-bottom: 7px;
    border-bottom: 1px solid var(--line);
    color: var(--text-muted);
    font-size: .58rem;
    font-weight: 720;
    letter-spacing: .08em;
    text-transform: uppercase;
}

/* Avatares */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: .82rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
    box-sizing: border-box;
}

.avatar-doctor {
    color: #fff;
    background: linear-gradient(145deg, #4ebcac, #24766f);
    box-shadow: 0 4px 12px rgba(9, 44, 42, .2);
}

.avatar-patient {
    color: #0d5a52;
    background: linear-gradient(135deg, #e6f7f4, #ccf0eb);
    border: 1.5px solid #a7e3d8;
    box-shadow: 0 2px 6px rgba(13, 90, 82, 0.08);
}

.avatar-large {
    width: 64px;
    height: 64px;
    font-size: 1.15rem;
    letter-spacing: 1px;
}

/* Badges & Status */
.status-badge,
.live-badge,
.trend-up,
.record-count {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: .59rem;
    font-weight: 720;
    gap: 5px;
    white-space: nowrap;
}

.status-scheduled {
    color: var(--blue);
    background: var(--blue-soft);
}

.status-done {
    color: var(--green);
    background: var(--green-soft);
}

.status-active {
    color: var(--amber);
    background: var(--amber-soft);
}

.status-waiting {
    color: var(--purple);
    background: var(--purple-soft);
}

.status-cancelled {
    color: var(--red);
    background: var(--red-soft);
}

.status-exams {
    color: var(--blue);
    background: var(--blue-soft);
}

.status-ready {
    color: var(--green);
    background: var(--green-soft);
}

.status-observation {
    color: var(--purple);
    background: var(--purple-soft);
}

/* Cards */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
}

.card-header {
    display: flex;
    min-height: 70px;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    gap: 14px;
}

.card-header h2,
.side-title {
    margin-top: 4px;
    font-size: .96rem;
    font-weight: 720;
    letter-spacing: -.02em;
}

.eyebrow,
.card-kicker {
    display: block;
    color: var(--primary);
    font-size: .63rem;
    font-weight: 750;
    letter-spacing: .1em;
    text-transform: uppercase;
}

/* Tabelas e Paginação */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--text-soft);
    background: var(--surface-soft);
    font-size: .62rem;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.data-table td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    font-size: .72rem;
    vertical-align: middle;
}

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

.data-table tbody tr {
    transition: background .13s ease;
}

.data-table tbody tr:hover {
    background: var(--surface-soft);
}

.table-actions {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
}

.table-icon-button {
    display: grid;
    width: 31px;
    height: 31px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text-soft);
    background: var(--surface);
    cursor: pointer;
}

.table-icon-button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.table-icon-button svg {
    width: 14px;
    height: 14px;
}

.table-icon-button.danger {
    color: var(--red);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
}

.table-sort-button { display: inline-flex; align-items: center; gap: 7px; border: 0; padding: 7px 0; background: transparent; color: inherit; font: inherit; text-align: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.table-sort-button::after { content: "↕"; color: var(--text-muted); font-size: .85rem; }
th[aria-sort="ascending"] .table-sort-button::after { content: "↑"; color: var(--primary); }
th[aria-sort="descending"] .table-sort-button::after { content: "↓"; color: var(--primary); }
.table-sort-button:hover { color: var(--primary); }

.pagination:empty {
    display: none;
}

.pagination-summary {
    margin-left: 10px;
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 650;
}

.pagination-button {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text-soft);
    background: var(--surface);
    cursor: pointer;
    font-size: .72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s ease;
}

.pagination-button:hover:not(:disabled),
.pagination-button.active {
    color: #fff;
    border-color: var(--primary);
    background: var(--primary);
}

.pagination-button:disabled {
    opacity: .42;
    cursor: not-allowed;
}

button:disabled { cursor: not-allowed; }
.text-button:disabled, .table-icon-button:disabled, .mini-action:disabled, .button:disabled { opacity: .5; }
.field-label-help { display: flex; align-items: center; gap: 6px; }
.field-label-help label { margin: 0; }
.field-help-button { width: 17px; height: 17px; padding: 0; border: 1px solid var(--text-muted); border-radius: 50%; background: transparent; color: var(--text-muted); font-size: 11px; font-weight: 700; cursor: pointer; }
.coverage-expiry-warning { color: #946000; font-size: .75rem; line-height: 1.5; }

.pagination-nav {
    min-width: 76px;
}

.pagination-ellipsis {
    padding: 0 4px;
    color: var(--text-muted);
}

/* Modais & Diálogos */
.modal-overlay {
    position: fixed;
    z-index: 400;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    opacity: 0;
    background: rgba(7, 28, 26, .58);
    backdrop-filter: blur(7px);
    pointer-events: none;
    transition: opacity .2s ease;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.modal {
    width: min(570px, 100%);
    max-height: 92vh;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: translateY(12px) scale(.98);
    transition: transform .25s var(--ease);
}

.modal-overlay.open .modal {
    transform: translateY(0) scale(1);
}

.modal-small {
    width: min(485px, 100%);
}

.modal-large {
    width: min(920px, 96vw);
}

.modal-header {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    padding: 15px 19px;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    margin-top: 4px;
    font-size: 1rem;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text-muted);
    background: var(--surface);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--red);
    background: var(--red-soft);
}

.modal-body {
    max-height: calc(92vh - 145px);
    overflow-y: auto;
    padding: 18px 19px 4px;
}

.modal-footer {
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: flex-end;
    padding: 13px 19px;
    border-top: 1px solid var(--line);
    gap: 8px;
}

.dialog-modal {
    width: min(440px, 94vw);
    padding-top: 24px;
    text-align: center;
}

.dialog-icon {
    display: grid;
    width: 50px;
    height: 50px;
    margin: 0 auto;
    place-items: center;
    border-radius: 15px;
    color: var(--primary);
    background: var(--primary-soft);
}

.dialog-icon.danger {
    color: var(--red);
    background: var(--red-soft);
}

/* Toast Notifications */
.toast-stack {
    position: fixed;
    z-index: 500;
    top: 88px;
    right: 20px;
    display: flex;
    width: min(350px, calc(100vw - 30px));
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    min-height: 54px;
    align-items: center;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    gap: 9px;
    pointer-events: auto;
    animation: toastIn .28s var(--ease);
}

.toast.removing {
    animation: toastOut .2s ease forwards;
}

.toast-icon {
    display: grid;
    flex: 0 0 27px;
    width: 27px;
    height: 27px;
    place-items: center;
    border-radius: 8px;
}

.toast-success .toast-icon {
    color: var(--green);
    background: var(--green-soft);
}

.toast-error .toast-icon {
    color: var(--red);
    background: var(--red-soft);
}

.toast-info .toast-icon {
    color: var(--blue);
    background: var(--blue-soft);
}

.toast-icon svg {
    width: 14px;
    height: 14px;
}

.toast-copy {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.toast-copy strong {
    font-size: .67rem;
}

.toast-copy span {
    margin-top: 2px;
    overflow: hidden;
    color: var(--text-muted);
    font-size: .58rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast-close {
    border: 0;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
}

/* Empty, Loading & Error States */
.empty-state {
    display: flex;
    min-height: 200px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 26px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    width: 34px;
    height: 34px;
    margin-bottom: 10px;
    color: var(--line-strong);
}

.empty-state strong {
    color: var(--text-soft);
    font-size: .75rem;
}

.empty-state p {
    max-width: 320px;
    margin-top: 4px;
    font-size: .63rem;
    line-height: 1.55;
}

.module-loading,
.module-empty,
.module-error {
    padding: 24px;
    text-align: center;
    font-size: .78rem;
    color: var(--text-muted);
    border-radius: 10px;
}

.module-empty {
    border: 1px dashed var(--line);
}

.module-error {
    background: var(--red-soft);
    color: var(--red);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px) scale(.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-8px) scale(.95); }
}
