/* Presenza — responsive.css */

body { padding-bottom: 0; }
body.has-bottom-nav { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 900px) { body.has-bottom-nav { padding-bottom: 0; } }

/* TOP NAV */
.topnav {
    position: sticky;
    top: 0;
    z-index: 900;
    height: var(--topnav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
@media (prefers-color-scheme: dark) {
    .topnav { background: rgba(20, 23, 31, 0.9); backdrop-filter: blur(12px); }
}

.topnav-inner {
    height: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 var(--s-4);
    display: flex;
    align-items: center;
    gap: var(--s-4);
}
@media (min-width: 768px) { .topnav-inner { padding: 0 var(--s-6); } }

.topnav-brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    color: var(--text);
    text-decoration: none;
    flex: 0 0 auto;
}
.topnav-brand:hover { color: var(--text); }
.topnav-brand .brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden;
}
.topnav-brand .brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.topnav-brand .brand-text { display: none; font-weight: 700; font-size: var(--fs-md); }
.topnav-brand .brand-role { display: block; font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); margin-top: 1px; }
@media (min-width: 640px) { .topnav-brand .brand-text { display: block; } }

.topnav-nav { display: none; flex: 1; align-items: center; gap: 2px; margin-left: var(--s-4); }
@media (min-width: 900px) { .topnav-nav { display: flex; } }
.topnav-nav a {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: 8px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--dur-fast) var(--ease);
}
.topnav-nav a:hover { background: var(--surface-2); color: var(--text); }
.topnav-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.topnav-actions { display: flex; align-items: center; gap: var(--s-2); flex: 0 0 auto; margin-left: auto; }

.hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}
.hamburger:hover { background: var(--surface-2); }
@media (min-width: 900px) { .hamburger { display: none; } }

.user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: 4px 8px 4px 4px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
}
.user-menu-btn:hover { background: var(--surface-2); }
.user-menu-btn .user-name { display: none; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
@media (min-width: 640px) { .user-menu-btn .user-name { display: block; } }

/* DRAWER */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
}
.drawer-overlay.open { opacity: 1; visibility: visible; }

.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--dur-slow) var(--ease-out);
    overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-header {
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
}
.drawer-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.drawer-close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}
.drawer-close:hover { background: var(--surface-2); color: var(--text); }
.drawer-body { padding: var(--s-3); flex: 1; }
.drawer-nav-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: 12px 14px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: var(--fs-base);
    font-weight: 500;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.drawer-nav-item:hover { background: var(--surface-2); color: var(--text); }
.drawer-nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.drawer-section {
    padding: var(--s-3) var(--s-2) var(--s-2);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}
.drawer-divider { height: 1px; background: var(--border); margin: var(--s-2); }

/* BOTTOM NAV */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 800;
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.04);
}
@media (max-width: 899px) { .bottom-nav { display: flex; } }
@media (prefers-color-scheme: dark) {
    .bottom-nav { background: rgba(20, 23, 31, 0.95); backdrop-filter: blur(12px); }
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    position: relative;
    min-width: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}
.bottom-nav-item:hover, .bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item .badge-dot {
    position: absolute;
    top: 6px;
    right: calc(50% - 16px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
}
.bottom-nav-item .label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* PAGE */
.page { padding: var(--s-4) 0; }
@media (min-width: 768px) { .page { padding: var(--s-6) 0; } }

.page-header { margin-bottom: var(--s-5); }
.page-title { font-size: var(--fs-xl); font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
@media (min-width: 768px) { .page-title { font-size: var(--fs-2xl); } }
.page-subtitle { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 4px; }

/* STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-3);
    margin-bottom: var(--s-5);
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
    min-height: 88px;
    justify-content: center;
}
.stat.clickable { cursor: pointer; transition: all var(--dur) var(--ease); }
.stat.clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent);
}
.stat-icon {
    position: absolute;
    top: var(--s-3);
    right: var(--s-3);
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.stat-value {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
@media (min-width: 768px) { .stat-value { font-size: var(--fs-3xl); } }
.stat-label {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat.stat-success .stat-icon { background: var(--success-soft); color: var(--success); }
.stat.stat-success .stat-value { color: var(--success); }
.stat.stat-danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat.stat-danger .stat-value { color: var(--danger); }
.stat.stat-warning .stat-icon { background: var(--warning-soft); color: var(--warning); }
.stat.stat-warning .stat-value { color: var(--warning); }
.stat.stat-info .stat-icon { background: var(--info-soft); color: var(--info); }
.stat.stat-info .stat-value { color: var(--info); }

/* TABLE → CARDS on mobile */
@media (max-width: 767px) {
    .table-cards thead { display: none; }
    .table-cards,
    .table-cards tbody,
    .table-cards tr,
    .table-cards td { display: block; width: 100%; }
    .table-cards { border: none; background: transparent; overflow: visible; }
    .table-cards tbody tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: var(--s-4);
        margin-bottom: var(--s-3);
        box-shadow: var(--shadow-xs);
    }
    .table-cards tbody tr:hover { background: var(--surface); }
    .table-cards tbody tr td {
        padding: 6px 0;
        border: none;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: var(--s-3);
        font-size: var(--fs-sm);
        text-align: right;
    }
    .table-cards tbody tr td + td {
        border-top: 1px dashed var(--border);
        padding-top: 8px;
        margin-top: 2px;
    }
    .table-cards tbody tr td::before {
        content: attr(data-label);
        font-size: var(--fs-xs);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        text-align: left;
        flex: 0 0 auto;
        padding-right: var(--s-2);
    }
    .table-cards tbody tr td[data-label=""]::before,
    .table-cards tbody tr td:not([data-label])::before { display: none; }
    .table-cards tbody tr td:not([data-label]),
    .table-cards tbody tr td[data-label=""] {
        justify-content: flex-end;
        padding-top: var(--s-3);
        margin-top: var(--s-2);
        border-top: 1px solid var(--border);
    }
    .table-cards tbody tr td.actions-cell {
        display: flex;
        flex-wrap: wrap;
        gap: var(--s-2);
        justify-content: flex-start;
    }
    .table-cards tbody tr td.actions-cell .btn {
        flex: 1;
        min-width: 100px;
    }
}

/* QUICK LINKS */
.quick-links {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--s-3);
    margin-bottom: var(--s-5);
}
@media (min-width: 640px) { .quick-links { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .quick-links { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); } }

.quick-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-md);
    padding: var(--s-4);
    text-decoration: none;
    color: var(--text);
    min-height: 68px;
    transition: all var(--dur) var(--ease);
}
.quick-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--text);
}
.quick-link .ql-label { font-size: var(--fs-base); font-weight: 600; color: var(--text); }
.quick-link .ql-sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }
.quick-link .ql-count {
    background: var(--warning);
    color: #fff;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: 700;
    flex-shrink: 0;
}

/* CLOCK ACTION */
.clock-action {
    display: block;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 22px 28px;
    font-size: var(--fs-lg);
    font-weight: 700;
    border: none;
    border-radius: var(--radius-lg);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all var(--dur) var(--ease);
    letter-spacing: 0.02em;
    font-family: inherit;
    min-height: 68px;
}
.clock-action.clock-in { background: linear-gradient(135deg, var(--success), #059669); }
.clock-action.clock-in:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.clock-action.clock-out { background: linear-gradient(135deg, var(--danger), #dc2626); }
.clock-action.clock-out:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

/* STICKY OFFSET */
.sticky-offset { scroll-margin-top: calc(var(--topnav-h) + var(--s-4)); }

/* MOBILE-ONLY HELPERS */
.mobile-only { display: block; }
.desktop-only { display: none; }
@media (min-width: 900px) {
    .mobile-only { display: none !important; }
    .desktop-only { display: block !important; }
}

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* PRINT */
@media print {
    .topnav, .bottom-nav, .drawer, .drawer-overlay, .hamburger, .btn, .tabs { display: none !important; }
    body { background: #fff; padding: 0; }
    .card, .table-wrap { box-shadow: none; border: 1px solid #ddd; }
}