/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
    --brand:      #2563eb;
    --brand-dark: #1d4ed8;
    --border:     #e5e7eb;
    --muted:      #6b7280;
    --radius:     12px;
    --radius-sm:  8px;
}

/* ─── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    /* Respect iPhone home-bar / notch */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── Login ───────────────────────────────────────────────────────────────── */
.login-bg {
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

.login-logo {
    width: 56px;
    height: 56px;
    background: var(--brand);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: white;
    margin: 0 auto 1rem;
}

/* ─── Navbar ──────────────────────────────────────────────────────────────── */
.navbar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
}

.navbar-toggler:focus {
    box-shadow: none;
}

/* Desktop: active link underline indicator */
@media (min-width: 768px) {
    .navbar-nav .nav-link {
        padding-top: 0.9rem;
        padding-bottom: calc(0.9rem - 3px);
        border-bottom: 3px solid transparent;
        transition: border-color 0.15s;
        font-size: 0.9rem;
    }
    .navbar-nav .nav-link:hover {
        border-bottom-color: rgba(255, 255, 255, 0.35);
    }
    .navbar-nav .nav-link.active {
        border-bottom-color: rgba(255, 255, 255, 0.85);
    }
}

/* Mobile: active link left-border indicator */
@media (max-width: 767px) {
    .navbar-nav .nav-link {
        padding: 0.6rem 0.5rem;
        border-left: 3px solid transparent;
        font-size: 0.95rem;
    }
    .navbar-nav .nav-link.active {
        border-left-color: rgba(255, 255, 255, 0.75);
        background: rgba(255, 255, 255, 0.06);
        border-radius: 0 6px 6px 0;
    }
}

/* User area — mobile: inside collapse with top separator */
.nav-user-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    padding: 0.75rem 0 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.nav-username {
    flex: 1;
    font-weight: 500;
    font-size: 0.875rem;
}

@media (min-width: 768px) {
    .nav-user-area {
        padding: 0;
        margin-top: 0;
        border-top: none;
    }
    .nav-username {
        flex: none;
        margin-right: 0.25rem;
    }
}

/* ─── Page layout ─────────────────────────────────────────────────────────── */
/* Vertical rhythm only — horizontal padding comes from .container inside */
.page-body {
    padding-top: 1.25rem;
    padding-bottom: 2rem;
}

@media (min-width: 576px) {
    .page-body {
        padding-top: 1.75rem;
    }
}

@media (min-width: 992px) {
    .page-body {
        padding-top: 2rem;
    }
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.card-header {
    border-bottom: 1px solid #f3f4f6;
    padding: 0.875rem 1rem;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

@media (min-width: 576px) {
    .card-header {
        padding: 1rem 1.25rem;
    }
}

/* ─── Avatar ──────────────────────────────────────────────────────────────── */
.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--brand);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* ─── Contact list ────────────────────────────────────────────────────────── */
.contact-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}

.contact-item:last-child {
    border-bottom: none;
}

@media (hover: hover) {
    .contact-item:hover {
        background: #f9fafb;
    }
}

@media (min-width: 576px) {
    .contact-item {
        padding: 0.875rem 1.25rem;
    }
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-phone {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-phone .bi {
    color: var(--brand);
    opacity: 0.7;
    font-size: 0.72rem;
    vertical-align: 0.05em;
}

.contact-actions {
    display: flex;
    gap: 0.375rem;
    flex-shrink: 0;
}

/* Touch-sized action buttons */
.contact-actions .btn {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ─── Search box ──────────────────────────────────────────────────────────── */
.search-box {
    width: 100%;
}

@media (min-width: 576px) {
    .search-box {
        width: 240px;
    }
}

/* ─── Stat card ───────────────────────────────────────────────────────────── */
.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

/* ─── Sidebar layout ─────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: calc(100vh - 58px);
}

.app-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: white;
    border-right: 1px solid var(--border);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.75rem;
}

.sidebar-section {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 0.75rem 0.875rem 0.25rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.65rem 0.875rem;
    border-radius: var(--radius-sm);
    color: #374151;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.12s;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: #111827;
}

.sidebar-link.active {
    background: #eff6ff;
    color: var(--brand);
    font-weight: 600;
}

.sidebar-link .bi {
    font-size: 1rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* ─── App footer ─────────────────────────────────────────────────────────── */
.app-footer {
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    margin-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
}

.app-footer a {
    color: var(--muted);
    text-decoration: none;
}

.app-footer a:hover {
    color: var(--brand);
    text-decoration: underline;
}

/* ─── Auth-guard flash prevention ────────────────────────────────────────── */
.protected-page {
    visibility: hidden;
}
