/* Custom Styles for Nutri Smart Farm Integrated */

/* General Body and Font Styles */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f4f8; /* Light blue-gray background */
    color: #334155; /* Slate 700 */
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

/* Custom Tailwind Colors (if not directly configured in tailwind.config.js) */
.bg-primary-orange { background-color: #f97316; } /* Orange 500 */
.text-primary-orange { color: #f97316; } /* Orange 500 */
.bg-primary-blue { background-color: #3b82f6; } /* Blue 500 */
.text-primary-blue { color: #3b82f6; } /* Blue 500 */
.hover\:bg-primary-blue-dark:hover { background-color: #2563eb; } /* Blue 600 */


/* Main Layout */
.dashboard-container {
    display: flex;
    flex-direction: column; /* Stack vertically on small screens */
    min-height: 100vh;
}

@media (min-width: 768px) {
    .dashboard-container {
        flex-direction: row; /* Side-by-side on medium and larger screens */
    }
}

/* Sidebar Styling */
.sidebar {
    background-color: #ffffff;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 10; /* Ensure sidebar is above content for mobile toggle */
}

@media (min-width: 768px) {
    .sidebar {
        width: 280px;
        min-width: 280px; /* Fixed width sidebar on desktop */
        height: 100vh;
        position: sticky;
        top: 0;
        overflow-y: auto;
    }
}

/* Tab Links in Sidebar */
.tab-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem; /* Rounded-xl */
    font-weight: 500; /* Medium font */
    color: #4b5563; /* Gray 600 */
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.tab-link:hover {
    background-color: #e0e7ff; /* Indigo 100 */
    color: #3b82f6; /* Blue 500 */
}

.tab-link.tab-active {
    background-color: #3b82f6; /* Primary Blue */
    color: #ffffff;
    font-weight: 600; /* Semibold */
}

.tab-link.tab-active svg {
    color: #ffffff; /* Ensure icon color matches active state */
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 1.5rem;
    background-color: #f0f4f8; /* Light blue-gray background */
}

/* Content Sections (Tabs) */
.content-section {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.content-section.active {
    display: block;
}

/* Fade-in Animation for Content */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Card Styles (used universally) */
.card {
    background-color: #ffffff;
    padding: 1.5rem;
    border-radius: 1.5rem; /* Rounded-2xl */
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

/* Table Styling */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1.5rem; /* px-6 py-4 */
    text-align: left;
}

thead th {
    background-color: #f9fafb; /* Gray 50 */
    font-size: 0.75rem; /* text-xs */
    text-transform: uppercase;
    color: #4b5563; /* Gray 600 */
}

tbody tr {
    background-color: #ffffff;
    border-bottom: 1px solid #e5e7eb; /* Gray 200 */
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background-color: #f9fafb; /* Gray 50 */
}

/* Form Elements General Styling */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
select,
textarea {
    border: 1px solid #d1d5db; /* Gray 300 */
    border-radius: 0.75rem; /* Rounded-lg */
    padding: 0.5rem 0.75rem; /* py-2 px-3 */
    font-size: 0.875rem; /* text-sm */
    width: 100%;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    background-color: #ffffff;
    color: #334155;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3b82f6; /* Primary blue on focus */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); /* Ring effect */
}

/* Button Styling (General) */
.btn {
    padding: 0.625rem 1.25rem; /* py-2.5 px-5 */
    border-radius: 0.75rem; /* rounded-xl */
    font-weight: 600; /* Semibold */
    transition: background-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-primary {
    background-color: #3b82f6; /* Primary Blue */
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #2563eb; /* Blue 600 */
}

.btn-secondary {
    background-color: #e2e8f0; /* Gray 200 */
    color: #4b5563; /* Gray 600 */
}

.btn-secondary:hover {
    background-color: #cbd5e1; /* Gray 300 */
}

.btn-danger {
    background-color: #ef4444; /* Red 500 */
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626; /* Red 600 */
}

/* Modal Specific Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* On top of everything */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: #ffffff;
    padding: 2rem;
    border-radius: 1.5rem; /* rounded-2xl */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    max-width: 90%;
    max-height: 90vh; /* Max height to allow scrolling if content is long */
    overflow-y: auto; /* Enable scrolling for modal content */
    transform: translateY(20px);
    transition: transform 0.3s ease-in-out;
}

.modal.open .modal-content {
    transform: translateY(0);
}

/* Specific Modal Button Styling */
.modal-buttons button {
    margin-left: 0.75rem; /* gap-3 equivalent */
}

/* Dashboard Specifics */
.repro-summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem; /* gap-6 */
}

@media (min-width: 768px) {
    .repro-summary-grid {
        grid-template-columns: 2fr 1fr 1fr;
    }
}

/* Dashboard Chart Container */
.relative.h-64 { /* For dashboard charts */
    height: 16rem; /* 256px */
}
.relative.h-40 { /* For health monitor chart */
    height: 10rem; /* 160px */
}
.relative.h-72 { /* For ADG/FCR chart on dashboard */
    height: 18rem; /* 288px */
}


/* Kalkulator Tab Specifics */
.komposisi-header {
    background-color: #f3f4f6; /* Gray 100 */
    padding: 0.75rem 1rem;
    border-radius: 0.75rem; /* rounded-lg */
    font-weight: 600;
    color: #4b5563; /* Gray 600 */
}

.bahan-pakan-row {
    margin-bottom: 0.5rem; /* Space between rows */
}

/* Ensure price display is styled */
.harga-display {
    display: flex; /* Use flex to align content if needed */
    align-items: center;
    justify-content: flex-end; /* Align to right */
    padding-right: 0.5rem; /* Add some padding */
    color: #6b7280; /* Gray 500 */
}

/* Add a margin to the first button in a group if it follows a non-button element */
.grid.grid-cols-2.gap-4 button:first-child {
    margin-left: 0; /* Override default gap */
}

/* Manajemen Kandang Specifics */
.kandang-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem; /* gap-6 */
}

.kandang-card {
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.kandang-card.selected {
    border-color: #3b82f6; /* Primary blue border when selected */
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2); /* Blue ring when selected */
}

/* Prediksi Reproduksi Specifics (New Feature Styling) */
.action-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.action-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Tindakan Tab Specifics */
.tindakan-table-container {
    overflow-x: auto; /* Enable horizontal scrolling for tables on small screens */
}

/* Notification History Modal */
#notifikasiRiwayatContent {
    max-height: 70vh; /* Allow scrolling for many notifications */
    overflow-y: auto;
    padding-right: 0.5rem; /* Space for scrollbar */
}

#notifikasiRiwayatContent::-webkit-scrollbar {
    width: 8px;
}

#notifikasiRiwayatContent::-webkit-scrollbar-thumb {
    background-color: #cbd5e1; /* Gray 300 */
    border-radius: 4px;
}

#notifikasiRiwayatContent::-webkit-scrollbar-track {
    background-color: #f1f5f9; /* Gray 100 */
}

/* Utility to hide elements during export (html2canvas) */
.export-hidden {
    display: none !important;
}

/* Ensure Chart.js canvas elements are responsive within their containers */
canvas {
    max-width: 100%;
    height: auto;
}

/* Override default focus outlines for better consistency with custom styles */
*:focus {
    outline: none;
}

/* Custom styling for the alert modal buttons to match alert design */
#customAlertButtons button {
    min-width: 100px; /* Give buttons a consistent minimum width */
    margin-left: 0.5rem; /* Adjust margin between buttons */
    margin-right: 0.5rem; /* Adjust margin between buttons */
}
#customAlertButtons button:first-child {
    margin-left: 0;
}
#customAlertButtons button:last-child {
    margin-right: 0;
}

/* Specific styling for the header elements for better alignment and visibility */
header.bg-white {
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    z-index: 50; /* Ensure header is above content but below modals */
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px; /* Max width for the content inside header */
    margin: 0 auto; /* Center the content */
}

.logo-text {
    font-size: 1.25rem; /* text-xl */
    font-weight: 700; /* font-bold */
    color: #3b82f6; /* Primary blue */
}

/* Style for select dropdowns in the header */
#customerProfileSelect {
    appearance: none; /* Remove default arrow */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='currentColor'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.5em;
    padding-right: 2.5rem; /* Make space for the custom arrow */
    cursor: pointer;
}

/* Styling for the mobile menu toggle button */
.md\:hidden.flex.items-center.justify-between {
    padding: 1rem; /* Adjust padding for button area */
}

/* Mobile sidebar visibility */
.sidebar-mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none; /* Hidden by default */
}

.sidebar-mobile-overlay.open {
    display: block; /* Show when open */
}

.sidebar.mobile-open {
    transform: translateX(0%);
}

.sidebar.mobile-closed {
    transform: translateX(-100%);
}

@media (max-width: 767px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 250px; /* Fixed width for mobile sidebar */
        transition: transform 0.3s ease-in-out;
    }
}

/* Silsilah Tree Styling (New Comprehensive Version) */

.pedigree-chart {
    display: flex;
    flex-direction: column; /* Stack sections vertically */
    align-items: center;
    width: 100%;
    overflow-x: auto; /* Allow horizontal scrolling for wide trees */
    padding: 20px 0;
    background-color: #ffffff; /* Clean white background for the chart area */
    border-radius: 0.75rem; /* Slightly less rounded */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); /* Softer shadow */
    transform-origin: top center;
    transition: transform 0.3s ease-in-out; /* Smooth zoom transition */
}

.pedigree-section {
    margin-bottom: 25px; /* Reduced margin */
    padding: 10px;
    width: 100%;
    text-align: center;
}

.pedigree-section h3 {
    color: #334155;
    margin-bottom: 10px; /* Reduced margin */
    font-size: 1.125rem; /* text-lg */
    font-weight: 600; /* Semibold */
}

.root-animal-section {
    margin-bottom: 40px; /* Adjusted space around the central animal */
}

.pedigree-ancestors-container,
.pedigree-descendants-container {
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align nodes to the top */
    position: relative;
    padding: 15px 0; /* Reduced padding */
}

/* Base Node Styling */
.pedigree-node {
    display: inline-block;
    vertical-align: top;
    text-align: center;
    position: relative;
    padding: 8px; /* Reduced padding */
    min-width: 110px; /* Slightly smaller min-width */
    max-width: 160px; /* Slightly smaller max-width */
    margin: 8px 15px; /* Reduced margin between nodes */

    transition: none; /* Keep instant appearance */
    opacity: 1; /* Ensure nodes are always visible */
    transform: translateY(0); /* Ensure nodes are in their default position */
}

.pedigree-node .node-content {
    border: 1px solid #e2e8f0; /* Lighter border (gray-200) */
    padding: 6px 10px; /* Reduced padding */
    border-radius: 0.5rem; /* Slightly less rounded */
    background-color: #ffffff;
    box-shadow: none; /* Remove individual node shadow for cleaner look */
    position: relative;
    z-index: 10; /* Ensure content is above lines */
    font-size: 0.875rem; /* text-sm */
    color: #334155;
}

/* Node specific shapes and colors */
.pedigree-node.root-node .node-content {
    width: 100px; /* Fixed size for circle */
    height: 100px; /* Fixed size for circle */
    border-radius: 50%; /* Circle shape */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Hide overflow for image */
    border-color: #3b82f6; /* Primary blue border */
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.pedigree-node.parent-node .node-content { /* Direct parents */
    width: 80px; /* Fixed size for circle */
    height: 80px; /* Fixed size for circle */
    border-radius: 50%; /* Circle shape */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pedigree-node.grandparent-node .node-content, /* Grandparents and further */
.pedigree-node.descendant-node .node-content { /* All descendants */
    border-radius: 0.5rem; /* Rounded square */
    width: auto; /* Auto width */
    height: auto; /* Auto height */
    padding: 6px 10px;
}


/* Avatars/Images within nodes */
.pedigree-node .node-avatar {
    width: 60px; /* Size for avatar */
    height: 60px; /* Size for avatar */
    border-radius: 50%;
    background-color: #e2e8f0; /* Placeholder background */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem; /* Icon size */
    color: #94a3b8; /* Icon color */
    margin-bottom: 5px;
    overflow: hidden;
}

.pedigree-node.root-node .node-avatar {
    width: 70px;
    height: 70px;
}

/* Specific node colors based on gender */
.pedigree-node.male .node-content { border-color: #93c5fd; } /* blue-300 */
.pedigree-node.female .node-content { border-color: #fbcfe8; } /* pink-200 */

.pedigree-node.placeholder .node-content {
    border-style: dashed;
    background-color: #f8fafc; /* Lighter background for placeholder */
    color: #94a3b8; /* slate-400 */
    height: 70px; /* Adjusted height */
    display: flex;
    flex-direction: column; /* Allow content to stack */
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-radius: 0.5rem; /* Ensure placeholder is also rounded square by default */
}
.pedigree-node.placeholder .node-content::before {
    content: 'Data Tidak Ada';
    margin-bottom: 5px;
}
.pedigree-node.placeholder .node-avatar {
    display: none; /* Hide avatar for placeholders */
}


/* Line Styles (Simplified and Unified) */
/* Common line properties */
.pedigree-chart .line-vertical,
.pedigree-chart .line-horizontal {
    background-color: #6b7280; /* Darker gray for ancestor lines */
    position: absolute;
    z-index: 5;
}

/* Ancestor lines */
.pedigree-ancestors-container .line-vertical { background-color: #6b7280; }
.pedigree-ancestors-container .line-horizontal { background-color: #6b7280; }

/* Descendant lines (black) */
.pedigree-descendants-container .line-vertical { background-color: #000000; }
.pedigree-descendants-container .line-horizontal { background-color: #000000; }


/* Vertical lines from node to horizontal connector */
.pedigree-node.has-parent-line::before { /* For nodes that have parents */
    content: '';
    position: absolute;
    top: -15px; /* Position above the node */
    left: 50%;
    width: 2px;
    height: 15px;
    background-color: inherit; /* Inherit color from ancestor/descendant context */
    transform: translateX(-50%);
    z-index: 5;
}

.pedigree-node.has-child-line::after { /* For nodes that have children */
    content: '';
    position: absolute;
    bottom: -15px; /* Position below the node */
    left: 50%;
    width: 2px;
    height: 15px;
    background-color: inherit; /* Inherit color from ancestor/descendant context */
    transform: translateX(-50%);
    z-index: 5;
}


/* Connecting the root animal to its parents */
.root-animal-section .pedigree-node.has-parent-line::before {
    background-color: #6b7280; /* Ancestor line color */
}

/* Connecting the root animal to its children */
.root-animal-section .pedigree-node.has-child-line::after {
    background-color: #000000; /* Descendant line color */
}


/* Horizontal lines for generations (ancestors) */
.pedigree-ancestors-container .pedigree-generation {
    display: flex;
    justify-content: center;
    position: relative;
    padding-top: 30px; /* Space for lines above */
}

.pedigree-ancestors-container .pedigree-generation .pedigree-node {
    margin-top: 30px; /* Push nodes down */
}

/* Horizontal line between parents (siblings of the same child) */
.pedigree-ancestors-container .pedigree-generation .pedigree-node:first-child:nth-last-child(2) ~ .pedigree-node:last-child::before {
    /* This targets the second node if there are exactly two, to draw the horizontal line */
    content: '';
    position: absolute;
    top: 15px; /* Vertical position of the horizontal line */
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #6b7280;
    z-index: 4;
}

/* Vertical line from horizontal line to parent node */
.pedigree-ancestors-container .pedigree-generation .pedigree-node::after { /* Using ::after for the vertical line from horizontal */
    content: '';
    position: absolute;
    top: 0; /* Starts from the top of the node's container */
    left: 50%;
    width: 2px;
    height: 15px; /* Connects to the horizontal line */
    background-color: #6b7280;
    transform: translateX(-50%);
    z-index: 5;
}


/* Horizontal lines for generations (descendants) */
.pedigree-descendants-container .pedigree-generation {
    display: flex;
    justify-content: center;
    position: relative;
    padding-bottom: 30px; /* Space for lines below */
}

.pedigree-descendants-container .pedigree-generation .pedigree-node {
    margin-bottom: 30px; /* Push nodes up */
}

/* Horizontal line between children (siblings) */
.pedigree-descendants-container .pedigree-generation .pedigree-node:first-child:nth-last-child(2) ~ .pedigree-node:last-child::before {
    /* This targets the second node if there are exactly two, to draw the horizontal line */
    content: '';
    position: absolute;
    bottom: 15px; /* Vertical position of the horizontal line */
    left: 0;
    width: 100%;
    height: 2px;
    background-color: #000000; /* Black line */
    z-index: 4;
}

/* Vertical line from horizontal line to child node */
.pedigree-descendants-container .pedigree-generation .pedigree-node::before { /* Using ::before for the vertical line from horizontal */
    content: '';
    position: absolute;
    bottom: 0; /* Starts from the bottom of the node's container */
    left: 50%;
    width: 2px;
    height: 15px; /* Connects to the horizontal line */
    background-color: #000000;
    transform: translateX(-50%);
    z-index: 5;
}

/* Clear existing tree styles if they conflict */
.tree, .tree ul, .tree li {
    all: unset; /* Reset all styles for the old tree structure */
}
