/* === Rosea Work Tracker: Frontend Admin Styles === */

/* AGGRESSIVE GLOBAL RESET */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
    /* Ensure no main body scroll is triggered by inner content */
    overflow-x: hidden; 
    /* Set the desired page background color */
    background-color: #f0f0f1 !important; 
}
/* END AGGRESSIVE GLOBAL RESET */

#rlwt-frontend-admin-wrapper {
  max-width: 1200px;
  margin: 40px auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background-color: #f6f7f7;
  border: 1px solid #c3c4c7;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.rlwt-admin-header { padding: 20px 24px; background-color: #fff; border-bottom: 1px solid #dcdcde; }
.rlwt-admin-header h1 { margin: 0 0 15px; font-size: 24px; font-weight: 600; color: #1d2327; }
.rlwt-admin-nav { display: flex; gap: 5px; border-bottom: 1px solid #c3c4c7; margin: 0 -24px -21px; padding: 0 24px; }
.rlwt-admin-nav .nav-tab { padding: 10px 16px; font-size: 14px; font-weight: 500; color: #2271b1; text-decoration: none; border: 1px solid transparent; border-bottom: none; margin-bottom: -1px; background: none; cursor: pointer; transition: all 0.15s ease-in-out; }
.rlwt-admin-nav .nav-tab:hover { background-color: #f0f0f1; color: #1d2327; }
.rlwt-admin-nav .nav-tab.active { background-color: #f6f7f7; color: #1d2327; border-color: #c3c4c7; border-bottom-color: #f6f7f7; border-radius: 4px 4px 0 0; }

#rlwt-admin-content { padding: 24px; }
#rlwt-admin-content .tab-content { display: none; }
#rlwt-admin-content .tab-content.active { display: block; }
#rlwt-admin-content h2 { font-size: 20px; margin: 0 0 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid #dcdcde; }
#rlwt-admin-content hr { border: 0; border-top: 1px solid #dcdcde; margin: 2rem 0; }

/* === Notices & Indicators === */
.loading-indicator { padding: 20px; text-align: center; font-size: 16px; color: #50575e; }
#rlwt-fe-form-notice p { margin: 15px 0 0; padding: 10px 15px; border-radius: 4px; border-width: 1px; border-style: solid; }
.success-notice { color: #0f5132; background-color: #d1e7dd; border-color: #badbcc; }
.error-notice { color: #842029; background-color: #f8d7da; border-color: #f5c2c7; }

/* === Table Styles === */
.rlwt-admin-table { width: 100%; border-collapse: collapse; background-color: #fff; border: 1px solid #c3c4c7; }
.rlwt-admin-table th, .rlwt-admin-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #dcdcde; }
.rlwt-admin-table th { background-color: #f0f0f1; font-weight: 600; }
.rlwt-admin-table tbody tr:nth-child(even) { background-color: #f6f7f7; }
.rlwt-admin-table tbody tr:hover { background-color: #e0e7ff; }
.rlwt-admin-table .department-header { background-color: #e8f4fd; font-weight: bold; font-size: 1.1em; }

/* === Form Styles === */
.rlwt-fe-form { background: #fff; padding: 20px; border: 1px solid #dcdcde; border-radius: 4px; }
.rlwt-fe-form .form-group { display: flex; flex-direction: column; }
.rlwt-fe-form label { font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.rlwt-fe-form input[type="text"], .rlwt-fe-form input[type="email"], .rlwt-fe-form input[type="date"], .rlwt-fe-form input[type="time"], .rlwt-fe-form input[type="number"], .rlwt-fe-form select, .rlwt-fe-form textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #8c8f94; border-radius: 3px; box-shadow: inset 0 1px 2px rgba(0,0,0,.07); box-sizing: border-box;
}
.rlwt-fe-form textarea { min-height: 80px; }
/* Added styling for Admin Note (Readonly) to prevent editing on employee side */
.rlwt-admin-note-display textarea[readonly] {
    background-color: #f0f0f1 !important;
    color: #50575e;
    border-style: dashed;
}


/* === Button Styles === */
.button-primary { background: #2271b1; border-color: #2271b1; color: #fff; text-decoration: none; text-shadow: none; padding: 6px 14px; font-size: 14px; border-radius: 3px; cursor: pointer; }
.button-primary:hover { background: #135e96; border-color: #135e96; }
.button-secondary { background: #f6f7f7; border-color: #8c8f94; color: #1d2327; padding: 6px 14px; font-size: 14px; border-radius: 3px; cursor: pointer; }
.button-secondary.small { padding: 2px 8px; font-size: 12px; }

/* Repeater Field Styles */
.dept-row { align-items: center; }
.dept-row input, .dept-row select { flex: 1; }
.dept-row button { margin-left: 10px; }

/* === Filter Form Styles === */
.filters-form { margin-bottom: 20px; }
.filters-form .form-row { grid-template-columns: 1fr 1fr 1fr; }
.filters-form button { margin-right: 10px; }
/* ======================================================= */
/* === Modal Styles for Edit Forms === */
/* ======================================================= */

#rlwt-fe-edit-modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stays in place */
    z-index: 10000; /* On top of everything */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.6); /* Black w/ opacity */
}

#rlwt-fe-edit-modal .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

#rlwt-fe-edit-modal .modal-container {
    position: relative;
    background-color: #fefefe;
    margin: 10% auto; /* 10% from the top and centered */
    padding: 24px;
    border: 1px solid #888;
    width: 90%;
    max-width: 600px; /* Max width */
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 10001; /* Above the overlay */
}

#rlwt-fe-edit-modal .modal-close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0 5px;
}

#rlwt-fe-edit-modal .modal-close-btn:hover,
#rlwt-fe-edit-modal .modal-close-btn:focus {
    color: black;
    text-decoration: none;
}

#rlwt-fe-edit-modal .modal-content {
    clear: both; /* Clear the float from the close button */
}

#rlwt-fe-edit-modal .modal-content h2 {
    margin-top: 0;
    padding-bottom: 15px;
    border-bottom: 1px solid #dcdcde;
}

/* Ensure form inside modal looks good */
#rlwt-fe-edit-modal .rlwt-fe-form {
    padding: 0;
    border: none;
}
/* === Pagination Styles === */
.pagination-links { margin-top: 20px; text-align: center; }
.pagination-links .page-numbers { display: inline-block; padding: 8px 12px; margin: 0 2px; border: 1px solid #c3c4c7; background: #fff; text-decoration: none; color: #2271b1; border-radius: 4px; }
.pagination-links .page-numbers.current, .pagination-links .page-numbers:hover { background: #f0f0f1; border-color: #8c8f94; }
.pagination-links .page-numbers.dots { border: none; background: none; }

/* === Dashboard Sub-Navigation === */
.sub-nav { display: flex; border-bottom: 1px solid #dcdcde; margin-bottom: 1.5rem; }
.sub-nav a { padding: 8px 12px; text-decoration: none; color: #2271b1; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sub-nav a.active, .sub-nav a:hover { border-bottom-color: #2271b1; color: #1d2327; }
.dashboard-report-content { display: none; }
.dashboard-report-content.active { display: block; }

/* === Report Titles === */
.report-category-title { font-size: 18px; margin-top: 1.5rem; margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid #eee; }
.report-category-title:first-of-type { margin-top: 0; }

/* === Report Table Specific Styles === */
/* Standard admin tables: fixed layout */
.dashboard-report-content table.widefat { table-layout: fixed; width: 100%; }
.dashboard-report-content table.widefat th:first-child,
.dashboard-report-content table.widefat td:first-child { width: 180px; }
.dashboard-report-content table.widefat th:last-child,
.dashboard-report-content table.widefat td:last-child { width: 110px; }
.dashboard-report-content table.widefat th:not(:first-child),
.dashboard-report-content table.widefat td:not(:first-child) { text-align: center; white-space: nowrap; }

/* === Form Grid Layout Fix (CORRECTED) === */
.rlwt-fe-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 15px;
  align-items: end; /* Better vertical alignment */
}

/* Make single-item rows span both columns */
.rlwt-fe-form .form-group:only-child {
  grid-column: 1 / -1;
}

/* Responsive fix for smaller screens */
@media (max-width: 768px) {
  .rlwt-fe-form .form-row {
    grid-template-columns: 1fr;
  }
}

/* ======================================================= */
/* === MOBILE/FRONTEND HOLIDAY PAGE CSS FIX (Issue 3) === */
/* === Simplified Scroll/Background Fix === */
/* ======================================================= */

/* 1. Outer wrapper ensures the desired page background is visible. */
.rlwt-mobile-page-wrapper {
    padding: 20px 0; 
    min-height: 100vh;
    box-sizing: border-box;
    overflow: visible; 
}

/* 2. The inner card wrapper is now just the container for the scrolling section and title */
.rlwt-holiday-list-wrapper {
    max-width: 600px;
    margin: 0 auto;
    background: transparent; 
    box-shadow: none; 
    padding: 20px 0; 
    overflow: visible; 
    display: block;
    width: 100%;
}

/* 3. Dedicated scroll container added in PHP (This is the white scrollable card) */
.office-holidays-table-container {
    /* CRITICAL: This is the element that must trigger the scroll */
    overflow-x: auto; 
    overflow-y: hidden;
    display: block; 
    width: 100%;
    
    /* Apply the visual card style and background here */
    background: #ffffff; 
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    
    /* Set inner padding for the contents that DO NOT scroll (title) */
    padding: 10px; 
}

/* 4. Target the actual table structure inside the scroll wrapper */
.rlwt-holiday-list-wrapper table.rlwt-holiday-table {
    /* Set table layout properties */
    table-layout: fixed; 
    /* Set an explicit width much larger than the mobile viewport */
    width: 500px; 
    min-width: 500px; 
    border-collapse: collapse;
    margin: 0;
    padding: 0; 
}

/* 5. Target the Table Header (Header and table must be separate for padding/overflow to work) */
.rlwt-holiday-list-wrapper h2 {
    /* Use padding from the card wrapper */
    padding: 0 20px 10px 20px;
    border-bottom: 1px solid #dcdcde;
    margin-bottom: 10px;
}
.rlwt-holiday-list-wrapper .office-holidays-table-container h2 {
    /* Remove padding if the H2 is inside the scroll wrapper (must be tested) */
    padding: 10px;
    margin: 0;
}

/* 6. Responsive adjustment for small screens */
@media (max-width: 600px) {
    .rlwt-mobile-page-wrapper {
        padding: 10px 0;
    }
    
    .rlwt-holiday-list-wrapper {
        /* Use margin to separate card from screen edge */
        margin: 0 15px; 
        padding: 0; 
    }
    
    .office-holidays-table-container {
        /* Adjust padding for the scrollable area */
        padding: 15px 5px; 
    }

    /* Force cell widths in pixels to ensure the table is wide enough */
    .rlwt-holiday-list-wrapper table.rlwt-holiday-table th, 
    .rlwt-holiday-list-wrapper table.rlwt-holiday-table td {
        padding: 10px 8px;
        font-size: 14px;
        white-space: nowrap; 
    }

    /* Column widths to force the 500px width */
    .rlwt-holiday-list-wrapper table.rlwt-holiday-table th:first-child,
    .rlwt-holiday-list-wrapper table.rlwt-holiday-table td:first-child { 
        width: 150px; 
    }

    .rlwt-holiday-list-wrapper table.rlwt-holiday-table th:nth-child(2),
    .rlwt-holiday-list-wrapper table.rlwt-holiday-table td:nth-child(2) {
        width: 100px; 
    }
    
    .rlwt-holiday-list-wrapper table.rlwt-holiday-table th:last-child,
    .rlwt-holiday-list-wrapper table.rlwt-holiday-table td:last-child {
        width: 250px; 
    }
}
/* Fix for autocomplete suggestions appearing behind other content */
.ui-autocomplete {
    background-color: #ffffff !important; /* Force a white background */
    border: 1px solid #d1d5db !important;   /* Add a light border */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1) !important; /* Add a shadow */
    border-radius: 6px !important;        /* Match your new style */
    z-index: 9999 !important;             /* Ensure it's on top */
    padding: 4px !important;              /* Add some internal padding */
    list-style: none !important;          /* Remove bullets */
    width: auto !important;               /* <-- This fixes the stretching */
    position: absolute !important;        /* Ensures proper positioning */
}

/* Style for the individual items inside the list */
.ui-autocomplete .ui-menu-item {
    padding: 6px 10px !important;
    cursor: pointer;
    border-radius: 4px !important;
    margin: 0 !important;
}

/* Style for the highlighted/hovered item */
.ui-autocomplete .ui-menu-item .ui-menu-item-wrapper.ui-state-active {
    background: #3b82f6 !important; /* Blue 500 (matches your new style) */
    color: #ffffff !important;
    border: none !important;
    margin: 0 !important;
}
/* ======================================================= */
/* === Tablet Responsive Fix for Nav === */
/* ======================================================= */

@media (max-width: 1199px) {
  .rlwt-admin-nav {
    /* Allow the container to scroll horizontally */
    overflow-x: auto;
    /* Prevent tabs from wrapping to the next line */
    flex-wrap: nowrap;
    /* Add some padding to the bottom for the scrollbar */
    padding-bottom: 5px;
  }
  
  .rlwt-admin-nav .nav-tab {
    /* Ensure tabs don't shrink */
    flex-shrink: 0;
  }
}