/* ===========================================
   MedOrbit v2 - Reusable Components
   =========================================== */

/* === Skeleton Loader === */
.skeleton {
    background: linear-gradient(90deg, var(--bg-soft) 25%, var(--border) 50%, var(--bg-soft) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--r-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === Card === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    transition: all var(--t-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 14px 16px;
}

.card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
    display: flex;
    gap: 8px;
}

/* === Button === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--r-md);
    transition: all var(--t-fast);
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--primary-50);
    color: var(--primary);
    border-color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-soft);
}

.btn-ghost:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-icon {
    padding: 8px;
}

/* === Badge === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--r-full);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-primary {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

[data-theme="dark"] .badge-primary { background: rgba(37, 99, 235, 0.2); }
[data-theme="dark"] .badge-success { background: rgba(16, 185, 129, 0.2); }
[data-theme="dark"] .badge-warning { background: rgba(245, 158, 11, 0.2); }
[data-theme="dark"] .badge-danger { background: rgba(239, 68, 68, 0.2); }
[data-theme="dark"] .badge-info { background: rgba(6, 182, 212, 0.2); }

/* === Spinner === */
.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === Divider === */
.divider {
    height: 1px;
    background: var(--border);
    margin: 12px 0;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-mute);
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-soft);
    color: var(--text-faint);
    border-radius: var(--r-full);
    font-size: 32px;
}

.empty-state h3 {
    font-size: 16px;
    color: var(--text);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    line-height: 1.6;
}

/* === Rating === */
.rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.rating-stars {
    color: var(--accent);
    letter-spacing: 1px;
}

.rating-value {
    color: var(--text-soft);
    font-size: 12px;
}

/* === Alert === */
.alert {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 20px;
}

.alert.error {
    display: flex;
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.alert.success {
    display: flex;
    background: rgba(16, 185, 129, 0.08);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.25);
}

[data-theme="dark"] .alert.error { background: rgba(239, 68, 68, 0.15); }
[data-theme="dark"] .alert.success { background: rgba(16, 185, 129, 0.15); }

/* === Button loading state === */
.btn .btn-spinner {
    display: none;
}

.btn.loading .btn-spinner {
    display: inline-flex;
}

.btn.loading .btn-label {
    display: none;
}

.btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.btn-primary .btn-spinner {
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
}

/* === Generic confirm/detail modal (cancel appointment, delete post, etc.) === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal, 1000);
    padding: 20px;
}

.modal-box {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    padding: 22px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal-box h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.modal-box p {
    font-size: 13.5px;
    color: var(--text-mute);
    margin-bottom: 14px;
    line-height: 1.7;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

@media (max-width: 480px) {
    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
    }
}

/* === Utility === */
.hidden {
    display: none !important;
}

/* === Responsive: touch tap targets ===
   Desktop keeps the compact sizing above (mouse pointer, not touch); below
   1024px (tablet and phone are both touch, not just phone) every
   button-like control meets the ~44px minimum tap target. */
@media (max-width: 1024px) {
    .btn {
        min-height: 44px;
        padding-top: 11px;
        padding-bottom: 11px;
    }

    .btn-sm {
        min-height: 44px;
        padding-top: 10px;
        padding-bottom: 10px;
        font-size: 13px;
    }

    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }
}