/**
 * Dashboard Styles
 *
 * This file contains all styles for the CanTrace Farms Dashboard.
 *
 * @author Craig Hope (HopeTech Agri Solutions)
 * @since 1.0.0
 * @updated 2.80.0 - Added professional, elevated styles for the new KPI tiles.
 * @updated 2.82.0 - FIX: Added 'cursor: pointer' to .kpi-tile for click indication and ensured the drag-and-drop library correctly handles the new interactive element.
 * @updated 2.91.0 - FEATURE: Added styles for .dashboard-list-item-clickable to improve UX for the new drill-down functionality in the Critical Alerts and Herd Events cards.
 * @updated 3.3.4 - UI CLEANUP: Adjusted header layout to align "Welcome" text beside the user name and vertically center the notification bell.
 * @updated 4.5.0 - UI: Added styles for the new DataTables implementation in the All Records section.
 */

/* Basic styling for the CanTrace Farms Dashboard */

/* Force full width for the entire page and prevent horizontal scroll */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    overflow-x: hidden !important; /* Prevent horizontal scroll */
}

/* Hide WordPress Admin Bar */
#wpadminbar {
    display: none !important;
}

/* --- Specific overrides for the dashboard page (Page ID 164) --- */
body.page-id-164 .site-header,
body.page-id-164 .main-header,
body.page-id-164 .site-footer,
body.page-id-164 .main-footer,
body.page-id-164 .nav-primary,
body.page-id-164 .site-navigation,
body.page-id-164 .sidebar,
body.page-id-164 .woocommerce-notices-wrapper
{
    display: none !important;
}

body.page-id-164 #main,
body.page-id-164 .site-main,
body.page-id-164 .content-wrap,
body.page-id-164 article.post-164,
body.page-id-164 .entry-content.single-content,
body.page-id-164 .content-container,
body.page-id-164 .site-container
{
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    display: block !important;
    box-sizing: border-box;
}
.content-area{
    margin: 0!important;
}

.cantrace-dashboard-container {
    font-family: 'Inter', sans-serif;
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa; /* Slightly lighter main background */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === START HEADER REFINEMENT === */
.dashboard-header {
    background-color: #ffffff;
    padding: 15px 30px; /* Increased padding for better spacing */
    border-bottom: 1px solid #e5e7eb; /* Softer border color */
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04); /* Subtler shadow */
    width: 100%;
    box-sizing: border-box;
    position: relative;
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 16px; /* Consistent gap */
}

/* MODIFICATION: Adjusted logo height slightly */
.header-logo-large {
    height: 50px; 
    width: auto;
}

/* MODIFICATION: Updated flex layout to put Welcome and Name side-by-side */
.header-welcome-text {
    display: flex;
    flex-direction: row; /* Changed from column to row */
    align-items: baseline; /* Align text on the baseline */
    gap: 5px; /* Spacing between "Welcome," and the name */
}

.welcome-title {
    font-size: 1em; /* Increased size to match name better */
    color: #6b7280;  /* Softer grey color */
    line-height: 1;
    font-weight: 400; /* Regular weight */
}

.welcome-name {
    font-size: 1.1em; /* Adjusted size */
    font-weight: 600;
    color: #111827; /* Darker, more professional text color */
    line-height: 1;
}

/* MODIFICATION: Improved vertical centering for the right side elements */
.header-farm-display {
    text-align: right;
    display: flex; /* Use flexbox for vertical alignment */
    flex-direction: column;
    justify-content: center;
}

.farm-label {
    font-size: 0.85em;
    color: #6b7280;
    display: block;
    line-height: 1;
    font-weight: 500;
    margin-bottom: 4px; /* Add slight spacing below label */
}

.farm-name-pid {
    font-size: 1.15em; /* Adjusted size */
    font-weight: 600;
    color: #111827;
    line-height: 1.2;
}

/* NEW: Styles for the Alerts Bell and Dropdown */
.alerts-bell-container {
    position: relative;
    cursor: pointer;
    line-height: 1;
    z-index: 101;
    display: flex; /* Ensure the icon centers in its container */
    align-items: center;
    height: 100%; /* Take full height if needed */
    padding-top: 4px; /* Slight manual adjustment if font rendering is off */
}

.alerts-bell-container .dashicons {
    font-size: 28px;
    color: #4b5563; /* Default bell color */
    transition: color 0.2s ease;
    height: 28px; /* Force height to match font size */
    width: 28px;  /* Force width */
    display: flex;
    align-items: center;
    justify-content: center;
}

.alerts-bell-container:hover .dashicons {
    color: #111827; /* Hover color */
}

.alerts-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #ef4444; /* Red for alerts */
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 50%;
    padding: 3px 6px;
    min-width: 15px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.alerts-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 450px; /* Increased from 300px for better readability */
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* Slightly deeper shadow */
    margin-top: 15px;
    max-height: 500px; /* Increased height limit */
    overflow-y: auto;
    z-index: 1000; /* Ensure it floats above other elements */
}

.alerts-dropdown.active {
    display: block;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 10px;
}

.alerts-dropdown h4 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    font-weight: 600;
    color: #1f2937;
    border-bottom: 1px solid #f3f4f6;
    padding-bottom: 10px;
}

#alerts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.alert-item {
    padding: 15px; /* Added horizontal padding and increased vertical padding */
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.2s ease;
}

.alert-item:last-child {
    border-bottom: none;
}

/* Make notification items look clickable */
.alert-item.notification-item {
    cursor: pointer;
}

/* Styles for the Notification Header with Clear All button */
.notifications-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #f3f4f6;
    background-color: #ffffff;
    position: sticky; /* Keep header visible while scrolling */
    top: 0;
    z-index: 10;
}
.notifications-header h4 {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    color: #1f2937;
    border-bottom: none; /* Remove border from H4 as container has it */
    padding-bottom: 0;
}
#clear-all-notifications-btn {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.85em;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    margin: 0;
}
#clear-all-notifications-btn:hover {
    color: #ef4444; /* Red on hover */
    background: none;
    transform: none;
}

#clear-all-notifications-btn:disabled {
    color: #d1d5db;
    text-decoration: none;
    cursor: default;
}

.alert-item p {
    margin: 0;
    font-size: 0.9em;
    line-height: 1.4;
    color: #4b5563;
}

.alert-item .alert-buttons {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.alert-item:hover {
    background-color: #f9fafb; /* Subtle hover effect */
}

.alert-item .alert-buttons .button {
    padding: 6px 12px;
    font-size: 0.8em;
    margin: 0;
    position: relative; /* For spinner */
}

/* --- MODIFICATION START: Styles for inline button loading/success --- */
.alert-buttons .button .btn-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

.alert-buttons .button.is-loading .btn-text {
    display: none;
}

.alert-buttons .button.is-loading .btn-spinner {
    display: inline-block;
    margin: 0;
}
.alert-buttons .button.is-loading {
    cursor: wait;
}

.alert-buttons .button.is-success {
    background-color: #22c55e !important;
    border-color: #16a34a !important;
}

.alert-error-message {
    font-size: 0.85em !important;
    color: #dc3545 !important;
    font-weight: 500;
    margin-top: 8px !important;
}
/* --- MODIFICATION END --- */


/* === END HEADER REFINEMENT === */

/* Styles for the Request Farm Access button */
#request-farm-access-btn {
    padding: 8px 14px;
    font-size: 0.9em;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#request-farm-access-btn .dashicons {
    font-size: 18px;
    line-height: 1;
}

.clts-card {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.clts-card.full-width-card {
    max-width: 100%;
}

.clts-card h3, .clts-card h4, .clts-card h5 {
    color: #444;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.5em;
    font-weight: 600;
}

.clts-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
    position: relative; /* Needed for absolute positioning of search results */
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus {
    border-color: #28a745;
    outline: none;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.25);
}

button {
    background-color: #28a745;
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.3s ease, transform 0.1s ease;
    margin-right: 10px;
}

button:hover {
    background-color: #218838;
    transform: translateY(-1px);
}

button:active {
    background-color: #1e7e34;
    transform: translateY(0);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    font-weight: 500;
    display: none;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
}

.message.info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #28a745;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 15px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Overall Dashboard Layout */
.dashboard-layout {
    display: flex;
    min-height: calc(100vh - 85px); /* Adjusted for new header height */
    width: 100%;
}

.dashboard-sidebar {
    width: 200px;
    flex-shrink: 0;
    background-color: #333;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: #f8f8f8;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-left: 5px solid transparent;
    text-align: left;
}
.sidebar-nav .nav-item:hover {
    cursor: pointer;
    background-color: #555;
    color: #fff;
}

.sidebar-nav .nav-item.active {
    background-color: #28a745;
    color: #fff;
    border-left-color: #fff;
}

.dashboard-main-content {
    flex-grow: 1;
    background-color: #f8f9fa;
    padding: 20px;
}

.dashboard-section {
    display: none;
}

.dashboard-section.active-section {
    display: block;
}

/* Dashboard Grid System */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 300px; /* Define a standard row height */
    gap: 20px;
    position: relative;
}

.dashboard-card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    position: relative; 
    overflow: hidden;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    transition: box-shadow 0.2s ease, opacity 0.2s ease;
    grid-column: span 1;
    grid-row: span 1;
    grid-area: auto / auto / span 1 / span 1;
}

.dashboard-card .card-content {
    width: 100%;
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative; 
    box-sizing: border-box;
    min-height: 0;
    overflow: auto; /* Allow content like charts to scroll if they become too large */
}

.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.dashboard-card .chart-loading-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #28a745;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 5;
}


.dashboard-card h4 {
    color: #333;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
    font-weight: 600;
    width: 100%;
    flex-shrink: 0;
}

.dashboard-card p {
    font-size: 2.2em;
    font-weight: 700;
    color: #28a745;
    margin: 0;
}

.chart-card {
    min-height: 300px;
    position: relative; 
}

.chart-card canvas {
    max-height: 100%;
    width: 100% !important;
    height: 100% !important;
}

.no-data-message {
    color: #888;
    font-style: italic;
    font-size: 0.9em;
    margin-top: 10px;
}

.chart-card .no-data-message {
    font-size: 1.1em;
    font-weight: 500;
    color: #6b7280;
    font-style: normal;
    text-align: center;
    padding: 20px;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Record Lists */
.records-list {
    list-style: none;
    padding: 0;
    margin-top: 20px;
}

.records-list li {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    line-height: 1.5;
    color: #555;
    text-align: left;
}

.records-list li strong {
    color: #333;
}

/* --- MODIFICATION START: Styles for clickable list items in dashboard cards --- */
.dashboard-list-item-clickable {
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#critical-alerts-list .dashboard-list-item-clickable:hover {
    background-color: #fff5e6; /* Light warning yellow */
    border-color: #ffc107;
}

#herd-events-list .dashboard-list-item-clickable:hover {
    background-color: #f3f9f3; /* Very light green */
    border-color: #28a745;
}
/* --- MODIFICATION END --- */

/* Drag & Resize Handle Styling */
.drag-handle {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: #28a745;
    color: white;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 0.8em;
    font-weight: 600;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 10;
    transition: background-color 0.2s ease;
    touch-action: none; /* This is the fix: Prevents browser interference on touch/drag */
}

.drag-handle:hover {
    background-color: #218838;
}

/* Styles for the visible resize handle and resizing state */
.resize-handle-se {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    z-index: 11;
}
.resize-handle-se::after {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 8px;
    height: 8px;
    border-right: 2px solid #aaa;
    border-bottom: 2px solid #aaa;
    transition: border-color 0.2s ease;
}
.resize-handle-se:hover::after {
    border-color: #28a745;
}

.dashboard-card.is-resizing {
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    opacity: 0.7; /* Make the original card semi-transparent */
}

.resize-ghost {
    position: absolute;
    background-color: rgba(40, 167, 69, 0.1);
    border: 2px dashed #28a745;
    border-radius: 10px;
    z-index: 99;
    box-sizing: border-box;
    pointer-events: none; /* Make sure it doesn't interfere with mouse events */
}

/* --- All other styles remain the same --- */

/* Multiple CLTS Accounts Management */
#clts-account-selector {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1em;
    margin-bottom: 15px;
}

.clts-account-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.clts-account-item:last-child {
    border-bottom: none;
}

.clts-account-item .button-small {
    padding: 6px 12px;
    font-size: 0.85em;
    margin-left: 10px;
}

/* Custom Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: 90%; 
    width: 500px; /* A fixed width for most modals */
    max-height: 90vh; 
    text-align: center;
    display: flex; 
    flex-direction: column; 
}

#modal-body {
    flex-grow: 1; 
    overflow-y: auto; 
    padding-bottom: 20px;
    text-align: left; /* Default text to left for forms */
}

.modal-form-content {
    width: 100%;
    max-width: 800px;
    margin: 0 auto; 
}


.modal-buttons {
    flex-shrink: 0;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.modal-buttons button {
    margin: 0 10px;
}

/* MODIFICATION START: Professional styles for the Animal Management cards */
#animals-list-container {
    padding-top: 20px;
}

#animals-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    list-style: none;
    padding: 0;
}

.animal-card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: auto; /* Allow height to be determined by content */
    position: relative; /* For status indicator positioning */
    overflow: hidden; /* To contain the header accent */
}

.animal-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.animal-card-header {
    display: flex;
    align-items: center;
    
    padding: 15px;
    border-bottom: 1px solid #f3f4f6;
    background-color: #f9fafb;
    position: relative;
    padding-left: 20px;
}

/* Green accent bar */
.animal-card-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background-color: #28a745;
}

.animal-card-header .header-icon {
    flex-shrink: 0;
    width: 65px; /* Slightly increased from 32px for better visibility of the new image */
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Ensure image stays inside */
}
/* Style specifically for the new image icon */
.animal-card-header .header-icon img.animal-card-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ensures the whole icon is visible without cropping */
    display: block;
}
/* Remove old SVG styles if they conflict (optional, but cleaner) */
.animal-card-header .header-icon svg {
    display: none; 
}

.animal-card-header h5 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.animal-card-body {
    padding: 20px;
    flex-grow: 1;
    text-align: left;
}

.animal-card-body p {
    margin: 0;
    color: #6b7280;
    font-size: 0.9em;
}

.animal-card-body .data-value {
    font-weight: 500;
    color: #374151;
    display: block;
    font-size: 1em;
    margin-top: 4px;
}

.animal-card-footer {
    padding: 15px 20px;
    border-top: 1px solid #f3f4f6;
    text-align: right;
}

.animal-card-footer a {
    color: #28a745;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
}

.animal-card-footer a:hover {
    color: #218838;
}

.animal-card-footer a .dashicons {
    font-size: 18px;
    line-height: 1;
}

/* Status Indicator for withdrawal alerts */
.animal-card.has-withdrawal-alert .animal-card-status-indicator {
    display: flex;
}

.animal-card-status-indicator {
    display: none; /* Hidden by default */
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background-color: #ef4444; /* Red for alerts */
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    color: white;
}

.animal-card-status-indicator .dashicons {
    font-size: 18px;
    line-height: 1;
}
/* MODIFICATION END */


#animal-profile-view {
    /* Styles for the container that will hold the profile */
}

.animal-profile-header {
    background-color: #fff;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
}

.animal-profile-header h2 {
    margin: 0 0 15px 0;
    font-size: 2em;
    position: relative; /* Fix for timeline overlap */
    z-index: 2; /* Fix for timeline overlap */
}

.animal-profile-details {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    color: #6b7280;
}

.animal-profile-details p {
    margin: 0;
    font-size: 1.1em;
}

.animal-profile-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.animal-profile-actions .button .dashicons {
    margin-right: 8px;
}

.animal-profile-timeline {
    margin-top: 20px;
    position: relative;
}
#animal-timeline-container {
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    margin-top: 15px;
    padding: 15px; /* Add padding inside the container */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
/* DataTables Overrides for Timeline Grid */
#animal-timeline-table {
    font-size: 0.9em;
    border-bottom: 1px solid #f0f0f0;
}

#animal-timeline-table thead th {
    background-color: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
    color: #374151;
    font-weight: 600;
    padding: 12px 15px;
}

#animal-timeline-table tbody td {
    padding: 12px 15px;
    vertical-align: top;
    color: #4b5563;
    border-bottom: 1px solid #f3f4f6;
}

#animal-timeline-table tbody tr:hover {
    background-color: #f8fafc; /* Subtle hover highlight */
}
/* Timeline Image Thumbnail in Table */
#animal-timeline-table .image-card {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background-color: #f3f4f6;
    border-radius: 4px;
    color: #374151;
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 500;
    transition: background-color 0.2s;
}
#animal-timeline-table .image-card:hover {
    background-color: #e5e7eb;
}

/* Responsive adjustments for DataTables */
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 15px;
}
.dataTables_wrapper .dataTables_length {
    margin-bottom: 15px;
}
/* Status Badges within Table */
.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
}
.status-badge.success {
    background-color: #dcfce7;
    color: #166534;
}
.status-badge.warning {
    background-color: #fef9c3;
    color: #854d0e;
}
.status-badge.error {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Category-Specific Row Accents (Left Border) */
.row-health td:first-child {
    border-left: 4px solid #28a745; /* Green for Health */
}
.row-medication td:first-child {
    border-left: 4px solid #dc3545; /* Red for Meds */
}
.row-movement td:first-child {
    border-left: 4px solid #4b5563; /* Grey for Movement */
}
.row-clts td:first-child {
    border-left: 4px solid #ffc107; /* Yellow for CLTS */
}
.animal-profile-timeline h3 {
    position: relative;
    z-index: 2;
}

.timeline-event {
    background-color: #fff;
    border-left: 5px solid #28a745;
    padding: 15px 20px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.timeline-event.health { border-color: #ffcd56; }
.timeline-event.medication { border-color: #ff6384; }
.timeline-event.movement { border-color: #36a2eb; }


.timeline-event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.timeline-event-header h5 {
    margin: 0;
    font-size: 1.2em;
    color: #333;
}

.timeline-event-header .date {
    font-size: 0.9em;
    color: #6b7280;
    font-weight: 500;
}

.timeline-event-details p {
    margin: 4px 0;
    color: #555;
}

/* Fluid Form Layout for Modals */
.form-columns-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
}

.form-column {
    flex: 1; 
    min-width: 250px; 
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }
    .dashboard-sidebar {
        width: 100%;
    }
    .sidebar-nav {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 0;
    }
    .sidebar-nav .nav-item {
        width: 100%; 
        box-sizing: border-box;
    }
    .dashboard-main-content {
        padding: 10px;
    }
    
    .dashboard-grid {
       grid-template-columns: 1fr;
       grid-auto-rows: auto;
       height: auto;
    }

    .dashboard-card {
        grid-column: span 1 !important; /* Override inline styles */
        grid-row: span 1 !important;
        width: 100% !important;
        height: auto !important;
        min-height: 250px;
    }
    
    .form-columns-container {
        flex-direction: column; 
        gap: 0;
    }

    /* KPI Tile Responsive Stacking */
    .kpi-tile-container {
        flex-direction: column;
    }
    .kpi-tile {
        margin-bottom: 15px; /* Add spacing when stacked */
        width: 100%;
    }
}

/* Loading Overlay Styles */
#cantrace-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(49, 49, 40, 0.95); 
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
    color: #ffffff;
    transition: opacity 0.3s ease-in-out;
}

.loader-content {
    text-align: center;
}

.loader-spinner {
    border: 6px solid rgba(255, 255, 255, 0.3);
    border-top: 6px solid #28a745; 
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

.loader-text {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 1px;
}

.loader-subtext {
    font-size: 16px;
    margin-top: 10px;
    color: #e5e7eb; 
}

/* Messaging Search UI Styles */
.search-results-dropdown {
    position: absolute;
    top: 100%; 
    left: 0;
    right: 0;
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px; 
    overflow-y: auto;
    z-index: 100; 
    display: none; 
    margin-top: 5px; 
}

.search-result-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    text-align: left;
    color: #333;
    transition: background-color 0.2s ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #f0f0f0;
}

.search-result-item strong {
    font-weight: 600;
    color: #111827;
}

.search-result-item small {
    display: block;
    font-size: 0.85em;
    color: #6b7280;
    margin-top: 2px;
}

.search-result-item.no-results {
    padding: 12px 15px;
    color: #888;
    font-style: italic;
    cursor: default;
    background-color: #fff;
}

.selected-user-tag {
    display: inline-block;
    padding: 8px 15px;
    background-color: #e6ffe6; 
    border: 1px solid #28a745;
    border-radius: 20px; 
    font-size: 0.9em;
    font-weight: 500;
    color: #155724; 
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%; 
}

/* Messaging container */
.messaging-container {
    display: flex;
    gap: 20px;
    min-height: 600px; 
}

.conversation-list-panel {
    flex: 0 0 300px; 
    background-color: #f8f9fa; 
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.05); 
    display: flex;
    flex-direction: column;
}

.conversation-list-panel .button {
    width: 100%;
    margin-bottom: 15px;
}

.conversation-list-panel .records-list {
    flex-grow: 1;
    overflow-y: auto; 
    margin-top: 0;
    padding-right: 5px; 
}

.conversation-list-panel .records-list li {
    cursor: pointer;
    border-left: 5px solid transparent;
    transition: background-color 0.2s ease, border-left-color 0.2s ease;
}

.conversation-list-panel .records-list li:hover {
    background-color: #f0f0f0;
    border-left-color: #28a745;
}

.conversation-list-panel .records-list li.active {
    background-color: #e6ffe6; 
    border-left-color: #28a745;
}

.chat-window {
    flex-grow: 1;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-header h4 {
    margin: 0;
    font-size: 1.3em;
    color: #111827;
}

.messages-display {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.my-message {
    align-self: flex-end;
    background-color: #28a745;
    color: white;
    border-bottom-right-radius: 2px; 
}

.other-message {
    align-self: flex-start;
    background-color: #e5e7eb;
    color: #333;
    border-bottom-left-radius: 2px; 
}

.message-bubble strong {
    font-size: 0.9em;
    display: block;
    margin-bottom: 5px;
    color: inherit; 
}

.my-message strong {
    color: rgba(255, 255, 255, 0.9);
}

.other-message strong {
    color: #111827;
}

.message-bubble small {
    font-size: 0.75em;
    color: rgba(0, 0, 0, 0.5);
    display: block;
    margin-top: 5px;
    text-align: right;
}

/* Typing Indicator */
.typing-indicator {
    padding: 10px 20px;
    font-size: 0.9em;
    color: #6b7280;
    font-style: italic;
    display: flex;
    align-items: center;
    height: 20px;
}

.typing-indicator::after {
    content: '...';
    display: inline-block;
    animation: typing-dots 1.5s infinite;
    width: 1em; 
    text-align: left;
}

@keyframes typing-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

.chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area textarea {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 10px;
    resize: vertical;
    min-height: 40px;
    max-height: 120px;
    font-size: 1em;
}

.chat-input-area button {
    padding: 10px 20px;
    white-space: nowrap;
    margin-right: 0; 
}

@media (max-width: 992px) {
    .messaging-container {
        flex-direction: column;
    }
}

/* Image Gallery Styles */

.image-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.image-actions input {
    width: auto;
    flex-grow: 1;
    max-width: 400px;
}
.image-actions button {
    flex-shrink: 0;
    margin-right: 0;
}

#farm-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.image-card {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.image-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.image-card img {
    width: 100%;
    height: 250px; 
    object-fit: cover; 
    display: block;
}

.image-info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0,0,0,0.6);
    color: white;
    padding: 15px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    text-align: left;
}

.image-card:hover .image-info-overlay {
    transform: translateY(0);
}

.image-info-overlay .image-animal-id,
.image-info-overlay .image-date {
    display: block;
    margin: 0;
    font-size: 0.9em;
}

/* Image Modal Styles */
.image-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(49, 49, 40, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

.image-modal-content {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    position: relative;
}

.image-modal-header {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: calc(100% - 40px);
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

.image-modal-header h4 {
    margin: 0;
    color: #fff;
}

.image-modal-body {
    display: flex;
    flex-grow: 1;
    height: 100%;
    width: 100%;
}

.image-viewer {
    flex: 2;
    background-color: #313128;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#image-details {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: #fff;
    padding: 20px;
    text-align: left;
}

#image-details p {
    margin: 0;
    font-size: 0.9em;
}

#image-details strong {
    font-weight: 600;
}

.image-comments-section {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    max-width: 400px;
}

.image-comments-section h5 {
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    font-size: 1.2em;
    font-weight: 600;
}

#image-comments-list {
    flex-grow: 1;
    overflow-y: auto;
    max-height: 100%;
    min-height: 150px;
    margin-bottom: 15px;
}

.comment-item {
    border-bottom: 1px solid #f5f5f5;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.comment-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.comment-item p {
    margin: 0 0 5px 0;
    font-size: 0.9em;
    line-height: 1.4;
}

.comment-item small {
    font-size: 0.7em;
    color: #888;
    display: block;
}

.add-comment-form {
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.add-comment-form textarea {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    border: 1px solid #ccc;
    padding: 10px;
    box-sizing: border-box;
    resize: vertical;
}

.add-comment-form button {
    width: 100%;
    margin-top: 10px;
}

@media (max-width: 992px) {
    .image-modal-content {
        flex-direction: column;
        max-height: 95vh;
        max-width: 95vw;
    }
    .image-comments-section {
        max-height: 300px;
        min-height: 200px;
    }
}

.single-content ul, .single-content ol {
    margin: 0 0 var(--global-md-spacing);
}

/* Dashboard Overview Cards */

.record-summary-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    margin-top: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.record-summary-item {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    transition: background-color: 0.2s ease;
}

.record-summary-item:hover {
    background-color: #f3f4f6;
}

.record-summary-item .stat-value {
    font-size: 1.8em;
    font-weight: 700;
    color: #28a745;
    margin: 0;
}

.record-summary-item .stat-label {
    font-size: 0.8em;
    color: #6b7280;
    font-weight: 500;
    margin-top: 5px;
    line-height: 1.2;
}

#active-withdrawal-card {
    background-color: #ffffff; /* Clean white background */
    border: 1px solid #e5e7eb; /* Standard subtle border */
    border-left: 5px solid #28a745; /* Green accent on the left */
}
/* Ensure the chart container has room */
#active-withdrawal-card .card-content {
    min-height: 300px;
    padding: 10px;
}

#active-withdrawal-card .records-list {
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
}

/* Update the list items inside to remove the yellow border */
#active-withdrawal-card .records-list li {
    border: none;
    background-color: transparent;
    padding: 8px 0;
    box-shadow: none;
    border-bottom: 1px solid #f3f4f6; /* Subtle separator */
    padding-left: 0;
}

#movements-by-month-chart-card {
    grid-column: span 2;
}

/* Health Record Detail Modal */
#health-record-detail-modal .modal-content {
    max-width: 600px; 
    text-align: left;
}

#health-record-detail-modal .detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

#health-record-detail-modal .detail-header h4 {
    margin: 0;
    font-size: 1.4em;
    color: #111827;
}

#health-record-detail-modal .detail-header .button {
    margin: 0;
}

#health-record-detail-modal .record-details-body {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 15px;
}

.record-summary-section {
    display: flex;
    justify-content: space-between;
    background-color: #f9fafb;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.summary-item {
    text-align: center;
}

.summary-item strong {
    display: block;
    font-size: 0.8em;
    color: #6b7280;
    margin-bottom: 5px;
}

.summary-item span {
    font-size: 1.1em;
    font-weight: 600;
    color: #1f2937;
}

.record-details-section {
    margin-bottom: 20px;
}

.record-details-section h4 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    color: #28a745;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
}

.record-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}
.record-detail-row:last-child {
    border-bottom: none;
}

.record-detail-row strong {
    color: #4b5563;
    font-weight: 500;
}

.record-detail-row span, .record-detail-row p {
    color: #1f2937;
    text-align: right;
    margin: 0;
}

.image-gallery-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.record-detail-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

/* MODIFICATION START: New styles for the Reports Section */
.report-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.report-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.report-filters-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.report-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.report-results-header h4 {
    margin: 0;
}

.report-actions .button {
    margin-left: 10px;
}

.report-tabs {
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
}

.report-tabs .tab-link {
    background-color: transparent;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 600;
    color: #6b7280;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.report-tabs .tab-link.active {
    color: #28a745;
    border-bottom-color: #28a745;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

#report-raw-data-output {
    background-color: #2d2d2d;
    color: #f1f1f1;
    padding: 20px;
    border-radius: 8px;
    max-height: 500px;
    overflow: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

/* DataTables Styling Overrides */
.dataTables_wrapper {
    font-size: 0.9em;
}
.dataTables_filter input {
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 5px;
}
/* MODIFICATION END */

/* MODIFICATION START: New styles for Animal Management and Health Records */

/* --- Animal List --- */
#animals-list-container {
    padding-top: 20px;
}

#animals-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    list-style: none;
    padding: 0;
}

/* --- New Event Timeline Styles --- */
.animal-profile-timeline {
    position: relative;
    padding: 20px 0;
}

.timeline-event {
    position: relative;
    margin-bottom: 30px;
    padding-left: 80px; /* Space for the icon */
}

.timeline-icon {
    position: absolute;
    left: 18px; /* (40px line center - 22px icon radius) */
    top: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.timeline-icon .dashicons {
    font-size: 24px;
    color: #fff;
}

/* Icon Colors */
.timeline-event.event-health .timeline-icon { background-color: #28a745; } /* Green */
.timeline-event.event-medication .timeline-icon { background-color: #dc3545; } /* Red */
.timeline-event.event-image .timeline-icon { background-color: #17a2b8; } /* Teal */
.timeline-event.event-submission .timeline-icon { background-color: #ffc107; } /* Yellow */
.timeline-event.event-general .timeline-icon { background-color: #6c757d; } /* Grey */


.timeline-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    position: relative;
}

.timeline-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.timeline-content-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.timeline-content-header .date {
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
}

.timeline-content-details p {
    margin: 0 0 10px 0;
    line-height: 1.6;
}

.timeline-content-details p:last-child {
    margin-bottom: 0;
}

.timeline-image-thumbnail {
    max-width: 150px;
    height: auto;
    border-radius: 6px;
    margin-top: 10px;
    cursor: pointer;
    border: 1px solid #ddd;
    padding: 3px;
    background: #fff;
}

/* Responsive adjustments for the timeline */
@media (max-width: 768px) {
    .animal-profile-timeline::before {
        left: 20px;
    }
    .timeline-event {
        padding-left: 60px;
    }
    .timeline-icon {
        left: -2px; /* (20px line center - 22px icon radius) */
        width: 40px;
        height: 40px;
    }
    .timeline-icon .dashicons {
        font-size: 20px;
    }
}
/* MODIFICATION END */

/* MODIFICATION START: New styles for Health Record selection */
.health-record-item.selection-mode {
    cursor: pointer;
    padding-left: 50px; /* Make space for the checkbox */
    position: relative;
    transition: background-color 0.2s ease;
}

.health-record-item .record-checkbox {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.health-record-item.record-selected {
    background-color: #e6f7ff; /* A light blue to indicate selection */
    border-left: 5px solid #1890ff; /* A blue left border for emphasis */
}

.selection-action-buttons {
    display: none; /* Hidden by default */
}
/* MODIFICATION END */


/* --- MERGED STYLES: DRAFTS PAGE AND MEDICATION MODAL --- */

/* MODIFICATION START: New container style for the grid layout and status headers */
.drafts-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

h4.status-header {
    grid-column: 1 / -1; /* Make the header span all columns */
    margin-top: 20px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e5e7eb;
    color: #1f2937;
    font-size: 1.3em;
}
h4.status-header:first-of-type {
    margin-top: 0;
}
/* MODIFICATION END */

/* --- Drafts Page Card Styling --- */
.draft-card {
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-left: 5px solid #6c757d; /* Default 'draft' color */
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.draft-card.status-pending {
    border-left-color: #ffc107; /* Yellow */
}
.draft-card.status-error {
    border-left-color: #dc3545; /* Red */
}

.draft-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.draft-card-header h5 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

.draft-status-badge {
    font-size: 0.8em;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    color: #fff;
    background-color: #6c757d; /* Default 'draft' */
}
.draft-card.status-pending .draft-status-badge,
.submission-card .status-pending {
    background-color: #f59e0b; /* Amber for pending */
    color: #fff;
}
.draft-card.status-error .draft-status-badge,
.submission-card .status-error {
    background-color: #ef4444; /* Red for error */
}

.submission-card .status-synced {
    background-color: #22c55e; /* Green for synced */
}

.draft-card-body {
    font-size: 0.9em;
    color: #4b5563;
    line-height: 1.6;
    flex-grow: 1;
}
.draft-card-body p {
    margin: 0 0 5px 0;
}

.draft-card-error {
    color: #dc3545;
    font-weight: 500;
    margin-top: 10px;
    font-size: 0.85em;
}

.draft-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #f3f4f6;
}
.draft-card-footer .button {
    margin: 0;
    padding: 6px 12px;
    font-size: 0.85em;
}
.draft-card-footer .button.delete-draft-btn {
    background-color: transparent;
    color: #dc3545;
    border: 1px solid #dc3545;
}
.draft-card-footer .button.delete-draft-btn:hover {
    background-color: #dc3545;
    color: #fff;
}

/* --- Medication Modal Two-Column Layout --- */

#medication-detail-modal-content + .modal-buttons {
    display: none; /* Hide the generic modal buttons */
}

#custom-modal-overlay .modal-content {
    /* Reset any specific widths when our custom content is injected */
    width: auto;
}

#medication-detail-modal-content {
    max-width: 850px; /* Make the modal wider for two columns */
    width: 100%;
    text-align: left;
}

#medication-detail-modal-content .detail-header {
     margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}

#medication-detail-modal-content .detail-header h4 {
    margin: 0;
    font-size: 1.4em;
    color: #111827;
}

.medication-modal-columns {
    display: flex;
    gap: 30px; /* Space between the two columns */
    width: 100%;
}

.medication-modal-left-column {
    flex: 1; /* Take up half the space */
    min-width: 300px;
    display: flex;
    flex-direction: column;
}

.medication-modal-right-column {
    flex: 1; /* Take up the other half */
    min-width: 300px;
    border-left: 1px solid #e5e7eb;
    padding-left: 30px;
    display: flex;
    flex-direction: column;
    max-height: 450px; /* Give the right column a fixed height */
}

#medication-history-list {
    flex-grow: 1; /* Allow the list to take up the available vertical space */
    margin-top: 0;
    overflow-y: auto; /* Enable vertical scrolling ONLY for this list */
    padding-right: 10px; /* Space for the scrollbar */
}

#medication-history-list .history-item {
    border: none;
    background-color: #f9fafb;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-size: 0.9em;
    box-shadow: none;
}

#medication-history-list .no-data-message {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

/* MODIFICATION START: Redesigned Submission Card Styles */
#submissions-list.submission-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    list-style: none;
    padding: 0;
}

.submission-card {
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    overflow: hidden; /* To contain the border-top color */
    position: relative;
    border-top: 5px solid; /* Placeholder for the color */
}

.submission-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Professional Color Scheme for Submission Cards */
.submission-card.type-birth {
    border-top-color: #28a745; /* CanTrace Green */
}
.submission-card.type-movement {
    border-top-color: #4b5563; /* Slate Gray */
}
.submission-card.type-disposal {
    border-top-color: #f59e0b; /* Amber */
}
.submission-card.type-generic {
    border-top-color: #6b7280; /* Medium Gray */
}

.submission-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 20px;
    border-bottom: 1px solid #f3f4f6;
}

.submission-card-header-text h5 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #111827;
}
.submission-card-header-text .date {
    font-size: 0.85em;
    color: #6b7280;
    margin-top: 4px;
    display: block;
}

.submission-card .draft-status-badge {
    position: absolute;
    top: 15px;
    right: 20px;
}

.submission-card-body {
    padding: 20px;
    font-size: 0.9em;
    display: grid;
    grid-template-columns: auto 1fr; /* Two-column layout for details */
    gap: 8px 15px;
    align-items: center;
}

.submission-card-body strong {
    font-weight: 500;
    color: #6b7280;
    text-align: right;
}

.submission-card-body span {
    font-weight: 500;
    color: #1f2937;
    word-break: break-all;
}

/* Submission Details Modal */
#submission-detail-modal .modal-content {
    max-width: 700px;
}
#detail-submission-tags-list-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    background-color: #f9fafb;
}

#detail-submission-tags-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
#detail-submission-tags-list li {
    padding: 5px;
    border-bottom: 1px solid #f3f4f6;
    font-family: 'Courier New', monospace;
}
#detail-submission-tags-list li:last-child {
    border-bottom: none;
}
/* MODIFICATION END */

/* --- MODIFICATION START: Styles for Retired & Disposed Form (2.50.0) --- */

#retired-disposed-section {
    max-width: 800px;
}

#retired-disposed-form {
    padding: 30px;
}

.event-type-selector {
    display: flex;
    gap: 30px;
    margin-bottom: 25px;
}

.event-type-selector .radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 20px; /* Increased padding */
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    flex-grow: 1;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.event-type-selector .radio-option:hover {
    background-color: #f9fafb;
}

.event-type-selector input[type="radio"] {
    margin: 0;
    width: 20px;
    height: 20px;
    accent-color: #28a745; /* CanTrace Green */
    flex-shrink: 0;
}

.event-type-selector label {
    font-weight: 500;
    color: #333;
    margin: 0; /* Override default margin */
    display: block;
}

.event-type-selector input[type="radio"]:checked + label {
    font-weight: 700;
    color: #28a745;
}

.event-type-selector input[type="radio"]:checked ~ .radio-option {
    border-color: #28a745;
    background-color: #e6ffe6;
}

/* Conditional Field Group Styles */
.conditional-group {
    border-left: 3px solid #f0f0f0;
    padding-left: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    display: none; /* Controlled by JS */
}

.conditional-group.active {
    display: block;
    border-left-color: #ffc107; /* Highlight active section */
}

.conditional-group h4 {
    font-size: 1.1em;
    font-weight: 600;
    color: #111827;
    margin-bottom: 15px;
}

.form-columns-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

/* Specific button style for the submission form */
#submit-retired-disposed-btn {
    margin-top: 30px;
    padding: 15px 30px;
    font-size: 1.1em;
    width: 100%;
}

/* --- MODIFICATION END: Styles for Retired & Disposed Form --- */

/* --- START: NEW KPI TILE STYLES (Record Summary Card Redesign) --- */

.kpi-tile-container {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    width: 100%;
    padding-top: 10px; /* Add some space below the card title */
}

.kpi-tile {
    flex: 1;
    min-width: 100px;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
    
    /* Elevated look */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); 
    border: 1px solid rgba(255, 255, 255, 0.5); /* Light border for contrast */
}

.kpi-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1); 
}

.kpi-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.kpi-icon-wrapper .dashicons {
    font-size: 20px;
    color: #ffffff;
}

.kpi-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.kpi-label {
    font-size: 0.85em;
    font-weight: 500;
    color: #4b5563; /* Subtle text color */
    margin: 0;
    padding-top: 5px;
}

.kpi-value {
    font-size: 2.5em; /* Large number for impact */
    font-weight: 800;
    margin: 0;
    line-height: 1;
}

/* --- Color Themes (Using Gradients and Contrast) --- */

/* 1. Records (Green/Emerald Theme) */
.kpi-tile-records {
    background: linear-gradient(145deg, #e6fff7, #d4fceb); /* Soft green gradient */
}
.kpi-tile-records .kpi-icon-wrapper {
    background-color: #28a745; /* CanTrace Green */
}
.kpi-tile-records .kpi-value {
    color: #218838; /* Darker green for value text */
}

/* 2. Animals (Blue/Cyan Theme) */
.kpi-tile-animals {
    background: linear-gradient(145deg, #e0f2ff, #c3e8ff); /* Soft blue gradient */
}
.kpi-tile-animals .kpi-icon-wrapper {
    background-color: #36a2eb; /* Vibrant Blue */
}
.kpi-tile-animals .kpi-value {
    color: #2581c3; /* Darker blue for value text */
}

/* 3. Images (Yellow/Orange Theme) */
.kpi-tile-images {
    background: linear-gradient(145deg, #fff7e0, #ffecb3); /* Soft yellow/orange gradient */
}
.kpi-tile-images .kpi-icon-wrapper {
    background-color: #ffcd56; /* Accent Yellow */
}
.kpi-tile-images .kpi-value {
    color: #e09900; /* Darker orange for value text */
}

/* --- END: NEW KPI TILE STYLES --- */

/* --- START: New Farm Activity Feed Styles --- */

#herd-events-card .records-list {
    margin: 0;
    width: 100%;
    padding: 0;
}

#herd-events-card .records-list li {
    border: none;
    box-shadow: none;
    background: none;
    padding: 0;
    margin: 0;
}

.activity-feed-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

#herd-events-list .activity-feed-item:last-child {
    border-bottom: none;
}

.activity-icon-wrapper {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* Icon Background Colors */
.activity-icon-wrapper.event-birth { background-color: #28a745; } /* Green */
.activity-icon-wrapper.event-movement { background-color: #4b5563; } /* Slate */
.activity-icon-wrapper.event-health { background-color: #ffc107; } /* Yellow */
.activity-icon-wrapper.event-medication { background-color: #dc3545; } /* Red */
.activity-icon-wrapper.event-image { background-color: #17a2b8; } /* Teal */
.activity-icon-wrapper.event-general { background-color: #6c757d; } /* Grey */

.activity-icon-wrapper .dashicons {
    font-size: 22px;
}

.activity-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.activity-title {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95em;
}

.activity-description {
    font-size: 0.85em;
    color: #6b7280;
}

.activity-timestamp {
    flex-shrink: 0;
    font-size: 0.8em;
    color: #9ca3af;
    align-self: flex-start;
}

/* --- END: New Farm Activity Feed Styles --- */


/* --- MODIFICATION START: New Styles for "Clients" Page --- */

#clients-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

.client-card {
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
}

.client-card.is-expanded {
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.client-card-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
}
.client-card.is-expanded .client-card-header {
    border-bottom: 1px solid #e5e7eb;
}

.client-info .client-name {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
    color: #111827;
}
.client-info .client-pid {
    margin: 4px 0 0 0;
    font-size: 0.9em;
    color: #6b7280;
    font-family: 'Courier New', Courier, monospace;
}

.client-expand-icon .dashicons {
    font-size: 24px;
    color: #9ca3af;
    transition: transform 0.2s ease;
}
.client-card.is-expanded .client-expand-icon .dashicons {
    transform: rotate(180deg);
}

.client-card-details {
    padding: 20px;
    background-color: #f9fafb;
    border-top: 1px solid #f3f4f6;
}

.details-loader {
    text-align: center;
    padding: 20px;
    color: #6b7280;
    font-weight: 500;
}
.details-loader .loading-spinner {
    margin: 0 auto 10px auto;
}

.client-details-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.client-detail-item {
    font-size: 0.9em;
}

.client-detail-item strong {
    display: block;
    color: #6b7280;
    font-weight: 500;
    margin-bottom: 4px;
}
.client-detail-item span {
    color: #1f2937;
    font-weight: 500;
    word-break: break-word;
}

.client-card-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
}

.revoke-client-access-btn {
    background-color: #ef4444;
    border-color: #ef4444;
    margin: 0; /* Remove default margin */
}
.revoke-client-access-btn:hover {
    background-color: #dc2626;
}
.revoke-client-access-btn .dashicons {
    margin-right: 6px;
}

/* --- MODIFICATION END: New "Clients" Page Styles --- */

/* --- NEW: DataTables Styling for All Records Grid --- */
#all-records-table {
    width: 100% !important; /* Force width */
}

/* Header Styling */
#all-records-table thead th {
    background-color: #28a745;
    color: #ffffff;
    font-weight: 600;
    padding: 12px 15px;
    border-bottom: none;
    text-align: left;
}

/* Row Styling */
#all-records-table tbody tr {
    transition: background-color 0.2s ease;
}
#all-records-table tbody tr:hover {
    background-color: #f3f9f3 !important; /* Subtle green highlight on hover */
}
#all-records-table tbody td {
    padding: 12px 15px;
    vertical-align: middle;
    color: #4b5563;
    border-bottom: 1px solid #f3f4f6;
}

/* Record Type Badges */
.record-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    line-height: 1;
    gap: 5px;
    min-width: 80px;
    justify-content: center;
}
.record-type-badge .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Badge Colors */
.badge-health { background-color: #e6fffa; color: #0d9488; border: 1px solid #ccfbf1; } /* Teal */
.badge-medication { background-color: #fee2e2; color: #dc2626; border: 1px solid #fecaca; } /* Red */
.badge-movement { background-color: #eff6ff; color: #2563eb; border: 1px solid #dbeafe; } /* Blue */
.badge-image { background-color: #f3e8ff; color: #9333ea; border: 1px solid #e9d5ff; } /* Purple */
.badge-clts { background-color: #fff7ed; color: #ea580c; border: 1px solid #ffedd5; } /* Orange */
.badge-generic { background-color: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; } /* Grey */

/* Table Button */
.view-record-details-btn {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* Link Style */
a.animal-card {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}
a.animal-card:hover {
    text-decoration: underline;
}