/* Clean White + Dry Green Professional Cattle System */
/* Color Palette:
   - Background: #FFFFFF (white)
   - Primary Text: #1B4332 (dark dry green)
   - Active Buttons: #2D6A4F (medium green)
   - Hover State: #40916C (accent green)
   - Card Background: #F9F9F9 (light gray)
   - Borders: #DAD7CD (soft beige)
*/

:root {
    --primary-color: #1B4332;
    --secondary-color: #2D6A4F;
    --accent-color: #40916C;
    --success-color: #52B788;
    --warning-color: #F77F00;
    --danger-color: #D62828;
    --background-color: #FFFFFF;
    --card-background: #F9F9F9;
    --text-color: #1B4332;
    --text-muted: #6C757D;
    --border-color: #DAD7CD;
    --hover-color: #40916C;
}

/* Global Styles */
body {
    font-family: 'Roboto', 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Top Header Styles */
.top-header {
    background-color: var(--primary-color);
    padding: 0.75rem 0;
    box-shadow: 0 2px 10px rgba(27, 67, 50, 0.2);
    z-index: 1040;
    height: 60px;
}

.top-header .navbar-brand {
    font-size: 1.3rem;
    font-weight: bold;
    color: white !important;
    text-decoration: none;
}

.top-header .cattle-icon {
    color: var(--success-color);
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 280px;
    height: calc(100vh - 60px);
    background-color: var(--card-background);
    border-right: 2px solid var(--border-color);
    overflow-y: auto;
    z-index: 1030;
    transition: all 0.3s ease;
    box-shadow: 2px 0 10px rgba(27, 67, 50, 0.1);
}

.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: white;
}

.sidebar-header h5 {
    color: var(--primary-color);
    margin: 0;
    font-weight: 600;
    font-size: 1.1rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-item {
    margin: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    position: relative;
}

.sidebar-link:hover {
    background-color: rgba(27, 67, 50, 0.08);
    color: var(--accent-color);
    text-decoration: none;
    border-left-color: var(--accent-color);
    transform: translateX(4px);
}

.sidebar-link.active {
    background-color: rgba(27, 67, 50, 0.12);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.sidebar-link i {
    width: 20px;
    margin-right: 0.75rem;
    text-align: center;
    font-size: 1rem;
}

.sidebar-link span {
    flex: 1;
}

/* Submenu Styles */
.submenu-arrow {
    margin-left: auto;
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    opacity: 0.6;
}

.submenu-arrow.rotated {
    transform: rotate(90deg);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    background-color: rgba(27, 67, 50, 0.03);
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 0;
}

.submenu.show {
    max-height: 500px;
    padding: 0.5rem 0;
}

.submenu li {
    list-style: none;
}

.submenu a {
    display: block;
    padding: 0.625rem 1.25rem 0.625rem 3.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 400;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.submenu a:hover {
    background-color: rgba(27, 67, 50, 0.08);
    color: var(--accent-color);
    text-decoration: none;
    border-left-color: var(--accent-color);
    transform: translateX(4px);
}

.submenu a.active {
    background-color: rgba(27, 67, 50, 0.12);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.submenu-header {
    padding: 0.5rem 1.25rem 0.25rem 3.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.submenu-divider {
    margin: 0.5rem 1.25rem 0.5rem 3.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Main Content Adjustment */
.main-content {
    margin-left: 280px;
    padding-top: 60px;
    min-height: calc(100vh - 60px);
    transition: margin-left 0.3s ease;
}

.content-wrapper {
    padding: 2rem 1rem 1rem;
}

/* Mobile Sidebar */
.offcanvas .sidebar-nav {
    padding: 1rem 0;
}

.offcanvas .sidebar-link {
    padding: 1rem 1.5rem;
}

.offcanvas .submenu a {
    padding: 0.75rem 1.5rem 0.75rem 4rem;
}

.offcanvas .submenu-header {
    padding: 0.5rem 1.5rem 0.25rem 4rem;
}

.offcanvas .submenu-divider {
    margin: 0.5rem 1.5rem 0.5rem 4rem;
}

/* Responsive Design */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .content-wrapper {
        padding: 1rem 0.75rem;
    }
}

/* Mobile Menu Button Enhancement */
.mobile-menu-btn {
    background-color: rgba(255,255,255,0.15) !important;
    color: white !important;
    border: 1.5px solid rgba(255,255,255,0.4) !important;
    border-radius: 10px !important;
    padding: 8px 12px !important;
    transition: all 0.2s ease !important;
    backdrop-filter: blur(4px);
}

.mobile-menu-btn:hover,
.mobile-menu-btn:active {
    background-color: rgba(255,255,255,0.25) !important;
    color: white !important;
    transform: scale(0.96);
}

/* ========== MOBILE APP-LIKE EXPERIENCE ========== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed !important;
        z-index: 1050 !important;
        width: 280px !important;
        top: 56px !important;
        left: 0 !important;
        height: calc(100vh - 56px) !important;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding-bottom: 80px;
        padding-top: 56px;
    }

    .content-wrapper {
        padding: 0.75rem 0.5rem 1rem;
    }

    .top-header {
        height: 56px;
        padding: 0.5rem 0 !important;
    }

    .top-header .navbar-brand {
        font-size: 0.95rem;
        letter-spacing: -0.3px;
    }

    .top-header .navbar-brand i {
        font-size: 1rem;
    }

    h1 {
        font-size: 1.3rem !important;
    }

    h5 {
        font-size: 1rem !important;
    }

    .card {
        border-radius: 12px !important;
        overflow: hidden;
    }

    .card-body {
        padding: 0.875rem !important;
    }

    .card-header {
        padding: 0.75rem 0.875rem !important;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        min-height: 44px;
        border-radius: 10px !important;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.15s ease;
    }

    .btn:active {
        transform: scale(0.97);
        opacity: 0.85;
    }

    .btn-sm {
        min-height: 38px;
        padding: 0.375rem 0.625rem;
        font-size: 0.8rem;
        border-radius: 8px !important;
    }

    .badge {
        font-size: 0.7rem;
        padding: 0.3em 0.55em;
        border-radius: 6px;
    }

    .table-responsive {
        font-size: 0.8rem;
        border-radius: 12px;
        overflow: hidden;
    }

    .table th, .table td {
        padding: 0.5rem 0.4rem;
        white-space: nowrap;
    }

    .offcanvas {
        background-color: var(--card-background) !important;
        border-right: none !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15) !important;
    }

    .offcanvas-header {
        background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
        color: white !important;
        padding: 1rem 1.25rem !important;
    }

    .offcanvas-title {
        color: white !important;
        font-weight: 600 !important;
    }

    .offcanvas .btn-close {
        filter: invert(1) !important;
        opacity: 0.8 !important;
    }

    .form-control, .form-select {
        min-height: 46px;
        font-size: 16px !important;
        border-radius: 10px !important;
        border: 1.5px solid var(--border-color);
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .form-control:focus, .form-select:focus {
        border-color: var(--secondary-color);
        box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.15);
    }

    .form-control-sm, .form-select-sm {
        min-height: 40px;
        font-size: 14px !important;
    }

    .form-label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }

    .input-group .btn {
        min-height: 46px;
    }

    .input-group .form-control {
        border-radius: 10px 0 0 10px !important;
    }

    .input-group .btn:last-child {
        border-radius: 0 10px 10px 0 !important;
    }

    .alert {
        border-radius: 12px !important;
        font-size: 0.85rem;
        padding: 0.75rem 1rem;
    }

    .dropdown-menu {
        border-radius: 12px !important;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15) !important;
        border: none !important;
        padding: 0.5rem !important;
    }

    .dropdown-item {
        border-radius: 8px !important;
        padding: 0.6rem 0.875rem !important;
        font-size: 0.9rem;
    }

    .dropdown-divider {
        margin: 0.25rem 0.5rem;
    }

    .mobile-hidden-floating,
    .vet-camera-btn,
    .quick-actions-menu,
    .quick-toggle,
    .quick-actions-content {
        display: none !important;
    }

    .mobile-camera-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: #000;
        z-index: 9999;
        display: flex;
        flex-direction: column;
    }

    .mobile-camera-controls {
        position: absolute;
        bottom: 20px;
        left: 0;
        right: 0;
        text-align: center;
        padding: 20px;
    }

    .mobile-camera-controls .btn {
        margin: 0 10px;
        min-width: 80px;
    }

    .voice-input-active {
        border: 2px solid #dc3545 !important;
        animation: voiceRecording 1s infinite;
    }

    @keyframes voiceRecording {
        0%, 100% { border-color: #dc3545; }
        50% { border-color: #fd7e14; }
    }

    .veterinary-image-gallery {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .veterinary-image-item {
        position: relative;
        aspect-ratio: 1;
        border-radius: 10px;
        overflow: hidden;
        cursor: pointer;
    }

    .veterinary-image-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .consultation-mobile {
        padding: 12px;
    }

    .consultation-mobile .chat-container {
        height: calc(100vh - 200px);
        overflow-y: auto;
        border: 1px solid #eee;
        border-radius: 12px;
        padding: 12px;
        margin-bottom: 12px;
    }

    .consultation-mobile .message {
        margin-bottom: 12px;
        padding: 10px 12px;
        border-radius: 12px;
        font-size: 0.9rem;
    }

    .consultation-mobile .message.user {
        background-color: #e3f2fd;
        margin-left: 16px;
        border-bottom-right-radius: 4px;
    }

    .consultation-mobile .message.ai {
        background-color: #f1f8e9;
        margin-right: 16px;
        border-bottom-left-radius: 4px;
    }

    .predictive-card-mobile {
        background: linear-gradient(135deg, #2D6A4F 0%, #1B4332 100%);
        color: white;
        border-radius: 14px;
        padding: 18px;
        margin-bottom: 12px;
        position: relative;
        overflow: hidden;
    }

    .predictive-card-mobile::before {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        width: 80px;
        height: 80px;
        background: rgba(255,255,255,0.08);
        border-radius: 50%;
        transform: translate(20px, -20px);
    }

    .predictive-score {
        font-size: 2.2rem;
        font-weight: bold;
        color: #95D5B2;
    }

    .diagnostic-mobile .symptom-selector {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 8px;
        margin-bottom: 16px;
    }

    .diagnostic-mobile .symptom-btn {
        padding: 12px 8px;
        border: 2px solid #eee;
        border-radius: 10px;
        background: white;
        text-align: center;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 0.85rem;
    }

    .diagnostic-mobile .symptom-btn.selected {
        border-color: #2D6A4F;
        background-color: rgba(45, 106, 79, 0.06);
        color: #2D6A4F;
    }

    .protocol-mobile-card {
        border-left: 4px solid #2D6A4F;
        margin-bottom: 12px;
        padding: 14px;
        background: white;
        border-radius: 0 12px 12px 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    }

    .protocol-mobile-card.urgent {
        border-left-color: #dc3545;
        background-color: #fff5f5;
    }

    .protocol-mobile-card.warning {
        border-left-color: #ffc107;
        background-color: #fffbf0;
    }

    .pwa-mobile-header {
        position: sticky;
        top: 0;
        background: rgba(255,255,255,0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        z-index: 100;
        border-bottom: 1px solid rgba(0,0,0,0.06);
    }

    .pagination .page-link {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px !important;
        margin: 0 2px;
        font-size: 0.85rem;
    }

    .modal-content {
        border-radius: 16px !important;
        border: none !important;
    }

    .modal-header {
        border-radius: 16px 16px 0 0 !important;
    }

    .footer {
        display: none !important;
    }

    .g-3 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }
}

/* ========== MOBILE BOTTOM NAV (defined outside media query for specificity) ========== */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: none;
    justify-content: space-around;
    align-items: stretch;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 1050;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    height: 64px;
}

@media (max-width: 767.98px) {
    .mobile-bottom-nav {
        display: flex;
    }
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #8c9aa5;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 6px 4px;
    flex: 1;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s ease;
    letter-spacing: 0.2px;
}

.mobile-bottom-nav .nav-item i {
    font-size: 1.25rem;
    margin-bottom: 3px;
    transition: transform 0.2s ease;
}

.mobile-bottom-nav .nav-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

.mobile-bottom-nav .nav-item.active i {
    transform: scale(1.1);
}

.mobile-bottom-nav .nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--secondary-color);
    border-radius: 0 0 4px 4px;
}

.mobile-bottom-nav .nav-item:active {
    opacity: 0.7;
    transform: scale(0.95);
}

/* ========== MOBILE CARD STYLES ========== */
@media (max-width: 768px) {
    .animal-card {
        border-radius: 14px !important;
        border-left-width: 4px !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .animal-card:active {
        transform: scale(0.98);
    }

    .animal-card .card-body {
        padding: 0.75rem !important;
    }

    .animal-card .rounded-circle {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.75rem !important;
    }

    .animal-card h6 {
        font-size: 0.9rem !important;
    }

    .animal-card .bg-light,
    .animal-card [class*="bg-opacity-10"] {
        border-radius: 10px !important;
        padding: 0.4rem !important;
    }

    .animal-card .btn {
        width: auto !important;
        margin-bottom: 0 !important;
        font-size: 0.75rem !important;
        min-height: 36px;
        padding: 0.25rem 0.5rem;
    }

    .dashboard-card {
        border-radius: 14px !important;
        border: none !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06) !important;
    }

    .dashboard-card .card-body {
        padding: 0.75rem !important;
    }

    .dashboard-card .fa-2x {
        font-size: 1.4rem !important;
        margin-bottom: 0.25rem !important;
    }

    .dashboard-card .fs-2 {
        font-size: 1.5rem !important;
    }

    .dashboard-card .card-title {
        font-size: 0.7rem !important;
    }

    .dashboard-card small {
        font-size: 0.65rem !important;
    }
}

/* ========== MOBILE TABLE TO CARD CONVERSION ========== */
@media (max-width: 768px) {
    .mobile-card-view .table {
        display: block;
    }

    .mobile-card-view .table thead {
        display: none;
    }

    .mobile-card-view .table tbody {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .mobile-card-view .table tbody tr {
        display: flex;
        flex-wrap: wrap;
        background: white;
        border: 1px solid rgba(0, 0, 0, 0.06);
        border-radius: 12px;
        padding: 10px 12px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
        gap: 4px;
        align-items: center;
    }

    .mobile-card-view .table tbody tr td {
        border: none !important;
        padding: 2px 4px !important;
        white-space: normal;
    }

    .mobile-card-view .table tbody tr td:first-child {
        order: -1;
    }
}

/* ========== SMALL SCREEN EXTRAS ========== */
@media (max-width: 576px) {
    .container {
        padding: 6px;
    }

    .content-wrapper {
        padding: 0.5rem 0.375rem 1rem;
    }

    h1 {
        font-size: 1.15rem !important;
    }

    .btn-group .btn {
        width: auto !important;
        margin-bottom: 0 !important;
    }

    .d-flex.gap-2 > .btn {
        width: auto !important;
        margin-bottom: 0 !important;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--card-background);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Utility Classes */
.text-primary {
    color: var(--primary-color) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.bg-success {
    background-color: var(--success-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}

.shadow-custom {
    box-shadow: 0 4px 15px rgba(27, 67, 50, 0.1);
}

/* Professional Veterinary/Agricultural System Elements */
.cattle-icon {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

.health-status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.health-status.ok {
    background-color: rgba(82, 183, 136, 0.2);
    color: var(--success-color);
}

.health-status.alert {
    background-color: rgba(247, 127, 0, 0.2);
    color: var(--warning-color);
}

.health-status.critical {
    background-color: rgba(214, 40, 40, 0.2);
    color: var(--danger-color);
}

/* PWA Styles */
.pwa-install-banner {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    text-align: center;
}

.pwa-install-banner .btn {
    margin-top: 0.5rem;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 70px;
    right: 20px;
    background-color: var(--warning-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Sync Status */
.sync-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--success-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Large Touch-Friendly Buttons */
.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    border-radius: 10px;
}

.btn-touch {
    min-height: 48px;
    min-width: 48px;
    padding: 0.75rem 1.5rem;
}