/* ═══════════════════════════════════════════════════════════════
   SimpleTracker — Core Stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Brand */
    --primary:       #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --primary-rgb:   79, 70, 229;

    /* Semantic */
    --success:       #10B981;
    --success-light: #ECFDF5;
    --warning:       #F59E0B;
    --warning-light: #FFFBEB;
    --danger:        #EF4444;
    --danger-light:  #FEF2F2;
    --info:          #3B82F6;
    --info-light:    #EFF6FF;

    /* Neutrals */
    --gray-50:  #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    /* Layout */
    --nav-height:  60px;
    --sidebar-w:   260px;
    --content-max: 1200px;
    --radius:      8px;
    --radius-sm:   4px;
    --radius-lg:   12px;
    --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg:   0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

    /* Transitions */
    --ease:  cubic-bezier(.4,0,.2,1);
    --speed: .2s;
}

/* Large screen scaling — proportional zoom for displays wider than 1920px */
/* vh units stay relative to the physical viewport, so min-h-screen/.min-h-screen
    elements are corrected per breakpoint: override = 100vh / zoom */
@media (min-width: 1921px) {
    html { zoom: 1.2; }
    .min-h-screen { min-height: calc(100vh / 1.2) !important; }
}
@media (min-width: 2200px) {
    html { zoom: 1.35; }
    .min-h-screen { min-height: calc(100vh / 1.35) !important; }
}
@media (min-width: 2560px) {
    html { zoom: 1.5; }
    .min-h-screen { min-height: calc(100vh / 1.5) !important; }
}
@media (min-width: 3200px) {
    html { zoom: 1.6; }
    .min-h-screen { min-height: calc(100vh / 1.75) !important; }
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
                 Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color var(--speed) var(--ease); }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; height: auto; }

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; color: var(--gray-900); }
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

/* ── Layout Containers ─────────────────────────────────────── */
.container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 1rem;
}

.page-wrapper {
    min-height: calc(100vh - var(--nav-height));
    padding: 2rem 0;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .625rem 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--speed) var(--ease);
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; color: #fff; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }

.btn-sm { padding: .375rem .75rem; font-size: .8125rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }

.btn-block { display: flex; width: 100%; }

/* ── Breadcrumbs ───────────────────────────────────────────── */
.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .375rem;
    margin-bottom: 1rem;
    font-size: .8125rem;
}
.crumb {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .625rem;
    border-radius: 999px;
    background: var(--gray-100);
    color: var(--gray-600);
    white-space: nowrap;
    line-height: 1.4;
}
.crumb svg { width: 14px; height: 14px; }
.crumb-link { transition: background var(--speed) var(--ease), color var(--speed) var(--ease); }
.crumb-link:hover { background: var(--gray-200); color: var(--gray-900); }
.crumb-current { color: var(--gray-800); font-weight: 600; }
.crumb-sep { color: var(--gray-400); font-size: .95rem; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.card-body { padding: 1.25rem; }

.card-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: .375rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--gray-700);
}

.form-control {
    display: block;
    width: 100%;
    padding: .625rem .75rem;
    font-size: .9375rem;
    color: var(--gray-800);
    background: #fff;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
    outline: none;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), .15);
}

.form-control::placeholder { color: var(--gray-400); }

.form-error {
    color: var(--danger);
    font-size: .8125rem;
    margin-top: .25rem;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

table.table th,
table.table td {
    padding: .75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

table.table th {
    font-weight: 600;
    color: var(--gray-600);
    background: var(--gray-50);
    white-space: nowrap;
    user-select: none;
}

table.table th.sortable { cursor: pointer; }
table.table th.sortable:hover { color: var(--primary); }

table.table tbody tr { transition: background var(--speed) var(--ease); }
table.table tbody tr:hover { background: var(--gray-50); }

table.table th:last-child,
table.table td:last-child { text-align: right; }
table.table td:last-child .d-flex { justify-content: flex-end; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.alert-success { background: var(--success-light); color: #065F46; border-left: 3px solid var(--success); }
.alert-danger  { background: var(--danger-light);  color: #991B1B; border-left: 3px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400E; border-left: 3px solid var(--warning); }
.alert-info    { background: var(--info-light);    color: #1E40AF; border-left: 3px solid var(--info); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .5rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: #065F46; }
.badge-warning { background: var(--warning-light); color: #92400E; }
.badge-danger  { background: var(--danger-light);  color: #991B1B; }

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: .25rem;
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 .5rem;
    font-size: .8125rem;
    border-radius: var(--radius);
    transition: all var(--speed) var(--ease);
}

.pagination a:hover { background: var(--gray-100); }
.pagination .active { background: var(--primary); color: #fff; font-weight: 600; }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
/* Prevent jQuery UI from injecting icons into our custom tabs */
.tabs .ui-icon, .tabs .ui-tabs-nav { display: none !important; }

.tab {
    padding: .75rem 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all var(--speed) var(--ease);
    white-space: nowrap;
}

.tab:hover { color: var(--gray-800); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-content { display: none; padding: 1.25rem 0; }
.tab-content.active { display: block; }

/* ── Search / Filter Bar ───────────────────────────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    padding-left: 2.25rem;
}

.toolbar .btn {
    align-self: stretch;
}

.search-box .search-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    display: flex;
    pointer-events: none;
}

/* ── Navigation ────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    box-shadow: var(--shadow);
}

.navbar-brand {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.navbar-brand:hover { color: var(--primary-hover); }

/* Shared nav list styles */
.navbar-links,
.navbar-actions,
.navbar-nav {
    display: flex;
    align-items: center;
    gap: .25rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Left nav links — after brand with gap */
.navbar-links { margin-left: 1.5rem; }

/* Right action buttons — pushed to end */
.navbar-actions,
.navbar-nav { margin-left: auto; }

/* Base link style for all nav items */
.navbar-links a,
.navbar-actions a,
.navbar-nav a {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    padding: .5rem .875rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--gray-600);
    border-radius: var(--radius);
    transition: all var(--speed) var(--ease);
}

.navbar-links a:hover,
.navbar-nav a:hover { background: var(--gray-100); color: var(--gray-900); }

.navbar-links a.active,
.navbar-nav a.active { color: var(--primary); background: var(--primary-light); }

/* Buttons inside nav — override link colors, match height */
.navbar-actions a.btn,
.navbar-nav a.btn {
    padding: .5rem 1.125rem;
    font-size: .875rem;
}

.navbar-actions a.btn-primary,
.navbar-nav a.btn-primary { color: #fff; background: var(--primary); }
.navbar-actions a.btn-primary:hover,
.navbar-nav a.btn-primary:hover { color: #fff; background: var(--primary-hover); }

.navbar-actions a.btn-outline,
.navbar-nav a.btn-outline { color: var(--primary); border-color: var(--primary); background: transparent; }
.navbar-actions a.btn-outline:hover,
.navbar-nav a.btn-outline:hover { color: #fff; background: var(--primary); }

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: .5rem;
    cursor: pointer;
    color: var(--gray-700);
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    margin: 5px 0;
    transition: all var(--speed) var(--ease);
    border-radius: 2px;
}

/* ── Mobile Drawer ─────────────────────────────────────────── */
.mobile-drawer {
    display: none; /* hidden on desktop, shown via media query */
}

.mobile-drawer-section {
    padding: .5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.mobile-drawer-link {
    display: block;
    padding: .75rem 1rem;
    font-size: .9375rem;
    font-weight: 500;
    color: var(--gray-700);
    border-radius: var(--radius);
    transition: background var(--speed) var(--ease);
}

.mobile-drawer-link:hover { background: var(--gray-100); color: var(--gray-900); }
.mobile-drawer-link.active { color: var(--primary); background: var(--primary-light); }
.mobile-drawer-link-danger { color: var(--danger); }
.mobile-drawer-link-danger:hover { background: var(--danger-light); color: var(--danger); }

.mobile-drawer-divider {
    height: 1px;
    background: var(--gray-200);
    margin: .25rem 1rem;
}

.mobile-drawer-email {
    padding: .5rem 1rem;
    font-size: .8125rem;
    color: var(--gray-500);
    font-weight: 500;
}

/* ── Tracking Widget ───────────────────────────────────────── */
.tracking-widget {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    padding: .375rem .75rem;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    font-size: .875rem;
    margin-right: .75rem;
}

.tracking-widget.is-running {
    background: var(--success-light);
    animation: pulse-soft 2s ease-in-out infinite;
}

.tracking-timer {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 5rem;
    text-align: center;
}

@keyframes pulse-soft {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .3); }
    50%      { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* ── Feature Icons ─────────────────────────────────────────── */
.feature-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    margin-bottom: .875rem;
}

/* ── Modal ─────────────────────────────────────────────────── */
.st-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .25s ease, backdrop-filter .25s ease;
}

.st-modal-overlay.open {
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(4px);
}

.st-modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
    width: 90%;
    max-width: 400px;
    transform: scale(.9) translateY(10px);
    opacity: 0;
    transition: transform .25s var(--ease), opacity .25s var(--ease);
}

.st-modal-overlay.open .st-modal {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.st-modal-header {
    padding: 1.25rem 1.5rem .75rem;
}

.st-modal-header h3 {
    font-size: 1.125rem;
    margin: 0;
}

.st-modal-body {
    padding: 0 1.5rem .5rem;
}

.st-modal-body p {
    color: var(--gray-600);
    font-size: .9375rem;
    margin: 0;
    line-height: 1.5;
}

.st-modal-footer {
    padding: 1rem 1.5rem 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
}

/* ── Error Page ────────────────────────────────────────────── */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 5rem;
    font-weight: 800;
    color: var(--gray-300);
    margin-bottom: .5rem;
}

.error-page p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
}

/* ── Utility Classes ───────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--gray-500); }
.text-small  { font-size: .8125rem; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }

.hidden { display: none !important; }

/* ── Action Groups ─────────────────────────────────────────── */
.action-group {
    display: inline-flex;
    align-items: center;
    gap: 0;
}

.action-group .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Icon-only buttons (only an SVG inside) get tighter padding */
.action-group .btn-ghost.btn-sm {
    padding: .375rem .5rem;
}

.action-group .btn svg {
    display: block;
}

.action-divider {
    width: 1px;
    height: 1rem;
    background: var(--gray-200);
    margin: 0 .125rem;
    flex-shrink: 0;
}

/* ── Client Mobile Cards ──────────────────────────────────── */
.client-cards-mobile {
    display: none;
    flex-direction: column;
    gap: .75rem;
    margin-top: .75rem;
}

.client-card-m-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.client-card-m-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray-900);
}

.client-card-m-body {
    padding: .875rem 1.25rem;
}

.client-card-m-stats {
    display: flex;
    align-items: center;
}

.client-card-m-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--gray-200);
}

.client-card-m-stat:last-child {
    border-right: none;
}

.client-card-m-val {
    font-size: .9375rem;
    font-weight: 600;
    color: var(--gray-800);
    line-height: 1.2;
}

.client-card-m-lbl {
    font-size: .6875rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: .03em;
}


/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    :root {
        --nav-height: 56px;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    .container { padding: 0 .75rem; }
    .page-wrapper { padding: 1.25rem 0; }

    .menu-toggle { display: block; margin-left: auto; }

    .navbar-links { display: none; }
    .navbar-nav-desktop { display: none !important; }

    .navbar-actions {
        position: fixed;
        top: var(--nav-height);
        right: -100%;
        width: 280px;
        height: calc(100vh - var(--nav-height));
        background: #fff;
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        box-shadow: var(--shadow-lg);
        transition: right .3s var(--ease);
        gap: .125rem;
        z-index: 99;
    }

    .navbar-actions.open { right: 0; }

    .mobile-drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: var(--nav-height);
        right: -100%;
        width: 280px;
        height: calc(100vh - var(--nav-height));
        background: #fff;
        box-shadow: var(--shadow-lg);
        transition: right .3s var(--ease);
        z-index: 99;
        padding: .5rem 0;
        overflow-y: auto;
    }

    .mobile-drawer.open { right: 0; }

    table.table th,
    table.table td { padding: .5rem .75rem; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { min-width: 100%; }

    .card-header { flex-direction: column; align-items: flex-start; }

    .tracking-widget {
        order: -1;
        width: 100%;
        justify-content: center;
        margin: 0 0 .5rem;
    }

    /* Table → Cards on mobile */
    .client-table-desktop { display: none; }
    .client-cards-mobile { display: flex; }
}

@media (max-width: 480px) {
    .btn { padding: .5rem 1rem; font-size: .8125rem; }
    .card-body { padding: 1rem; }
}
