/* ASK Sales Manager Styles — adapted from ASKReports */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f0f4f8;
}

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

.navbar-brand {
    margin-right: 0.5rem;
}

.navbar-toggler {
    padding: 0.25rem 0.5rem;
    font-size: 1rem;
}

/* ── Dashboard stat cards ─────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(255,255,255,0.97), rgba(240,244,248,0.92));
    border: 1px solid rgba(21, 101, 192, 0.12);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(13, 71, 161, 0.08);
    min-height: 180px;
}

.dashboard-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url('../safetyxpress-logo-white.png');
    background-repeat: no-repeat;
    background-position: right 1.5rem center;
    background-size: min(38vw, 360px);
    opacity: 0.18;
    filter: saturate(0) brightness(0.55);
    pointer-events: none;
}

.dashboard-hero__content {
    position: relative;
    z-index: 1;
    padding: 2rem;
    max-width: 720px;
}

.stat-card {
    background: white;
    padding: 1.75rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-top: 4px solid var(--primary-color);
}

.stat-card h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #666;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.1;
}

/* ── Content cards ────────────────────────────────────────────────────────── */
.report-card {
    background: white;
    padding: 1.75rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

/* ── Scrollable table wrapper ─────────────────────────────────────────────── */
.import-table {
    overflow: auto;
    max-height: 65vh;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.import-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.import-table th,
.import-table td {
    border: 1px solid #e9ecef;
    padding: 0.5rem 0.75rem;
    text-align: left;
    white-space: nowrap;
}

.import-table thead th {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 1;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #495057;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Action buttons in tables */
.action-buttons {
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.action-btn {
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

@media (max-width: 991px) {
    .action-btn {
        padding: 0.3rem 0.4rem;
        font-size: 0.75rem;
        line-height: 1;
        font-weight: 600;
        min-width: 34px;
        min-height: 34px;
    }
    
    .action-buttons {
        gap: 0.2rem;
    }
}

@media (min-width: 992px) {
    .action-btn {
        padding: 0.375rem 0.75rem;
    }
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    margin-top: 2rem;
    padding: 1rem;
}

@media (max-width: 768px) {
    .footer {
        text-align: center;
        font-size: 0.85rem;
        padding: 0.75rem;
        margin-top: 1.5rem;
    }

    .footer .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 160px);
    padding: 2rem;
}

.login-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 3rem;
    width: 100%;
    max-width: 460px;
}

.login-card h2 {
    color: #1a1a2e;
    font-weight: 700;
}

/* ── Badge for link type ──────────────────────────────────────────────────── */
.badge-prospect {
    background-color: #e3f2fd;
    color: #1565c0;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.badge-client {
    background-color: #e8f5e9;
    color: #2e7d32;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Dashboard hero adjustments */
    .dashboard-hero::after {
        background-position: center bottom 1rem;
        background-size: min(60vw, 260px);
        opacity: 0.12;
    }

    .dashboard-hero__content {
        padding: 1.5rem;
        padding-bottom: 8rem;
    }

    .dashboard-hero h2 {
        font-size: 1.5rem;
    }

    /* Stats grid - single column */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    /* Report cards */
    .report-card {
        padding: 0.75rem;
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        border-radius: 0;
    }

    /* Table wrapper - horizontal scroll */
    .import-table {
        margin-left: -0.75rem;
        margin-right: -0.75rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
        max-height: 70vh;
    }

    /* Page headers with buttons */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start !important;
    }

    .d-flex.justify-content-between h2 {
        width: 100%;
    }

    .d-flex.justify-content-between .btn {
        width: 100%;
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }

    .d-flex.justify-content-between .btn-outline-secondary {
        order: 2; /* Put "Back to list" below heading on mobile */
    }

    .d-flex.justify-content-between h2 {
        order: 1;
    }

    /* Form submit buttons */
    form .btn-primary {
        width: 100%;
        padding: 0.875rem 1rem;
        font-size: 1.05rem;
        font-weight: 600;
    }

    /* Button groups on mobile */
    .btn-sm {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }

    /* Login card */
    .login-container {
        padding: 1rem;
        min-height: calc(100vh - 100px);
    }

    .login-card {
        padding: 2rem 1.5rem;
    }

    /* Container padding */
    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Main content area */
    main,
    .content {
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }

    /* Headings */
    h2.mb-0 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem !important;
    }

    /* Record count text */
    #row-count {
        font-size: 0.7rem;
        margin-bottom: 0.5rem !important;
    }

    .mb-4 {
        margin-bottom: 0.75rem !important;
    }

    /* Navbar mobile adjustments */
    body {
        padding-top: 0;
    }

    .navbar {
        padding: 0.5rem 0.75rem !important;
    }

    .navbar-brand {
        font-size: 0.9rem;
        gap: 0.4rem !important;
    }

    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    .navbar-collapse {
        margin-top: 0.5rem;
    }

    /* Action buttons in tables - make them stack */
    .btn-group-vertical {
        display: flex;
        flex-direction: column;
    }

    /* Form inputs full width on mobile */
    .form-control,
    .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Form buttons full width */
    .report-card .btn,
    form .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Form card spacing */
    .row.g-4 {
        gap: 1rem !important;
    }

    .col-lg-6 {
        padding-left: 0;
        padding-right: 0;
    }
}

/* Mobile - very small screens */
@media (max-width: 576px) {
    .stat-card h3 {
        font-size: 0.75rem;
    }

    .stat-card .btn {
        font-size: 0.95rem;
        padding: 0.625rem 1rem;
    }

    .stat-card .d-flex {
        gap: 0.5rem !important;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Smaller table text */
    .import-table {
        font-size: 0.65rem;
    }

    .import-table th,
    .import-table td {
        padding: 0.25rem 0.3rem;
        white-space: nowrap;
    }

    .import-table th {
        font-size: 0.6rem;
        line-height: 1.2;
    }

    /* Hide less critical columns on mobile */
    .import-table th:first-child,
    .import-table td:first-child {
        display: none; /* Hide ID column */
    }

    /* Allow wrapping for name/prospect columns */
    .import-table td[data-val],
    .import-table td:has(.badge-prospect),
    .import-table td:has(.badge-client),
    .import-table td.text-wrap {
        white-space: normal !important;
        word-wrap: break-word;
        max-width: 100px;
        line-height: 1.3;
    }

    /* Make text columns more compact */
    .import-table td[style*="max-width"] {
        max-width: 100px !important;
        white-space: normal !important;
        line-height: 1.3;
    }

    /* Compact date display */
    .import-table td {
        font-variant-numeric: tabular-nums;
    }

    /* Better touch targets for table buttons */
    .import-table .btn {
        min-width: 34px;
        min-height: 34px;
        font-size: 0.65rem;
        padding: 0.3rem 0.4rem;
    }

    .import-table .action-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.4rem;
        line-height: 1;
        font-weight: 600;
    }

    /* Action buttons container in tables */
    .import-table .action-buttons {
        display: flex;
        gap: 0.2rem;
        justify-content: center;
        flex-wrap: nowrap;
    }

    /* Improve table action buttons spacing */
    .import-table td > .btn + .btn,
    .import-table td > a + a {
        margin-left: 0.2rem;
        margin-top: 0;
    }

    /* Clear filters button */
    #f-clear {
        font-size: 0.6rem;
        padding: 0.15rem 0.35rem;
    }

    /* Compact table data */
    .import-table .text-muted {
        font-size: 0.6rem;
    }

    .import-table small {
        font-size: 0.55rem;
        line-height: 1.2;
        display: block;
        margin-top: 0.1rem;
    }

    .import-table .badge-prospect,
    .import-table .badge-client {
        font-size: 0.55rem;
        padding: 0.1rem 0.25rem;
        display: inline-block;
        line-height: 1.2;
        white-space: nowrap;
    }

    /* Compact filter inputs */
    .import-table .form-control-sm,
    .import-table .form-select-sm {
        font-size: 0.6rem;
        padding: 0.15rem 0.25rem;
        height: auto;
        min-height: 24px;
    }

    /* Adjust column widths for better fit */
    .import-table .text-end {
        text-align: right !important;
    }

    .import-table .text-nowrap {
        white-space: nowrap !important;
    }

    /* Tighter line height for wrapped text */
    .import-table tbody td {
        line-height: 1.3;
    }
}
