/* =========================================================
   COMPONENTS — Buttons, forms, cards, tables, badges, alerts
   ========================================================= */

/* ---------- BUTTONS ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
    line-height: 1;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 13px 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }

/* ---------- FORMS ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.form-group input::placeholder { color: var(--text-soft); }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-group .hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.form-group.full { grid-column: 1 / -1; }
.form-actions {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

/* ---------- CARDS ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    max-width: 760px;
}
.form-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.form-card .sub { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ---------- BADGES ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .2px;
    line-height: 1.6;
}
.badge::before {
    content: "";
    width: 5px; height: 5px;
    border-radius: 50%;
    background: currentColor;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-neutral { background: var(--surface-2);    color: var(--text-muted); }
.badge-neutral::before { display: none; }

/* ---------- ALERTS ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    line-height: 1.5;
}
.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(220,38,38,.25);
}
.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(5,150,105,.25);
}

/* ---------- TABLES ---------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.table-toolbar {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.table-toolbar h3 { font-size: 14px; font-weight: 600; }
.table-toolbar .search {
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    min-width: 220px;
}
.table-toolbar .search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
table.data th {
    text-align: left;
    padding: 12px 20px;
    background: var(--surface-2);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-2); }
table.data .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
table.data tfoot td { border-top: 2px solid var(--border); padding-top: 14px; }

/* ---------- SCROLLABLE TABLE WRAPPER ---------- */
.table-wrap--scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) var(--surface-2);
}

/* Webkit scrollbar — Chrome, Edge, Safari */
.table-wrap--scroll::-webkit-scrollbar {
    height: 10px;
    background: var(--surface-2);
}
.table-wrap--scroll::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 5px;
}
.table-wrap--scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-soft);
}
.table-wrap--scroll::-webkit-scrollbar-track {
    background: var(--surface-2);
    border-top: 1px solid var(--border);
}

/* ---------- STICKY ACTIONS COLUMN (Check-ins table) ---------- */
#checkinsTable th:last-child,
#checkinsTable td:last-child {
    position: sticky;
    right: 0;
    background: var(--surface);
    z-index: 2;
    box-shadow: -6px 0 10px -6px rgba(16,24,40,.10);
}
#checkinsTable thead th:last-child {
    background: var(--surface-2);
    z-index: 3;
}
#checkinsTable tr:hover td:last-child {
    background: var(--surface-2);
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}
.empty-state .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-soft);
    margin-bottom: 14px;
}
.empty-state p { font-size: 13.5px; }

/* ---------- TOAST ---------- */
.toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: var(--surface);
    padding: 12px 20px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: transform .25s, opacity .25s;
    z-index: 9999;
    pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- LOADER ---------- */
.loader {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row td { text-align: center; padding: 40px; color: var(--text-muted); }

/* ---------- COMPANY SETTINGS MODAL ---------- */
.tn-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
}
@media (min-width: 640px) {
    .tn-modal-overlay { align-items: center; }
}
.tn-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow: auto;
    padding: 22px;
    box-shadow: var(--shadow-lg);
}
.tn-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.tn-modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.tn-modal-sub   { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.tn-modal-section {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin: 16px 0 8px;
}
.tn-modal-section span {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    opacity: .8;
}
.tn-field {
    display: block;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 10px;
}
.tn-field input {
    width: 100%;
    margin-top: 5px;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
}
.tn-check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    color: var(--text);
    padding: 7px 0;
    cursor: pointer;
}
.tn-check input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}
.tn-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 18px;
}