/* public/css/style.css */

/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Noto+Sans+Arabic:wght@400;600;700&display=swap');

/* Define Color Palette using CSS Variables */
:root {
    --primary-color: #4CAF50;
    /* A fresh green, representing nature/growth */
    --primary-dark: #388E3C;
    /* Darker green */
    --primary-light: #81C784;
    /* Lighter green */
    --secondary-color: #FFC107;
    /* A warm yellow/orange, representing sun/energy */
    --secondary-dark: #FFA000;
    /* Darker yellow/orange */
    --text-dark: #333333;
    /* Dark gray for main text */
    --text-light: #ffffff;
    /* White for light text */
    --bg-light: #f8f9fa;
    /* Light background for body */
    --bg-card: #ffffff;
    /* White background for cards/sections */
    --border-color: #e0e0e0;
    /* Light gray for borders */
    --success-color: #28a745;
    /* Bootstrap success green */
    --error-color: #dc3545;
    /* Bootstrap danger red */
    --info-color: #17a2b8;
    /* Bootstrap info blue */
    --warning-color: #ffc107;
    /* Bootstrap warning yellow */
    --dark-section-bg: #343a40;
    /* Dark background for some headers */
}

/* Base Body Styling - rely on Bootstrap classes for layout/centering */
/* ONLY apply font, colors, and RTL here */
body {
    font-family: 'Cairo', Tahoma, sans-serif;
    /* Apply Cairo as main font */
    background-color: var(--bg-light);
    direction: rtl;
    /* For Arabic */
    text-align: right;
    /* For Arabic */
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* REMOVED: display: flex, justify-content, align-items, min-height, height: 100% */
    /* These will be applied via Bootstrap classes directly on <body> in PHP files like <body class="d-flex flex-column min-vh-100 bg-light"> */
}

/* Ensure html and body take full height for Bootstrap's min-vh-100 to work */
html {
    height: 100%;
    /* Important for vh units */
}

/* Specific font for printed receipts */
.print-receipt-font {
    font-family: Tahoma, Arial, sans-serif !important;
}

/* General Container Styling - will use Bootstrap classes in HTML */
/* All these elements will also have Bootstrap's .card, .shadow, .rounded classes */
.dashboard-container,
.settings-container,
.employees-container,
.accounts-container,
.transactions-container,
.livestock-container,
.products-container,
.horses-container,
.users-container,
.general-management-container,
.login-container {
    background-color: var(--bg-card);
    padding: 30px;
    /* Default padding for all main containers */
    border-radius: 12px;
    /* Consistent border-radius */
    box-sizing: border-box;
    /* Include padding and border in sizing */
}

/* Login Page Specific Styling - ensure it's centered and sized correctly via Bootstrap classes in index.php */
.login-container {
    max-width: 450px;
    /* Still apply a max-width for login form */
    width: 90%;
    /* Responsive width */
    text-align: center;
    /* Center content within login box */
}


/* Headings - basic styling and font */
h1,
h2,
h3 {
    font-family: 'Cairo', Tahoma, sans-serif;
    /* Apply Cairo explicitly */
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 30px;
    font-weight: 700;
}

h1 {
    font-size: 2.8em;
}

h2 {
    font-size: 2.2em;
}

h3 {
    font-size: 1.6em;
}

/* Paragraphs */
p {
    color: var(--text-dark);
    /* Ensure custom text color */
    margin-bottom: 15px;
    line-height: 1.8;
}

/* Messages (Success/Error/Warning) - complement Bootstrap .alert classes */
.message {
    /* These will be applied with .alert .message .error/success/info/warning */
    font-weight: 600;
    text-align: center;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Main Dashboard Navigation - rely on Bootstrap classes like d-flex, gap-3, etc. */
.main-nav ul {
    list-style: none;
    padding: 0;
    margin: 40px 0;
    /* Add margin here for spacing */
    /* flex properties are from Bootstrap d-flex, flex-wrap, justify-content-center */
}

.main-nav li {
    background-color: var(--primary-light);
    border-radius: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    /* flex sizing properties from Bootstrap like flex-fill, min-width, max-width */
}

.main-nav li:hover {
    background-color: var(--primary-dark);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    transform: translateY(-5px);
}

.main-nav a {
    display: block;
    padding: 20px 25px;
    text-decoration: none;
    color: var(--text-light) !important;
    /* Force white text over Bootstrap */
    font-weight: 600;
    font-size: 1.2em;
    white-space: nowrap;
    text-align: center;
    font-family: 'Cairo', Tahoma, sans-serif;
}

/* Form Sections */
.form-section {
    background-color: var(--bg-light);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 5px rgba(0, 0, 0, 0.05);
}

.form-section h2 {
    color: var(--primary-dark);
    font-family: 'Cairo', Tahoma, sans-serif;
}

/* Form Controls (.form-control class) */
.form-control {
    font-family: 'Cairo', Tahoma, sans-serif;
    /* Apply Cairo explicitly */
    direction: rtl;
    /* For Arabic */
    text-align: right;
    /* For Arabic */
    font-size: 1em;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    /* Ensure our border color is used */
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(76, 175, 80, 0.25);
    outline: none;
}

input[type="file"].form-control {
    padding: 8px;
}

/* Buttons (.btn class) */
.btn {
    font-family: 'Cairo', Tahoma, sans-serif;
    padding: 12px 30px;
    font-size: 1.2em;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    display: inline-block;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--text-light);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: var(--text-light);
}

.btn-secondary:hover {
    background-color: #5a6268;
    border-color: #5a6268;
}

/* Data Tables - rely on Bootstrap .table classes (e.g., .table, .table-striped, .table-hover, .table-bordered) */
.table {
    /* Base Bootstrap table class */
    border-radius: 10px;
    overflow: hidden;
    /* Ensures rounded corners */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background-color: var(--bg-card);
}

.table thead th {
    font-family: 'Cairo', Tahoma, sans-serif;
    background-color: var(--primary-color);
    color: var(--text-light);
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
    padding: 18px 15px;
}

.table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.table tbody tr:hover {
    background-color: #e0e0e0;
}

.table tfoot td {
    font-weight: 700;
    background-color: var(--bg-light);
    border-top: 2px solid var(--primary-dark);
}

/* No explicit .data-table custom class now, rely on .table now */


/* Action Buttons in tables (Edit/Delete) - will use Bootstrap .btn, .btn-sm etc. directly in HTML */
.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}


/* Specific Section Header Colors - override Bootstrap's default .table thead th */
.employees-container .form-section h2,
.employees-container .table thead th {
    background-color: #28a745;
    color: var(--text-light);
}

.accounts-container .form-section h2,
.accounts-container .table thead th {
    background-color: #17a2b8;
    color: var(--text-light);
}

.transactions-container .form-section h2,
.transactions-container .table thead th {
    background-color: #6c757d;
    color: var(--text-light);
}

.livestock-container .form-section h2,
.livestock-container .table thead th {
    background-color: #fd7e14;
    color: var(--text-light);
}

.products-container .form-section h2,
.products-container .table thead th {
    background-color: #6610f2;
    color: var(--text-light);
}

.horses-container .form-section h2,
.horses-container .table thead th {
    background-color: #6f42c1;
    color: var(--text-light);
}

.users-container .form-section h2,
.users-container .table thead th {
    background-color: #343a40;
    color: var(--text-light);
}

.general-management-container .form-section h2,
.general-management-container .table thead th {
    background-color: #20c997;
    color: var(--text-light);
}


/* Dashboard Specific */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 30px;
    margin-bottom: 40px;
    justify-content: center;
}

.stat-card {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    text-align: center;
    border-bottom: 5px solid;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-7px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.stat-card h3 {
    font-family: 'Cairo', Tahoma, sans-serif;
    color: var(--primary-dark);
    font-size: 1.2em;
    margin-top: 0;
    margin-bottom: 12px;
    font-weight: bold;
}

.stat-card .stat-value {
    font-family: 'Cairo', Tahoma, sans-serif;
    font-size: 2.5em;
    font-weight: bolder;
    color: var(--text-dark);
    margin: 0;
}

/* Color coding for stat cards */
.stat-card.finance-card {
    border-color: var(--info-color);
}

.stat-card.animals-card {
    border-color: var(--primary-color);
}

.stat-card.products-card {
    border-color: var(--secondary-color);
}

.dashboard-sections-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
}

.dashboard-section {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    flex: 1;
    min-width: 400px;
    max-width: calc(50% - 15px);
}

@media (max-width: 992px) {
    .dashboard-section {
        max-width: 100%;
    }
}

.chart-section {
    position: relative;
    height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#monthlyNetIncomeChart {
    max-height: 350px;
    width: 100% !important;
    height: auto !important;
}

.list-section h3 {
    font-family: 'Cairo', Tahoma, sans-serif;
    color: var(--primary-dark);
    border-bottom: 2px solid var(--border-color);
}

.account-balances-list li span,
.top-expenses-list li span {
    color: var(--primary-color);
}


/* Tabbed Interface Styles */
.tabs {
    border-bottom: 1px solid var(--border-color);
}

.tab-button {
    font-family: 'Cairo', Tahoma, sans-serif;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.tab-button:hover {
    background-color: var(--border-color);
    color: var(--primary-dark);
}

.tab-button.active {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    border-bottom-color: transparent;
    color: var(--primary-color);
}

.tab-content {
    border-top: 1px solid var(--border-color);
}


/* Utility Classes */
.hidden-field {
    display: none;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .main-nav ul {
        gap: 10px;
    }

    .main-nav li {
        flex-basis: calc(50% - 10px);
        max-width: unset;
    }

    .main-nav a {
        font-size: 1em;
        padding: 15px 10px;
    }

    .table th,
    .table td {
        padding: 10px;
        font-size: 0.9em;
    }

    .action-buttons {
        flex-direction: column;
        gap: 5px;
    }

    .action-buttons button,
    .action-buttons a {
        width: 100%;
        padding: 6px;
    }

    .form-control,
    .btn {
        font-size: 0.9em;
        padding: 10px;
    }

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.6em;
    }

    h3 {
        font-size: 1.2em;
    }
}

@media (max-width: 480px) {

    .dashboard-container,
    .settings-container,
    .employees-container,
    .accounts-container,
    .transactions-container,
    .livestock-container,
    .products-container,
    .horses-container,
    .users-container,
    .general-management-container,
    .login-container {
        padding: 20px;
        margin: 20px auto;
        border-radius: 10px;
    }

    .main-nav li {
        max-width: 100%;
    }

    .login-container {
        padding: 30px;
    }

    .stat-card h3 {
        font-size: 1em;
    }

    .stat-card .stat-value {
        font-size: 2em;
    }
}