/* General Wrapper */
.productivity-rank-wrapper {
    margin: 20px auto;
    max-width: 900px;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
}
/* Title */
.productivity-rank-wrapper h2 {
    text-align: center;
    margin-bottom: 15px;
}
/* Controls (Search, Filters, etc.) */
.productivity-rank-controls {
    margin-bottom: 10px;
    text-align: right;
}
/* Table Styling */
.productivity-rank-table {
    width: 100% !important;
    border-collapse: collapse !important;
    table-layout: auto; /* Allow columns to expand to fit content */
    margin-bottom: 12px !important;
    font-size: 0.95em !important;
}
/* Table headers */
.productivity-rank-table th,
.productivity-rank-table td {
    padding: 10px 12px !important;
    text-align: left !important;
    border-bottom: 1px solid #eee !important;
    word-wrap: break-word; /* Allow long text to break to next line */
}
.productivity-rank-table th {
    background: #0073aa;
    color: white;
    font-weight: 600;
}
.productivity-rank-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}
.productivity-rank-table tbody tr:hover {
    background: #f3f7ff !important;
}
/* Category Row Highlights */
.rank-block:has(h4:contains("Top Cutter")) .productivity-rank-table tbody tr {
    background: #e6f9ed; /* Light Green Tint */
}
.rank-block:has(h4:contains("Average")) .productivity-rank-table tbody tr {
    background: #fff6e5; /* Light Amber Tint */
}
.rank-block:has(h4:contains("Slow")) .productivity-rank-table tbody tr {
    background: #fdecea; /* Light Red Tint */
}
/* Column specific background color */
.productivity-rank-table td:nth-child(2) {
    background: #e6f9ed;
}
.productivity-rank-table td:nth-child(3) {
    background: #fff6e5;
}
.productivity-rank-table td:nth-child(4) {
    background: #fdecea;
}
/* Highlight "Top", "Average", "Slow" Rows */
.productivity-rank-table tbody tr.top {
    background: #d4edda !important; /* green */
    font-weight: bold;
}
.productivity-rank-table tbody tr.slow {
    background: #f8d7da !important; /* red */
    font-weight: bold;
}
/* Pagination */
#paginationControls {
    text-align: center;
    margin-top: 15px;
}
#paginationControls .page-btn {
    margin: 0 5px;
    padding: 5px 10px;
    border: 1px solid #0073aa;
    background: #fff;
    cursor: pointer;
}
#paginationControls .page-btn.active {
    background: #0073aa;
    color: white;
    font-weight: bold;
}
/* Rank Block */
.product-section {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
    padding: 16px;
    margin-bottom: 24px;
}
.product-section h3 {
    border-left: 6px solid #4a90e2;
    padding-left: 10px;
    font-size: 1.3em;
    margin-bottom: 12px;
}
/* Rank Block Titles */
.rank-block h4 {
    margin: 12px 0 8px;
    font-size: 1.1em;
    font-weight: 600;
}
.rank-block:has(h4:contains("Top Cutter")) h4 {
    color: #28a745;
}
.rank-block:has(h4:contains("Average")) h4 {
    color: #f39c12;
}
.rank-block:has(h4:contains("Slow")) h4 {
    color: #e74c3c;
}
/* Flex Layout for Sections */
#productivity-rank-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    width: 100%;
}
/* Filter Controls (Rank-Range, Category, Search, Edit) */
#rank-filters-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    margin-bottom: 15px;
}
#rank-filters-container select,
#rank-filters-container input[type="text"] {
    padding: 6px 8px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #ccc;
}
#rank-filters-container input[type="text"] {
    flex: 1 1 200px;
}
#rank-filters-container button.modern-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
#rank-filters-container button.modern-button:hover {
    background-color: #0056b3;
}
/* Button Styling */
.modern-btn {
    background: linear-gradient(90deg, #007bff, #0056b3);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
}
.modern-btn:hover {
    background: linear-gradient(90deg, #0056b3, #003f7f);
    transform: translateY(-1px);
}
.modern-btn:active {
    transform: scale(0.98);
}
/* Controls Input (Select, Input) */
.rank-controls input, 
.rank-controls select {
    width: 100%;
    padding: 4px 6px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.9em;
}
/* ===================== MODAL ===================== */
#employeeModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

/* Modal content */
#employeeModal .modal-content {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: modalFadeIn 0.25s ease;
    max-height: 80vh; /* Set max height */
    overflow-y: auto; /* Make modal content scrollable */
}

/* Modal fade-in animation */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Header */
#employeeModal h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

/* Employee edit table styling */
.employee-edit-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    max-height: 50vh; /* Set max height for employee list */
    overflow-y: auto; /* Scrollable content for long lists */
}

.employee-edit-table th,
.employee-edit-table td {
    border-bottom: 1px solid #f0f0f0;
    padding: 8px;
    text-align: left;
}

.employee-edit-table th {
    background: #f9f9f9;
    font-weight: bold;
}

.employee-edit-table tr:hover {
    background: #f5faff;
}

/* Modal Footer */
.modal-footer {
    margin-top: 15px;
    text-align: right;
}

.modal-footer .button {
    margin-left: 8px;
    padding: 7px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}

.modal-footer .button-primary {
    background: #007bff;
    color: #fff;
}

.modal-footer .button-primary:hover {
    background: #0056b3;
}

.modal-footer .button:hover {
    background: #f2f2f2;
}
/* ====================== Rank Filters Layout & Edit Button */
.rank-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.rank-filters select,
.rank-filters input {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}
#editEmployeeBtn {
    background-color: #0073aa;
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s ease;
}
#editEmployeeBtn:hover {
    background-color: #005c87;
}
/* 👤 Icon styling (using emoji fallback or lucide if you prefer later) */
#editEmployeeBtn::before {
    content: "👤";
    font-size: 16px;
}
/* Manage Employees Modal */
#manageEmployeesModal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}
#manageEmployeesModal .modal-content {
    background: #fff;
    border-radius: 12px;
    width: 500px;
    max-width: 90%;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: fadeInUp 0.25s ease-out;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
#manageEmployeesModal h2 {
    margin-bottom: 15px;
    font-size: 20px;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 6px;
    color: #0073aa;
}
/* Employee List */
#employeeList {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
    padding: 8px;
    border-radius: 6px;
    margin-bottom: 12px;
}
.employee-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid #f1f1f1;
}
.employee-item:last-child {
    border-bottom: none;
}
.employee-item span {
    flex: 1;
}
.employee-item button {
    background: #ddd;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    margin-left: 4px;
    transition: background 0.2s ease;
}
.employee-item button:hover {
    background: #bbb;
}
/* Modal Footer Buttons */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.modal-footer button {
    background-color: #0073aa;
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
}
.modal-footer button:hover {
    background-color: #005c87;
}
/* Rank Filters Layout */
#rank-filters-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    max-width: 100%;          /* ✅ Prevent overflow */
    overflow-x: hidden;       /* ✅ Hide extra scroll */
    justify-content: flex-start;
    box-sizing: border-box;
}
/* Make inputs and selects align evenly */
#rank-filters-container .rank-control,
#rank-filters-container button {
    flex: 0 0 auto;
}
/* Narrow date pickers */
#rank-start, #rank-end {
    width: 130px;
    min-width: 110px;
}
/* Adjust search to share space */
#rank-search {
    flex: 1 1 240px;
    min-width: 160px;
    max-width: 260px;
}
/* Print & edit button small */
#rank-print, #editEmployeeBtn {
    white-space: nowrap;
    flex: 0 0 auto;
}
/* Contain entire filter area inside wrapper width */
.productivity-rank-wrapper {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}
#rank-filters-container select,
#rank-filters-container input[type="text"] {
    padding: 6px 8px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid #ccc;
}
#rank-filters-container input[type="text"] {
    flex: 1 1 200px; /* let search bar take flexible space */
}
#rank-filters-container button.modern-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: background 0.2s;
}
#rank-filters-container button.modern-button:hover {
    background-color: #0056b3;
}
/* ============================ CATEGORY HEADERS ============================ */
.rank-section {
    margin-bottom: 25px;
}
.rank-header {
    font-size: 18px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    color: #fff;
}
.rank-top-header {
    background: #28a745;
}
.rank-average-header {
    background: #ffc107;
    color: #333;
}
.rank-slow-header {
    background: #dc3545;
}
/* ================== CARD LAYOUT ================== */
.rank-sections-wrapper {
    display: flex;
    flex-direction: column;
    gap: 25px;
    width: 100vw !important;
    max-width: 100vw !important; /* ensure full width */
    margin-left: 0;
    margin-right: 0;
    padding: 0;
    box-sizing: border-box;
    justify-content: flex-start;
}

.rank-card-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 cards per row */
    gap: 15px;
    justify-items: center; /* center the cards */
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}
/* Force Elementor containers to not restrict width */
.elementor .rank-sections-wrapper,
.elementor .rank-card-container {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
/* Increase possible columns for large screens */
@media (min-width: 1400px) {
    .rank-card-container {
        grid-template-columns: repeat(5, 1fr); /* up to 5 cards side-by-side */
    }
}

@media (min-width: 1100px) and (max-width: 1399px) {
    .rank-card-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 900px) and (max-width: 1099px) {
    .rank-card-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 899px) {
    .rank-card-container {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}
.rank-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
    padding: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.rank-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 14px rgba(0,0,0,0.12);
}
.rank-card-name {
    font-weight: bold;
    font-size: 1.05em;
    margin-bottom: 8px;
    color: #0073aa;
}
.rank-card-stats div {
    font-size: 0.9em;
    margin: 2px 0;
}
.rank-card b {
    color: #333;
}
.rank-summary {
    width: 100%;
    max-width: 100%;
    margin: 30px auto 0;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    padding: 10px 0;
    background: #f8f8f8;
    border-radius: 8px;
}
.rank-top-header { background: #28a745; color: #fff; }
.rank-average-header { background: #ffc107; color: #333; }
.rank-slow-header { background: #dc3545; color: #fff; }
/* ================== COLOR VARIANTS FOR CARDS ================== */
#rank-top-cards .rank-card {
    background: #e8f8ed;
    border-left: 6px solid #28a745;
}
#rank-average-cards .rank-card {
    background: #fff8e5;
    border-left: 6px solid #ffc107;
}
#rank-slow-cards .rank-card {
    background: #fdebea;
    border-left: 6px solid #dc3545;
}
.elementor-widget-container .productivity-rank-wrapper {
    padding: 0 !important;
    margin: 0 auto !important;
    max-width: 100% !important;
}
/* ===== Filter control sizing (prevents select from collapsing) ===== */
#rank-filters-container {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}
/* Basic control shared styling */
.rank-control {
    box-sizing: border-box;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #cfcfcf;
    font-size: 14px;
    background: #fff;
}
#rank-print {
    background-color: #17a2b8;
}
#rank-print:hover {
    background-color: #117a8b;
}
/* Prefer explicit widths to avoid collapse */
#rank-range { min-width: 140px; width: auto; flex: 0 0 auto; }
#rank-start, #rank-end { min-width: 130px; flex: 0 0 auto; }
#rank-print { white-space: nowrap; }
/* Make the search a fixed-ish width so it doesn't steal the row */
#rank-search { flex: 0 0 220px; min-width: 120px; }
/* Small screens: stack nicely */
@media (max-width: 780px) {
    #rank-filters-container { flex-wrap: wrap; gap: 6px; }
    #rank-search { flex: 1 1 100%; min-width: 120px; }
    #rank-range, #rank-start, #rank-end, #rank-print, #editEmployeeBtn {
        flex: 0 0 auto;
    }
}
/* ===== Align filters to ranking width ===== */
.productivity-rank-wrapper > .rank-controls {
    max-width: 1100px;
    margin: 0 auto;
    overflow-x: hidden;
}
#rank-filters-container {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}
#rank-filters-container .rank-control,
#rank-filters-container button {
    flex: 0 0 auto;
}
#rank-search {
    flex: 1 1 220px;
    min-width: 160px;
}
