/*
 * Repair Tracker — professional mobile-first design system
 */

@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

:root {
    --rt-font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
    --rt-bg: #f1f5f9;
    --rt-surface: #ffffff;
    --rt-surface-elevated: #ffffff;
    --rt-border: #e2e8f0;
    --rt-border-light: #f1f5f9;
    --rt-text: #0f172a;
    --rt-text-muted: #64748b;
    --rt-text-subtle: #94a3b8;
    --rt-primary: #2563eb;
    --rt-primary-hover: #1d4ed8;
    --rt-primary-soft: #eff6ff;
    --rt-primary-muted: #dbeafe;
    --rt-success: #059669;
    --rt-success-soft: #ecfdf5;
    --rt-warning: #d97706;
    --rt-warning-soft: #fffbeb;
    --rt-danger: #dc2626;
    --rt-danger-soft: #fef2f2;
    --rt-info: #0284c7;
    --rt-info-soft: #f0f9ff;
    --rt-radius: 0.875rem;
    --rt-radius-sm: 0.625rem;
    --rt-radius-lg: 1.125rem;
    --rt-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --rt-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --rt-shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
    --rt-nav-height: 3.75rem;
    --rt-bottom-nav-height: 4.25rem;
    --bs-primary: var(--rt-primary);
    --bs-primary-rgb: 37, 99, 235;
    --bs-body-font-family: var(--rt-font);
    --bs-body-bg: var(--rt-bg);
    --bs-body-color: var(--rt-text);
    --bs-border-color: var(--rt-border);
    --bs-border-radius: var(--rt-radius-sm);
    --bs-border-radius-lg: var(--rt-radius);
}

/* ── Base ─────────────────────────────────────────────── */

body {
    font-family: var(--rt-font);
    background: var(--rt-bg);
    color: var(--rt-text);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--rt-primary);
}

a:hover {
    color: var(--rt-primary-hover);
}

/* ── Layout ───────────────────────────────────────────── */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 72rem;
    margin-inline: auto;
    padding: 1rem 1rem 1.25rem;
}

.app-main--auth {
    max-width: 28rem;
    padding-top: 2rem;
}

@media (min-width: 768px) {
    .app-main {
        padding: 1.5rem 1.5rem 2rem;
    }

    .app-main--auth {
        padding-top: 3rem;
    }
}

.pb-nav {
    padding-bottom: calc(var(--rt-bottom-nav-height) + 1rem + env(safe-area-inset-bottom));
}

@media (min-width: 992px) {
    .pb-nav {
        padding-bottom: 2rem;
    }
}

/* ── Top navbar ───────────────────────────────────────── */

.app-navbar {
    background: var(--rt-surface);
    border-bottom: 1px solid var(--rt-border);
    box-shadow: var(--rt-shadow-sm);
    min-height: var(--rt-nav-height);
    padding-block: 0.5rem;
}

.app-navbar .navbar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--rt-text) !important;
    letter-spacing: -0.02em;
}

.app-navbar .brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: var(--rt-primary-soft);
    color: var(--rt-primary);
    font-size: 1rem;
    margin-right: 0.5rem;
}

.app-navbar .nav-link {
    color: var(--rt-text-muted) !important;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: var(--rt-radius-sm);
    padding: 0.5rem 0.75rem !important;
    transition: color 0.15s, background 0.15s;
}

.app-navbar .nav-link:hover {
    color: var(--rt-text) !important;
    background: var(--rt-border-light);
}

.app-navbar .nav-link.active {
    color: var(--rt-primary) !important;
    background: var(--rt-primary-soft);
}

.app-navbar .navbar-toggler {
    border: 1px solid var(--rt-border);
    padding: 0.35rem 0.55rem;
}

.app-navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 3px var(--rt-primary-muted);
}

/* ── Bottom navigation (mobile) ───────────────────────── */

.bottom-nav {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--rt-border);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 1030;
}

.bottom-nav-inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 0.35rem 0.5rem 0.5rem;
    max-width: 28rem;
    margin-inline: auto;
}

.bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    min-width: 3.5rem;
    min-height: 2.75rem;
    padding: 0.35rem 0.5rem;
    color: var(--rt-text-subtle);
    text-decoration: none;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    border-radius: var(--rt-radius-sm);
    border: none;
    background: transparent;
    transition: color 0.15s, transform 0.15s;
}

.bottom-nav-link i {
    font-size: 1.25rem;
}

.bottom-nav-link.active {
    color: var(--rt-primary);
}

.bottom-nav-link:active:not(.bottom-nav-link--fab) {
    transform: scale(0.95);
}

.bottom-nav-link--fab {
    position: relative;
    top: -0.75rem;
    min-width: 3.25rem;
    min-height: 3.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rt-primary) 0%, #1d4ed8 100%);
    color: #fff !important;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.45);
    justify-content: center;
    gap: 0;
}

.bottom-nav-link--fab i {
    font-size: 1.5rem;
}

.bottom-nav-link--fab span {
    display: none;
}

/* ── Page headers ─────────────────────────────────────── */

.page-header {
    margin-bottom: 1.25rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.25rem;
    color: var(--rt-text);
}

.page-header p {
    color: var(--rt-text-muted);
    font-size: 0.9rem;
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .page-header h1 {
        font-size: 1.75rem;
    }
}

/* ── Cards ────────────────────────────────────────────── */

.rt-card {
    background: var(--rt-surface);
    border: 1px solid var(--rt-border);
    border-radius: var(--rt-radius);
    box-shadow: var(--rt-shadow-sm);
    overflow: hidden;
}

.rt-card + .rt-card {
    margin-top: 0.75rem;
}

.rt-card-header {
    padding: 0.875rem 1rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--rt-text);
    background: var(--rt-border-light);
    border-bottom: 1px solid var(--rt-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rt-card-header i {
    color: var(--rt-primary);
}

.rt-card-header--accent {
    background: linear-gradient(135deg, var(--rt-primary) 0%, #1d4ed8 100%);
    color: #fff;
    border-bottom: none;
}

.rt-card-header--accent i {
    color: rgba(255, 255, 255, 0.9);
}

.rt-card-body {
    padding: 1rem;
}

/* Stat cards (dashboard) */
.stat-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--rt-surface);
    border: 1px solid var(--rt-border);
    border-radius: var(--rt-radius);
    padding: 1rem;
    height: 100%;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--rt-shadow);
    border-color: var(--rt-primary-muted);
    color: inherit;
}

.stat-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.625rem;
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.stat-card__icon--primary {
    background: var(--rt-primary-soft);
    color: var(--rt-primary);
}

.stat-card__icon--success {
    background: var(--rt-success-soft);
    color: var(--rt-success);
}

.stat-card__icon--warning {
    background: var(--rt-warning-soft);
    color: var(--rt-warning);
}

.stat-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--rt-text);
}

.stat-card__label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--rt-text-muted);
    margin-top: 0.25rem;
}

/* Job cards */
.job-card {
    background: var(--rt-surface);
    border: 1px solid var(--rt-border);
    border-radius: var(--rt-radius);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.job-card:hover {
    box-shadow: var(--rt-shadow);
    border-color: var(--rt-primary-muted);
}

.job-card:active {
    transform: scale(0.99);
}

.job-card .card-body {
    padding: 1rem;
}

.job-card__ref {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--rt-text);
    letter-spacing: -0.01em;
}

.job-card__meta {
    font-size: 0.85rem;
    color: var(--rt-text-muted);
}

.job-card__device {
    font-size: 0.85rem;
    color: var(--rt-text);
    margin-top: 0.35rem;
}

.job-card__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--rt-text-subtle);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--rt-border-light);
}

/* ── Status badges ────────────────────────────────────── */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.65rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    border-radius: 2rem;
    white-space: nowrap;
}

.status-received { background: #f1f5f9; color: #475569; }
.status-diagnosing { background: var(--rt-info-soft); color: #0369a1; }
.status-repair_in_progress { background: var(--rt-primary-soft); color: var(--rt-primary); }
.status-ready_for_dispatch { background: var(--rt-success-soft); color: var(--rt-success); }
.status-delivered { background: #f1f5f9; color: #334155; }
.status-cancelled { background: var(--rt-danger-soft); color: var(--rt-danger); }

/* ── Status filter chips ──────────────────────────────── */

.status-filter-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.status-filter-scroll::-webkit-scrollbar {
    display: none;
}

.status-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--rt-border);
    border-radius: 2rem;
    background: var(--rt-surface);
    color: var(--rt-text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.15s;
}

.status-filter-chip:hover {
    border-color: var(--rt-primary-muted);
    color: var(--rt-text);
}

.status-filter-chip.active {
    background: var(--rt-primary);
    border-color: var(--rt-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.status-filter-chip .badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.2em 0.5em;
    background: var(--rt-border-light) !important;
    color: var(--rt-text-muted) !important;
}

.status-filter-chip.active .badge {
    background: rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
}

/* ── Buttons ──────────────────────────────────────────── */

.btn {
    font-weight: 600;
    border-radius: var(--rt-radius-sm);
    letter-spacing: -0.01em;
    transition: transform 0.1s, box-shadow 0.15s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--rt-primary);
    border-color: var(--rt-primary);
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--rt-primary-hover);
    border-color: var(--rt-primary-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-outline-primary {
    color: var(--rt-primary);
    border-color: var(--rt-border);
    background: var(--rt-surface);
}

.btn-outline-primary:hover {
    background: var(--rt-primary-soft);
    border-color: var(--rt-primary-muted);
    color: var(--rt-primary-hover);
}

.btn-success {
    background: var(--rt-success);
    border-color: var(--rt-success);
}

.btn-lg {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
}

/* ── Forms ────────────────────────────────────────────── */

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--rt-text);
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    border: 1px solid var(--rt-border);
    border-radius: var(--rt-radius-sm);
    padding: 0.625rem 0.875rem;
    font-size: 0.95rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--rt-primary);
    box-shadow: 0 0 0 3px var(--rt-primary-muted);
}

.form-check-input:checked {
    background-color: var(--rt-primary);
    border-color: var(--rt-primary);
}

/* ── Alerts ───────────────────────────────────────────── */

.alert {
    border: none;
    border-radius: var(--rt-radius);
    font-size: 0.9rem;
    border-left: 4px solid transparent;
}

.alert-info {
    background: var(--rt-info-soft);
    color: #0c4a6e;
    border-left-color: var(--rt-info);
}

.alert-warning {
    background: var(--rt-warning-soft);
    color: #92400e;
    border-left-color: var(--rt-warning);
}

.alert-success {
    background: var(--rt-success-soft);
    color: #065f46;
    border-left-color: var(--rt-success);
}

.alert-danger {
    background: var(--rt-danger-soft);
    color: #991b1b;
    border-left-color: var(--rt-danger);
}

/* ── Auth pages ───────────────────────────────────────── */

.auth-card {
    background: var(--rt-surface);
    border: 1px solid var(--rt-border);
    border-radius: var(--rt-radius-lg);
    box-shadow: var(--rt-shadow-lg);
    padding: 1.75rem;
}

@media (min-width: 576px) {
    .auth-card {
        padding: 2rem 2.25rem;
    }
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-brand__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, var(--rt-primary) 0%, #1d4ed8 100%);
    color: #fff;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.35rem;
}

.auth-brand p {
    color: var(--rt-text-muted);
    font-size: 0.9rem;
    margin-bottom: 0;
}

.auth-divider {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rt-text-subtle);
    margin: 1.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--rt-border);
}

/* ── Detail page ──────────────────────────────────────── */

.detail-grid {
    display: grid;
    gap: 0.75rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--rt-border-light);
    font-size: 0.9rem;
}

.detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-row__label {
    color: var(--rt-text-muted);
    flex-shrink: 0;
}

.detail-row__value {
    text-align: right;
    font-weight: 500;
    color: var(--rt-text);
}

/* ── Billing ──────────────────────────────────────────── */

.plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 2rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.plan-badge--active {
    background: var(--rt-success-soft);
    color: var(--rt-success);
}

.plan-badge--expired {
    background: var(--rt-danger-soft);
    color: var(--rt-danger);
}

/* ── Empty state ──────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 2.5rem 1.5rem;
}

.empty-state i {
    font-size: 2.5rem;
    color: var(--rt-text-subtle);
    margin-bottom: 0.75rem;
}

.empty-state p {
    color: var(--rt-text-muted);
    margin-bottom: 1.25rem;
}

/* ── Section title ────────────────────────────────────── */

.section-title {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--rt-text-subtle);
    margin-bottom: 0.75rem;
}

/* ── Pagination ───────────────────────────────────────── */

.pagination .page-link {
    border-color: var(--rt-border);
    color: var(--rt-text-muted);
    border-radius: var(--rt-radius-sm) !important;
    margin: 0 0.15rem;
    font-weight: 500;
}

.pagination .page-item.active .page-link {
    background: var(--rt-primary);
    border-color: var(--rt-primary);
}

/* ── Touch targets (mobile) ───────────────────────────── */

@media (max-width: 575.98px) {
    .btn {
        min-height: 2.75rem;
    }

    .form-control,
    .form-select {
        min-height: 2.75rem;
        font-size: 1rem;
    }
}

/* ── Bootstrap card overrides ─────────────────────────── */

.card {
    border: 1px solid var(--rt-border);
    border-radius: var(--rt-radius);
    box-shadow: var(--rt-shadow-sm);
}

.card-header {
    background: var(--rt-border-light);
    border-bottom: 1px solid var(--rt-border);
    font-weight: 600;
}

.list-group-item {
    border-color: var(--rt-border-light);
}
