/**
 * Timesheet Dashboard Styles
 */

/* Ensure timesheet dashboard is contained within site-main */
.site-main {
    overflow-x: hidden; /* Prevent site-main from scrolling */
    width: 100%;
    max-width: 100%;
}

.site-main .timesheet-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: var(--spacing-md) var(--container-padding);
    box-sizing: border-box;
    overflow-x: hidden; /* Prevent dashboard from scrolling */
}

.timesheet-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: var(--spacing-md) var(--container-padding);
    box-sizing: border-box;
    overflow-x: hidden; /* Prevent dashboard from scrolling */
    position: relative;
}

/* Improved mobile padding */
@media (max-width: 767px) {
    .timesheet-dashboard {
        padding: var(--spacing-md) 1.5rem; /* 24px on mobile */
    }
}

@media (min-width: 768px) {
    .timesheet-dashboard {
        padding: var(--spacing-xl) var(--container-padding);
    }
}

.timesheet-dashboard__header {
    margin-bottom: var(--spacing-2xl);
    display: flex;
    justify-content: center;
}

.timesheet-dashboard__title-box {
    background: #f5f5f5;
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: var(--spacing-lg) var(--spacing-2xl);
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    max-width: 100%;
}

.timesheet-dashboard__header h1 {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 3rem);
    margin: 0;
}

@media (max-width: 767px) {
    .timesheet-dashboard__title-box {
        padding: var(--spacing-md) var(--spacing-lg);
    }
}

.timesheet-dashboard__controls {
    background: #f5f5f5;
    padding: var(--spacing-lg);
    border-radius: 8px;
    margin-bottom: var(--spacing-2xl);
}

.timesheet-filters {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
    align-items: flex-end;
}

@media (min-width: 768px) {
    .timesheet-filters {
        gap: var(--spacing-md);
    }
}

.timesheet-filters__group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.timesheet-filters__group label {
    font-weight: 600;
    font-size: 0.875rem;
}

.timesheet-filters__group input,
.timesheet-filters__group select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
    min-width: 0;
}

@media (min-width: 768px) {
    .timesheet-filters__group input,
    .timesheet-filters__group select {
        padding: 0.5rem;
        font-size: 0.9375rem;
        width: auto;
    }
}

.timesheet-dashboard__totals {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xl);
}

@media (min-width: 480px) {
    .timesheet-dashboard__totals {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--spacing-md);
    }
}

@media (min-width: 768px) {
    .timesheet-dashboard__totals {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: var(--spacing-lg);
        margin-bottom: var(--spacing-2xl);
    }
}

.timesheet-totals-card {
    background: #fff;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    padding: var(--spacing-md);
    text-align: center;
}

@media (min-width: 768px) {
    .timesheet-totals-card {
        padding: var(--spacing-lg);
    }
}

.timesheet-totals-card h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-secondary);
    margin: 0 0 var(--spacing-sm) 0;
}

.timesheet-totals-card__value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

@media (min-width: 480px) {
    .timesheet-totals-card__value {
        font-size: 2rem;
    }
}

@media (min-width: 768px) {
    .timesheet-totals-card__value {
        font-size: 2.5rem;
    }
}

.timesheet-dashboard__compliance {
    background: #fff;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.timesheet-dashboard__compliance h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin: 0 0 var(--spacing-lg) 0;
}

.compliance-checks {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
}

@media (min-width: 768px) {
    .compliance-checks {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: var(--spacing-lg);
    }
}

.compliance-check {
    padding: var(--spacing-lg);
    border-radius: 8px;
    border: 2px solid;
}

.compliance-check.compliant {
    background: #e8f5e9;
    border-color: #4caf50;
}

.compliance-check.non-compliant {
    background: #ffebee;
    border-color: #f44336;
}

.compliance-check h3 {
    font-size: 1rem;
    margin: 0 0 var(--spacing-sm) 0;
}

.compliance-check .warnings {
    margin: 0;
    padding-left: 1.25rem;
    color: #c62828;
}

.compliance-check .compliant-message {
    margin: 0;
    color: #2e7d32;
    font-weight: 600;
}

.timesheet-dashboard__entry {
    background: #fff;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.timesheet-dashboard__entry h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin: 0 0 var(--spacing-lg) 0;
}

.timesheet-entry-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.timesheet-form__row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
}

@media (min-width: 480px) {
    .timesheet-form__row {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }
}

@media (min-width: 768px) {
    .timesheet-form__row {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: var(--spacing-md);
    }
}

.timesheet-form__field {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.timesheet-form__field label {
    font-weight: 600;
    font-size: 0.875rem;
}

.timesheet-form__field input[type="text"],
.timesheet-form__field input[type="number"],
.timesheet-form__field input[type="date"],
.timesheet-form__field input[type="time"] {
    padding: 0.875rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

/* Larger mobile inputs for easier tapping */
@media (max-width: 767px) {
    .timesheet-form__field input[type="text"],
    .timesheet-form__field input[type="number"],
    .timesheet-form__field input[type="date"],
    .timesheet-form__field input[type="time"] {
        padding: 1rem; /* 16px */
        font-size: 1.0625rem; /* 17px */
        min-height: 48px; /* Minimum touch target */
    }

    .timesheet-form__field label {
        font-size: 0.9375rem; /* 15px */
        margin-bottom: 0.5rem;
    }
}

@media (min-width: 768px) {
    .timesheet-form__field input[type="text"],
    .timesheet-form__field input[type="number"],
    .timesheet-form__field input[type="date"],
    .timesheet-form__field input[type="time"] {
        padding: 0.75rem;
        font-size: 0.9375rem;
    }
}

.timesheet-form__field input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
}

/* Larger checkbox on mobile */
@media (max-width: 767px) {
    .timesheet-form__field input[type="checkbox"] {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
    }

    .timesheet-form__field label[for*="night_out"],
    .timesheet-form__field label[for*="reduced_rest"] {
        font-size: 1.0625rem; /* 17px */
        display: flex;
        align-items: center;
        min-height: 48px;
    }
}

.timesheet-form__field small {
    display: block;
    color: var(--color-secondary);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.timesheet-dashboard__entries {
    background: #fff;
    border: 2px solid var(--color-border);
    border-radius: 8px;
    padding: var(--spacing-xl);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    position: relative;
}

.timesheet-entries-header {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .timesheet-entries-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: var(--spacing-lg);
        gap: var(--spacing-md);
    }
}

.timesheet-entries-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin: 0;
}

.timesheet-actions {
    display: flex;
    gap: var(--spacing-sm);
    width: 100%;
}

.timesheet-actions .button {
    flex: 1;
    text-align: center;
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
}

/* Larger buttons on mobile */
@media (max-width: 767px) {
    .timesheet-actions .button {
        padding: 1rem 1.5rem; /* 16px 24px */
        font-size: 1.0625rem; /* 17px */
        min-height: 48px;
    }

    button[name="timesheet_submit"],
    .button-primary {
        padding: 1rem 1.5rem;
        font-size: 1.0625rem;
        min-height: 48px;
        font-weight: 600;
    }
}

@media (min-width: 768px) {
    .timesheet-actions {
        width: auto;
    }

    .timesheet-actions .button {
        flex: none;
        padding: 0.5rem 1rem;
    }
}

.timesheet-table {
    width: 100%;
    min-width: 800px; /* Force minimum width to trigger scrollbar */
    border-collapse: collapse;
    font-size: 0.75rem;
    display: table !important; /* Force table display */
    box-sizing: border-box;
    /* Remove overflow from table itself - wrapper handles it */
    overflow: visible;
    table-layout: auto;
}

/* Table wrapper to contain overflow - MUST be constrained */
.timesheet-table-wrapper {
    overflow-x: scroll !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    width: 100% !important;
    max-width: 100% !important;
    display: block !important;
    position: relative;
    box-sizing: border-box;
    /* Force scrollbar to always show when needed */
    min-height: 0;
    /* Ensure scrollbar is visible */
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* Force scrollbar styling on all browsers */
.timesheet-table-wrapper::-webkit-scrollbar {
    height: 12px;
}

.timesheet-table-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

.timesheet-table-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 6px;
}

.timesheet-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}

@media (max-width: 767px) {
    .timesheet-dashboard__entries {
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
        overflow-x: hidden; /* Prevent container from scrolling */
    }

    .timesheet-table-wrapper {
        margin-left: calc(-1 * var(--spacing-md));
        margin-right: calc(-1 * var(--spacing-md));
        padding-left: var(--spacing-md);
        padding-right: var(--spacing-md);
        width: calc(100% + 2 * var(--spacing-md));
        max-width: calc(100% + 2 * var(--spacing-md));
        overflow-x: scroll; /* Force scrollbar */
    }
}

/* Better mobile table display */
@media (max-width: 767px) {
    .timesheet-table {
        font-size: 0.875rem; /* Slightly larger on mobile */
    }
}

@media (min-width: 768px) {
    .timesheet-table {
        font-size: 0.875rem;
        display: table;
        width: 100%;
        max-width: 100%;
        table-layout: auto;
        min-width: 0; /* Allow table to shrink */
    }

    .timesheet-table-wrapper {
        overflow-x: auto;
        overflow-y: visible;
        width: 100%;
        max-width: 100%;
        /* Force scrollbar when content overflows */
        overflow-x: scroll;
    }

    .timesheet-dashboard__entries {
        overflow-x: hidden; /* Prevent container scroll */
    }
}

.timesheet-table thead {
    background: #f5f5f5;
    display: none;
}

@media (min-width: 768px) {
    .timesheet-table thead {
        display: table-header-group;
    }
}

.timesheet-table th {
    padding: var(--spacing-sm);
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

@media (min-width: 768px) {
    .timesheet-table th {
        padding: var(--spacing-md);
        font-size: 0.75rem;
    }
}

.timesheet-table tbody {
    display: block;
}

@media (min-width: 768px) {
    .timesheet-table tbody {
        display: table-row-group;
    }
}

.timesheet-table tr {
    display: block;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    margin-bottom: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: #fff;
}

@media (min-width: 768px) {
    .timesheet-table tr {
        display: table-row;
        border: none;
        border-radius: 0;
        margin-bottom: 0;
        padding: 0;
        background: transparent;
    }
}

.timesheet-table td {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: var(--spacing-xs) 0;
    border-bottom: 1px solid #eee;
    text-align: right;
    position: relative;
    padding-left: 40%;
    min-height: 44px; /* Minimum touch target */
}

/* Better mobile table cell spacing */
@media (max-width: 767px) {
    .timesheet-table td {
        padding: var(--spacing-sm) 0;
        padding-left: 40%;
        font-size: 0.9375rem; /* 15px */
    }
}

.timesheet-table td:before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 35%;
    padding-right: var(--spacing-xs);
    white-space: nowrap;
    text-align: left;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--color-secondary);
}

.timesheet-table td:last-child {
    border-bottom: none;
}

@media (min-width: 768px) {
    .timesheet-table td {
        display: table-cell;
        padding: var(--spacing-md);
        border-bottom: 1px solid var(--color-border);
        text-align: left;
        padding-left: var(--spacing-md);
    }

    .timesheet-table td:before {
        display: none;
    }

    .timesheet-table td:last-child {
        border-bottom: 1px solid var(--color-border);
    }
}

.timesheet-table tbody tr:hover {
    background: #f9f9f9;
}

/* Driver Compliance Dashboard Styles */
.driver-compliance-dashboard {
    margin-bottom: var(--spacing-lg);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes flash-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.flash-red {
    animation: flash-red 1s infinite;
}

@keyframes flash-amber {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 152, 0, 0.0); }
    50% { box-shadow: 0 0 18px rgba(255, 152, 0, 0.6); }
}

.flash-amber {
    animation: flash-amber 1s infinite;
}

/* Shift Spread Compliance Styles */
.shift-spread-compliance {
    margin-bottom: var(--spacing-lg);
}

.shift-spread-compliance h3 {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-md);
}

.shift-spread-compliance__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

@media (min-width: 480px) {
    .shift-spread-compliance__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .shift-spread-compliance__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.shift-spread-compliance__status {
    padding: var(--spacing-md);
    border-radius: 4px;
}

.shift-spread-compliance__status--legal {
    background: #e8f5e9;
    border: 2px solid #4caf50;
}

.shift-spread-compliance__status--reduced {
    background: #fff3e0;
    border: 2px solid #ff9800;
}

.shift-spread-compliance__status--breach,
.shift-spread-compliance__status--critical_breach {
    background: #ffebee;
    border: 2px solid #f44336;
}

/* Print Styles */
@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    .timesheet-dashboard__controls,
    .timesheet-dashboard__entry,
    .timesheet-actions,
    .timesheet-dashboard__compliance {
        display: none;
    }

    .timesheet-dashboard {
        padding: 0;
    }

    .timesheet-table-wrapper {
        overflow: visible !important;
        width: 100% !important;
    }

    .timesheet-table {
        display: table !important;
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed;
        font-size: 0.65rem;
        border-collapse: collapse;
    }

    .timesheet-table thead {
        display: table-header-group;
    }

    .timesheet-table tr {
        display: table-row;
    }

    .timesheet-table th,
    .timesheet-table td {
        display: table-cell !important;
        padding: 0.2rem;
        border: 1px solid #ddd;
        text-align: left;
        white-space: normal;
        word-break: break-word;
    }

    .timesheet-table td:before {
        display: none !important;
        content: none !important;
    }

    /* Hide non-essential columns for print readability */
    .timesheet-table th:nth-child(10),
    .timesheet-table td:nth-child(10),
    .timesheet-table th:nth-child(12),
    .timesheet-table td:nth-child(12),
    .timesheet-table th:nth-child(13),
    .timesheet-table td:nth-child(13),
    .timesheet-table th:nth-child(14),
    .timesheet-table td:nth-child(14),
    .timesheet-table th:nth-child(15),
    .timesheet-table td:nth-child(15),
    .timesheet-table th:nth-child(16),
    .timesheet-table td:nth-child(16) {
        display: none !important;
    }
}

