/* =========================================================================
   Backups Manager — Design System
   A custom theme layer built on top of Bootstrap 5.
   ========================================================================= */

:root {
    --bs-primary: #6366f1;
    --brand:        #6366f1;
    --brand-600:    #4f46e5;
    --brand-700:    #4338ca;
    --brand-soft:   #eef2ff;

    --ink:       #0f172a;   /* slate-900 */
    --ink-2:     #334155;   /* slate-700 */
    --muted:     #64748b;   /* slate-500 */
    --muted-2:   #94a3b8;   /* slate-400 */
    --line:      #e2e8f0;   /* slate-200 */
    --line-soft: #eef2f6;
    --surface:   #ffffff;
    --canvas:    #f6f7fb;

    --ok:    #16a34a;
    --warn:  #d97706;
    --danger:#dc2626;
    --info:  #0ea5e9;

    --radius:    14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow:    0 4px 16px -4px rgba(15, 23, 42, .10), 0 2px 6px -2px rgba(15, 23, 42, .06);
    --shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, .22);
}

* { -webkit-font-smoothing: antialiased; }

body {
    font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background:
        radial-gradient(1200px 480px at 100% -10%, #eef2ff 0%, rgba(238,242,255,0) 60%),
        var(--canvas);
    color: var(--ink-2);
    min-height: 100vh;
}

/* ------------------------------------------------------------------ Nav */
.app-nav {
    position: sticky;
    top: 0;
    z-index: 1030;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.app-nav .brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -.01em;
}
.app-nav .brand-badge {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-700) 100%);
    box-shadow: 0 6px 14px -4px rgba(79, 70, 229, .55);
    font-size: 1.05rem;
}
.app-nav .nav-scroll {
    display: flex;
    gap: .15rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.app-nav .nav-scroll::-webkit-scrollbar { display: none; }
.nav-item-link {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    white-space: nowrap;
    padding: .5rem .8rem;
    border-radius: 9px;
    font-weight: 600;
    font-size: .9rem;
    color: var(--muted);
    text-decoration: none;
    transition: all .15s ease;
    border: 1px solid transparent;
}
.nav-item-link i { font-size: 1rem; opacity: .85; }
.nav-item-link:hover { color: var(--ink); background: var(--line-soft); }
.nav-item-link.active {
    color: var(--brand-700);
    background: var(--brand-soft);
    border-color: #e0e7ff;
}
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: .35rem .55rem .35rem .35rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
}
.user-chip:hover { border-color: var(--muted-2); }
.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #a5b4fc, var(--brand-600));
    color: #fff; font-weight: 800; font-size: .8rem;
}

/* --------------------------------------------------------------- Header */
.page-head {
    padding: 1.9rem 0 .4rem;
}
.page-head .eyebrow {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: .7rem;
    font-weight: 800;
    color: var(--brand-600);
}
.page-head h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -.02em;
    margin: .1rem 0 0;
}
.page-head p { color: var(--muted); margin: .25rem 0 0; font-size: .92rem; }

/* ---------------------------------------------------------------- Panel */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--line-soft);
}
.panel-head h2 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--ink);
    margin: 0;
    display: flex; align-items: center; gap: .5rem;
}
.panel-head .count-pill {
    font-size: .72rem;
    font-weight: 800;
    color: var(--brand-700);
    background: var(--brand-soft);
    border-radius: 999px;
    padding: .12rem .55rem;
}
.panel-body { padding: 1.1rem 1.35rem 1.35rem; }

/* Warning-toned panel (e.g. unprotected databases) */
.panel-warn {
    border-color: #fde68a;
    background: linear-gradient(180deg, #fffbeb 0%, var(--surface) 60%);
}
.panel-warn .panel-head { border-bottom-color: #fde68a; }
.panel-warn .count-pill { color: var(--warn); background: #fef3c7; }

/* Clickable database chip — links a bare database to a new schedule */
.db-chip {
    display: inline-flex;
    align-items: center;
    font-size: .82rem;
    font-weight: 700;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .32rem .7rem;
    text-decoration: none;
    transition: border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.db-chip:hover {
    color: var(--brand-700);
    border-color: var(--brand-600);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.db-chip .bi-plus-circle-fill { color: var(--muted-2); }
.db-chip:hover .bi-plus-circle-fill { color: var(--brand-600); }

/* ----------------------------------------------------------- Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .15s ease;
    position: relative;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-icon {
    width: 40px; height: 40px;
    border-radius: 11px;
    display: grid; place-items: center;
    font-size: 1.15rem;
    margin-bottom: .7rem;
}
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: var(--ink); line-height: 1; }
.stat-card .stat-label { font-size: .82rem; color: var(--muted); font-weight: 600; margin-top: .3rem; }
.tint-indigo { background: #eef2ff; color: #4f46e5; }
.tint-green  { background: #dcfce7; color: #16a34a; }
.tint-amber  { background: #fef3c7; color: #d97706; }
.tint-red    { background: #fee2e2; color: #dc2626; }
.tint-sky    { background: #e0f2fe; color: #0284c7; }
.tint-slate  { background: #f1f5f9; color: #475569; }

/* --------------------------------------------------------- Quick action */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.quick-card {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    transition: all .15s ease;
}
.quick-card:hover {
    border-color: #c7d2fe;
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    color: var(--ink);
}
.quick-card .qc-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: grid; place-items: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.quick-card .qc-title { font-weight: 800; font-size: .98rem; }
.quick-card .qc-sub { font-size: .8rem; color: var(--muted); font-weight: 500; }
.quick-card .qc-arrow { margin-left: auto; color: var(--muted-2); transition: transform .15s ease; }
.quick-card:hover .qc-arrow { transform: translateX(3px); color: var(--brand-600); }

/* ------------------------------------------------------------ Filter bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
    margin-bottom: 1.1rem;
}
.filter-search {
    position: relative;
    flex: 1 1 240px;
    min-width: 200px;
}
.filter-search i {
    position: absolute;
    left: .85rem; top: 50%;
    transform: translateY(-50%);
    color: var(--muted-2);
    font-size: 1rem;
    pointer-events: none;
}
.filter-search .form-control { padding-left: 2.4rem; }
.filter-bar .form-select,
.filter-bar .form-control {
    border-radius: var(--radius-sm);
    border-color: var(--line);
    font-size: .9rem;
    font-weight: 600;
    color: var(--ink-2);
    box-shadow: var(--shadow-sm);
}
.filter-bar .form-select { width: auto; min-width: 160px; }
.filter-bar .form-control:focus,
.filter-bar .form-select:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 .2rem rgba(99, 102, 241, .18);
}
.filter-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .8rem; font-weight: 700;
    color: var(--muted);
    text-decoration: none;
    padding: .45rem .7rem;
    border-radius: var(--radius-sm);
}
.filter-chip:hover { color: var(--danger); background: #fef2f2; }

/* --------------------------------------------------------------- Tables */
.table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    overflow-x: auto;
}
.table {
    margin: 0;
    --bs-table-bg: transparent;
    font-size: .9rem;
    color: var(--ink-2);
}
.table > thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .7rem;
    font-weight: 800;
    padding: .7rem 1rem;
    white-space: nowrap;
}
.table > tbody td {
    padding: .8rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--line-soft);
}
.table > tbody tr:last-child td { border-bottom: 0; }
.table.table-hover > tbody tr:hover > * { background: #f9fafb; }
.table .mono { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }
.cell-strong { color: var(--ink); font-weight: 700; }
.cell-key {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: .82rem;
    background: var(--line-soft);
    padding: .12rem .45rem;
    border-radius: 6px;
    color: var(--ink-2);
}

/* --------------------------------------------------------------- Badges */
.badge-status {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .72rem; font-weight: 800;
    padding: .28rem .6rem;
    border-radius: 999px;
    text-transform: capitalize;
    letter-spacing: .01em;
    line-height: 1;
}
.badge-status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-success { color: #15803d; background: #dcfce7; }
.st-partial { color: #b45309; background: #fef3c7; }
.st-failed  { color: #b91c1c; background: #fee2e2; }
.st-running { color: #0369a1; background: #e0f2fe; }
.st-pending { color: #475569; background: #f1f5f9; }
.badge-status.st-running .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.35} }

.pill-yes { color: #15803d; background: #dcfce7; }
.pill-no  { color: #475569; background: #f1f5f9; }
.pill-flag {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .72rem; font-weight: 800; padding: .22rem .55rem;
    border-radius: 999px;
}

/* -------------------------------------------------------------- Buttons */
.btn { font-weight: 700; border-radius: var(--radius-sm); font-size: .875rem; }
.btn-sm { padding: .32rem .7rem; font-size: .8rem; border-radius: 8px; }
.btn-primary {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-600) 100%);
    border: none;
    box-shadow: 0 6px 14px -6px rgba(79, 70, 229, .6);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-700) 100%); }
.btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    border: none;
    box-shadow: 0 6px 14px -6px rgba(22, 163, 74, .55);
}
.btn-success:hover { background: linear-gradient(135deg, #16a34a, #15803d); }
.btn-outline-secondary { border-color: var(--line); color: var(--ink-2); background: #fff; }
.btn-outline-secondary:hover { background: var(--line-soft); color: var(--ink); border-color: var(--muted-2); }
.btn-secondary { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-secondary:hover { background: var(--line-soft); color: var(--ink); }
.btn-danger { background: #fff; border: 1px solid #fecaca; color: #dc2626; box-shadow: none; }
.btn-danger:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
.btn-outline-warning { border-color: #fcd34d; color: #b45309; }
.btn-outline-warning:hover { background: #fffbeb; color: #92400e; border-color: #f59e0b; }
.btn-icon { display: inline-flex; align-items: center; gap: .35rem; }
.action-cell { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Forms */
.form-label { font-weight: 700; font-size: .85rem; color: var(--ink-2); margin-bottom: .35rem; }
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--line);
    padding: .55rem .8rem;
    color: var(--ink);
}
.form-control:focus, .form-select:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 .2rem rgba(99, 102, 241, .18);
}
.form-text { color: var(--muted); }

/* --------------------------------------------------------------- Alerts */
.alert { border: 0; border-radius: var(--radius-sm); font-weight: 600; font-size: .9rem; }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-info    { background: #eff6ff; color: #1e40af; }
.alert-icon { display: flex; align-items: flex-start; gap: .6rem; }
.alert-icon i { font-size: 1.15rem; margin-top: .05rem; }

/* --------------------------------------------------------- Empty states */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty-state .es-icon {
    width: 64px; height: 64px;
    border-radius: 18px;
    display: inline-grid; place-items: center;
    background: var(--brand-soft);
    color: var(--brand-600);
    font-size: 1.8rem;
    margin-bottom: .9rem;
}
.empty-state h3 { color: var(--ink); font-weight: 800; font-size: 1.05rem; margin-bottom: .3rem; }
.empty-state p { font-size: .9rem; margin-bottom: 1rem; }

/* ---------------------------------------------------------- Live badge */
.live-tag {
    display: inline-flex; align-items: center; gap: .45rem;
    font-size: .78rem; font-weight: 800; color: #0369a1;
    background: #e0f2fe; border-radius: 999px; padding: .3rem .7rem;
}
.live-tag .spinner-border { width: .8rem; height: .8rem; border-width: .15em; }

/* --------------------------------------------------------- Pagination */
.pagination { --bs-pagination-color: var(--muted); --bs-pagination-active-bg: var(--brand-600); --bs-pagination-active-border-color: var(--brand-600); }
.page-link { border-radius: 8px !important; margin: 0 2px; border-color: var(--line); font-weight: 700; font-size: .85rem; }

/* ------------------------------------------------------------ Utilities */
.text-muted-2 { color: var(--muted) !important; }
.hstack-gap { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.link-arrow { font-weight: 700; font-size: .85rem; color: var(--brand-600); text-decoration: none; }
.link-arrow:hover { color: var(--brand-700); text-decoration: underline; }

@media (max-width: 575.98px) {
    .page-head h1 { font-size: 1.35rem; }
    .panel-body { padding: 1rem; }
}
