/* Colors & Branding */
:root {
    --primary-blue: #3b82f6;
    --dark-navy: #111827; /* Closer to the dark header */
    --light-gray: #f9fafb;
    --text-muted: #6b7280;
    
    /* App Colors */
    --app-crm: #3b82f6;
    --app-onboarding: #8b5cf6;
    --app-payroll: #10b981;
    --app-reports: #f59e0b;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--light-gray);
    color: #1f2937;
}

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

/* Mobile-first layout utilities */
.page-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.has-fixed-footer main {
    padding-bottom: 5rem;
}

.header-logo {
    width: 140px;
    filter: brightness(0) invert(1) !important;
}

.text-page-title {
    color: #1a2a40;
}

.title-divider {
    width: 40px;
    height: 2px;
    background-color: var(--primary-blue);
}

.toast-container {
    z-index: 1100;
}

@media (max-width: 575.98px) {
    .toast-container {
        bottom: 4.5rem !important;
    }

    #liveToast {
        min-width: 0;
        width: 100%;
    }
}

.app-card-bg {
    background: #f6fafe;
}

.bg-light-gray { background-color: var(--light-gray); }
.text-navy { color: var(--dark-navy); }

/* Header & Footer */
.atletico-header {
    background-color: var(--dark-navy);
}

.atletico-footer {
    background-color: var(--dark-navy);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.tracking-wide { letter-spacing: 0.05em; }
.hover-white:hover { color: #ffffff !important; }

/* Dashboard Cards */
.app-card {
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.app-card:not(.app-card-locked):hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
    cursor: pointer;
}

.app-card-locked {
    opacity: 0.7;
    filter: grayscale(0.5);
    
}

.app-card-locked:hover {
    opacity: 0.9;
}

/* Icon backgrounds */
.bg-light-primary { background-color: rgba(59, 130, 246, 0.1); }
.bg-light-secondary { background-color: #f3f4f6; }
.bg-light-purple { background-color: #f5f3ff; }

.shadow-inner { box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06); }

/* App Icon Circles and Accents */
.app-icon-container {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.app-icon-container img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.app-icon-container::before {
    content: '';
    position: absolute;
    width: 74px;
    height: 74px;
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 50%;
    z-index: 0;
}

.icon-bg { z-index: 1; position: relative; }

.accent-circle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-blue);
    z-index: 2;
}


.app-card:nth-child(1) .bi { color: var(--app-crm) !important; }
.app-card:nth-child(2) .bi { color: var(--app-onboarding) !important; }
.app-card:nth-child(3) .bi { color: var(--app-payroll) !important; }
.app-card:nth-child(4) .bi { color: var(--app-reports) !important; }


.accent-top { top: 0; left: 50%; transform: translateX(-50%); }
.accent-left { top: 50%; left: 0; transform: translateY(-50%); }
.accent-right { top: 50%; right: 0; transform: translateY(-50%); }

/* Modal tweaks */
.modal-content { border-radius: 1rem; }

/* Sidebar */
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .nav-link { font-size: 0.95rem; border-radius: 0.5rem; margin-bottom: 2px; }
.sidebar .nav-link:hover { background-color: #f8f9fa; }
.sidebar .nav-link.active { color: var(--primary-blue) !important; background-color: rgba(59, 130, 246, 0.05) !important; border-left-color: var(--primary-blue) !important; }

/* Custom Checkbox for Access Matrix */
.form-check-input.matrix-checkbox { width: 1.25em; height: 1.25em; cursor: pointer; }
.form-check-input.matrix-checkbox:checked { background-color: var(--primary-blue); border-color: var(--primary-blue); }

.admin-nav-label {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
}

.admin-sidebar {
    width: 240px;
    min-height: calc(100vh - 130px);
    position: sticky;
    top: 0;
}

.admin-mobile-bar {
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-main {
    min-width: 0;
}

/* Hover lift for cards */
.hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1) !important;
}

/* Admin sidebar nav link hover */
.nav-link.text-dark:hover:not(.bg-primary) {
    background-color: #f1f5f9;
}

/* Badge subtle colors (Bootstrap 5.3 fallback) */
.bg-success-subtle { background-color: #d1fae5 !important; }
.bg-danger-subtle  { background-color: #fee2e2 !important; }
.bg-warning-subtle { background-color: #fef9c3 !important; }
.text-success { color: #059669 !important; }
.text-danger  { color: #dc2626 !important; }

/* Form switch size */
.form-check-input[type="checkbox"] { cursor: pointer; }

/* Scrollable table viewport — vertical + horizontal scroll with sticky header */
.table-scroll-viewport {
    max-height: min(70vh, calc(100dvh - 220px));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.table-scroll-viewport table {
    margin-bottom: 0;
}

.table-scroll-viewport table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
}

.table-scroll-viewport table .sticky-col {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #fff;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

.table-scroll-viewport table thead .sticky-col {
    z-index: 4;
    background: #f8fafc;
}

.table-scroll-viewport.has-scroll-right {
    box-shadow: inset -8px 0 8px -6px rgba(0, 0, 0, 0.08);
}

/* App roles table — mobile card layout */
@media (max-width: 767.98px) {
    .app-roles-table thead {
        display: none;
    }

    .app-roles-table tbody tr {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 0.75rem;
        margin-bottom: 1rem;
        padding: 0.75rem;
        background: #fff;
    }

    .app-roles-table tbody td {
        display: block;
        border: none;
        padding: 0.5rem 0;
        width: 100% !important;
    }

    .app-roles-table tbody td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.7rem;
        font-weight: 600;
        text-transform: uppercase;
        color: var(--text-muted);
        margin-bottom: 0.35rem;
    }

    .app-roles-table tbody td:first-child::before {
        display: none;
    }

    .app-roles-table-wrapper.table-scroll-viewport {
        max-height: none;
        overflow: visible;
    }
}

@media (min-width: 1200px) {
    .dashboard-app-row .app-card .card-title {
        font-size: 1rem;
    }

    .dashboard-app-row .app-card .card-text {
        font-size: 0.8rem;
    }

    .dashboard-app-row .app-icon-container {
        width: 110px;
        height: 110px;
    }

    .dashboard-app-row .app-icon-container img {
        width: 110px;
        height: 110px;
    }

    .dashboard-app-row .app-icon-container::before {
        width: 104px;
        height: 104px;
    }
}

/* Rounded start on main admin panel */
@media (min-width: 576px) {
    .header-logo {
        width: 170px;
    }

    .app-icon-container {
        width: 100px;
        height: 100px;
    }

    .app-icon-container img {
        width: 100px;
        height: 100px;
    }

    .app-icon-container::before {
        width: 94px;
        height: 94px;
    }
}

@media (min-width: 768px) {
    .rounded-start-4 { border-radius: 1.5rem 0 0 1.5rem !important; }

    .header-logo {
        width: 200px;
    }

    .app-icon-container {
        width: 140px;
        height: 140px;
    }

    .app-icon-container img {
        width: 140px;
        height: 140px;
    }

    .app-icon-container::before {
        width: 130px;
        height: 130px;
    }
}

/* Table inside cards - remove outer border */
.card > .table-responsive > table,
.card > .table-scroll-viewport > table { border: none; }
.card > .table-responsive > table th,
.card > .table-responsive > table td,
.card > .table-scroll-viewport > table th,
.card > .table-scroll-viewport > table td { border-color: #f1f5f9; }

/* Toasts */
#liveToast { min-width: 280px; }