/* ============================================================
   BackupSphere Shared Components
   Cards, stats, badges, buttons, empty states, etc.
   ============================================================ */

/* ── Base body ── */
body {
    font-family: var(--font-sans);
    background-color: var(--surface-page);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: var(--leading-normal);
    transition: background-color var(--transition), color var(--transition);
}

/* ── Cards (global upgrade — applies to all Bootstrap .card) ── */
.card {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), border-color var(--transition);
    color: var(--text-primary);
}
.card .card-header {
    background: var(--surface-card);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1rem 1.25rem;
    color: var(--text-primary);
    font-weight: 600;
}
.card .card-header:first-child {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}
.card .card-body {
    padding: 1.25rem;
}
.card .card-footer {
    background: var(--surface-inset);
    border-top: 1px solid var(--border-subtle);
    padding: 0.75rem 1.25rem;
}
.card .card-footer:last-child {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}
/* Alias for explicit usage */
.card-bs { /* inherits from .card */ }

/* ── Topbar ── */
.topbar {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.topbar-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    color: var(--text-primary);
    margin: 0;
}
.topbar-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.1rem;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ── Stat cards ── */
.stat-card {
    background: var(--surface-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--bs-brand-blue);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.stat-card.success { border-left-color: var(--color-success); }
.stat-card.warning { border-left-color: var(--color-warning); }
.stat-card.danger  { border-left-color: var(--color-danger); }
.stat-card.info    { border-left-color: var(--color-info); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-icon.brand   { background: rgba(0, 136, 255, 0.12); color: var(--bs-brand-blue); }
.stat-icon.success { background: var(--color-success-soft); color: var(--color-success); }
.stat-icon.warning { background: var(--color-warning-soft); color: var(--color-warning); }
.stat-icon.danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.stat-icon.info    { background: var(--color-info-soft);    color: var(--color-info); }

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    line-height: 1;
    color: var(--text-primary);
}
.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

/* ── Badges ── */
.badge-soft {
    background: var(--surface-overlay);
    color: var(--text-primary);
    font-weight: 600;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.4em 0.7em;
    font-size: 0.8rem;
}
.badge-soft.success { background: var(--color-success-soft); color: #16a34a; border-color: rgba(34,197,94,0.2); }
.badge-soft.warning { background: var(--color-warning-soft); color: #d97706; border-color: rgba(245,158,11,0.2); }
.badge-soft.danger  { background: var(--color-danger-soft);  color: #dc2626; border-color: rgba(239,68,68,0.2); }
.badge-soft.info    { background: var(--color-info-soft);    color: #2563eb; border-color: rgba(59,130,246,0.2); }

[data-theme="dark"] .badge-soft.success { color: #4ade80; }
[data-theme="dark"] .badge-soft.warning { color: #fbbf24; }
[data-theme="dark"] .badge-soft.danger  { color: #f87171; }
[data-theme="dark"] .badge-soft.info    { color: #60a5fa; }

.status-badge {
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
}

/* ── Provider badges ── */
.provider-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3em 0.65em;
    border-radius: var(--radius-sm);
    color: #fff;
}
.provider-badge.azure { background-color: var(--color-azure); }
.provider-badge.aws   { background-color: var(--color-aws);   }

/* ── Buttons ── */
.btn-brand {
    background: var(--bs-brand-gradient);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-pill);
    transition: all var(--transition);
}
.btn-brand:hover {
    background: linear-gradient(135deg, #00c8e0, #0070e0);
    border-color: rgba(0, 229, 255, 0.5);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 136, 255, 0.25);
    transform: translateY(-1px);
}
.btn-brand:active {
    transform: translateY(0);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.btn-icon .bi {
    line-height: 1;
    font-size: 1rem;
}
.btn-group-sm .btn-icon {
    width: 28px;
    height: 28px;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}
.empty-state-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.6;
}
.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.empty-state-text {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ── Log viewer ── */
.log-viewer {
    background: var(--slate-900);
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    border-radius: var(--radius-md);
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
}
.log-viewer .log-debug { color: #94a3b8; }
.log-viewer .log-info  { color: #60a5fa; }
.log-viewer .log-warn  { color: #fbbf24; }
.log-viewer .log-error { color: #f87171; }

/* ── Tables ── */
.table-bs thead th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom-width: 2px;
}
.table-bs tbody tr {
    transition: background-color var(--transition-fast);
}

[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-border-color: var(--border-default);
}
[data-theme="dark"] .table-light {
    --bs-table-bg: rgba(255, 255, 255, 0.04);
    --bs-table-color: var(--text-primary);
}

/* ── Breadcrumbs ── */
.breadcrumb-bs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.breadcrumb-bs a {
    color: var(--text-link);
    text-decoration: none;
}
.breadcrumb-bs a:hover {
    text-decoration: underline;
}
.breadcrumb-bs .separator {
    color: var(--text-muted);
    opacity: 0.5;
}

/* ── Skeleton loading ── */
.skeleton {
    background: linear-gradient(90deg,
        var(--surface-overlay) 25%,
        var(--surface-hover) 50%,
        var(--surface-overlay) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite ease-in-out;
    border-radius: var(--radius-sm);
}
.skeleton-text {
    height: 1em;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-xs);
}
.skeleton-card {
    height: 120px;
    border-radius: var(--radius-lg);
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Toast container ── */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}
.toast-bs {
    background: var(--surface-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    animation: toast-slide-in 0.3s ease;
}
.toast-bs.success { border-left: 4px solid var(--color-success); }
.toast-bs.warning { border-left: 4px solid var(--color-warning); }
.toast-bs.danger  { border-left: 4px solid var(--color-danger); }
.toast-bs.info    { border-left: 4px solid var(--color-info); }
.toast-bs .toast-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}
@keyframes toast-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ── Confirm modal ── */
.modal-bs .modal-content {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xl);
    background: var(--surface-card);
}
.modal-bs .modal-header {
    border-bottom: 1px solid var(--border-subtle);
}
.modal-bs .modal-footer {
    border-top: 1px solid var(--border-subtle);
}

/* ── Dark mode: forms ── */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--surface-raised);
    border-color: var(--border-default);
    color: var(--text-primary);
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--surface-raised);
    border-color: var(--bs-brand-cyan);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 229, 255, 0.15);
}
[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}
[data-theme="dark"] .input-group-text {
    background-color: var(--surface-card);
    border-color: var(--border-default);
    color: var(--text-secondary);
}

/* ── Dark mode: cards ── */
[data-theme="dark"] .card {
    background: var(--surface-card);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}
[data-theme="dark"] .card .card-header {
    background: var(--surface-raised);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}
/* Let subtle-bg card headers keep their tinted background */
[data-theme="dark"] .card .card-header.bg-warning-subtle {
    background-color: rgba(245, 158, 11, 0.12) !important;
    color: #fcd34d !important;
}
[data-theme="dark"] .card .card-header.bg-info-subtle {
    background-color: rgba(6, 182, 212, 0.12) !important;
    color: #67e8f9 !important;
}
[data-theme="dark"] .card .card-header.bg-success-subtle {
    background-color: rgba(34, 197, 94, 0.12) !important;
    color: #86efac !important;
}
[data-theme="dark"] .card .card-header.bg-danger-subtle {
    background-color: rgba(239, 68, 68, 0.12) !important;
    color: #fca5a5 !important;
}
[data-theme="dark"] .card .card-header.bg-primary-subtle {
    background-color: rgba(59, 130, 246, 0.12) !important;
    color: #93c5fd !important;
}
[data-theme="dark"] .card .card-footer {
    background: var(--surface-raised);
    border-color: var(--border-subtle);
}

/* ── Dark mode: alert overrides ── */
[data-theme="dark"] .alert {
    border-color: var(--border-subtle);
}
[data-theme="dark"] .alert-info {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.2);
}
[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.2);
}
[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.2);
}
[data-theme="dark"] .alert-success {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.2);
}

/* ── Dark mode: dropdown ── */
[data-theme="dark"] .dropdown-menu {
    background: var(--surface-raised);
    border-color: var(--border-default);
    color: var(--text-primary);
}
[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
    background: var(--surface-hover);
    color: var(--text-primary);
}
[data-theme="dark"] .dropdown-header {
    color: var(--text-muted);
}
[data-theme="dark"] .dropdown-divider {
    border-color: var(--border-default);
}

/* ── Dark mode: modal ── */
[data-theme="dark"] .modal-content {
    background: var(--surface-card);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}
[data-theme="dark"] .modal-header {
    border-color: var(--border-subtle);
}
[data-theme="dark"] .modal-footer {
    border-color: var(--border-subtle);
}
[data-theme="dark"] .btn-close {
    filter: invert(1);
}

/* ── Dark mode: text utilities ── */
[data-theme="dark"] .text-muted { color: var(--text-secondary) !important; }
[data-theme="dark"] .text-dark  { color: var(--text-primary) !important; }
[data-theme="dark"] .bg-light   { background-color: var(--surface-raised) !important; }
[data-theme="dark"] .border     { border-color: var(--border-default) !important; }
[data-theme="dark"] .border-bottom { border-color: var(--border-default) !important; }
[data-theme="dark"] .bg-white   { background-color: var(--surface-card) !important; }

/* ── Links ── */
a { color: var(--text-link); }
a:hover { color: var(--bs-brand-blue); }

/* ── Progress bar ── */
.progress-bs {
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--surface-overlay);
    overflow: hidden;
}
.progress-bs .progress-bar {
    background: var(--bs-brand-gradient);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

/* ── Global table header upgrade ── */
.table thead th {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-default);
    white-space: nowrap;
}
.table-hover tbody tr {
    transition: background-color var(--transition-fast);
}

/* ── List group dark mode ── */
[data-theme="dark"] .list-group-item {
    background-color: var(--surface-card);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

/* ── Badge base enhancement ── */
.badge { font-weight: 600; }

/* ── Pagination dark mode ── */
[data-theme="dark"] .page-link {
    background-color: var(--surface-card);
    border-color: var(--border-default);
    color: var(--text-primary);
}
[data-theme="dark"] .page-item.active .page-link {
    background-color: var(--bs-brand-blue);
    border-color: var(--bs-brand-blue);
    color: #fff;
}
[data-theme="dark"] .page-item.disabled .page-link {
    background-color: var(--surface-raised);
    color: var(--text-muted);
}

/* ── Cloud provider icon colors (for sidebar / inline) ── */
.cloud-azure, .cloud-icon-azure { color: var(--color-azure) !important; }
.cloud-aws, .cloud-icon-aws     { color: var(--color-aws) !important; }

/* ── Auth page styles ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--slate-900) 0%, #0a1628 50%, #071020 100%);
    padding: 2rem 1rem;
}
.auth-card {
    background: var(--surface-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-subtle);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
}
.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.auth-brand h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    background: var(--bs-brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}
.auth-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 2rem;
}
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
}
.auth-footer, .auth-footer a {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
}
.auth-footer a:hover {
    color: var(--bs-brand-cyan);
}

[data-theme="dark"] .auth-card {
    background: var(--surface-raised);
    border-color: var(--border-default);
}

/* ── Code block ── */
[data-theme="dark"] code {
    color: var(--bs-brand-cyan);
}
[data-theme="dark"] pre {
    background: var(--surface-raised);
    color: var(--text-primary);
}

/* ── Form check dark mode ── */
[data-theme="dark"] .form-check-input {
    background-color: var(--surface-raised);
    border-color: var(--border-default);
}
[data-theme="dark"] .form-check-input:checked {
    background-color: var(--bs-brand-blue);
    border-color: var(--bs-brand-blue);
}

/* ── Nav tabs dark mode ── */
[data-theme="dark"] .nav-tabs {
    border-bottom-color: var(--border-default);
}
[data-theme="dark"] .nav-tabs .nav-link {
    color: var(--text-secondary);
}
[data-theme="dark"] .nav-tabs .nav-link:hover {
    border-color: var(--border-default) var(--border-default) transparent;
}
[data-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--surface-card);
    border-color: var(--border-default) var(--border-default) var(--surface-card);
    color: var(--text-primary);
}
