/* Custom CSS for AgriPulse Dashboard */

/* ---------------------------------- */
/* 1. THEME DEFINITIONS (Custom Props) */
/* ---------------------------------- */
:root {
    /* Base Green Theme (Default) */
    --color-primary: #10B981; /* Emerald 500 */
    --color-primary-dark: #059669; /* Emerald 600 */
    --color-secondary: #1F2937; /* Gray 800 */
    --color-secondary-hover: #374151; /* Gray 700 */
    --color-secondary-active: #111827; /* Gray 900 */
    --color-border-color: #4B5563; /* Gray 600 for dark surfaces */
}

.theme-blue {
    --color-primary: #3B82F6; /* Blue 500 */
    --color-primary-dark: #2563EB; /* Blue 600 */
    --color-secondary: #0A3D62; /* Darker Blue/Navy */
    --color-secondary-hover: #145DA0;
    --color-secondary-active: #042D4A;
}

.theme-earth {
    --color-primary: #CA8A04; /* Amber 600 */
    --color-primary-dark: #A16207; /* Amber 700 */
    --color-secondary: #583F2F; /* Brown/Dark Earth */
    --color-secondary-hover: #6F5441;
    --color-secondary-active: #473223;
}

/* Custom colors for modals */
.bg-whatsapp { background-color: #25D366; }
.hover\:bg-whatsapp-dark:hover { background-color: #128C7E; }

/* Apply custom properties to Tailwind classes */
.bg-primary { background-color: var(--color-primary); }
.hover\:bg-primary-dark:hover { background-color: var(--color-primary-dark); }
.text-primary { color: var(--color-primary); }
.focus\:ring-primary:focus { --tw-ring-color: var(--color-primary); }
.focus\:border-primary:focus { border-color: var(--color-primary); }

.bg-secondary { background-color: var(--color-secondary); }
.bg-secondary-active { background-color: var(--color-secondary-active); }
.hover\:bg-secondary-hover:hover { background-color: var(--color-secondary-hover); }
.border-border-color { border-color: var(--color-border-color); }

/* ---------------------------------- */
/* 2. ANIMATIONS (PROFESSIONAL) */
/* ---------------------------------- */

/* Fade-in for page content after load/switch */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* Fade-out for login screen (simulated for clean transition) */
@keyframes fadeOutUp {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}

.fade-out-up {
    animation: fadeOutUp 0.3s ease-out forwards;
}

/* ---------------------------------- */
/* 3. MOBILE RESPONSIVENESS FIXES */
/* ---------------------------------- */

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 30; /* Below sidebar (z-40) but above content */
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 1023px) {
    /* Prevent body scroll when mobile menu is open */
    .overflow-hidden {
        overflow: hidden !important;
    }

    /* Ensure the sticky nav content fills the sidebar on mobile */
    nav .p-4.sticky {
        top: 0; 
        height: 100vh;
        overflow-y: auto;
    }
}

/* ---------------------------------- */
/* 4. UTILITY & COMPONENT STYLES */
/* ---------------------------------- */

/* Chart Containers (optional but good practice) */
.chart-container {
    position: relative;
    /* Optional: min-height: 200px; */ 
}

/* Crop Doctor Drop Area Animation */
.file-drop-area {
    border: 3px dashed var(--color-primary);
    background-color: #F9FAFB;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.file-drop-area:hover {
    border-color: var(--color-primary-dark);
    background-color: #F3F4F6;
}

.file-drop-area.active {
    border-color: #EF4444; /* Red border when actively dragging */
    background-color: #FEF2F2; /* Light red background */
}

/* Page Content Toggling */
.page-content {
    display: none;
}

.page-content.active {
    display: block;
}

/* Chat Bubbles and Typing Indicator */
.chat-bubble {
    max-width: 80%;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
}

.user-bubble {
    background-color: #3B82F6;
    color: white;
    margin-left: auto; /* Aligns to the right */
    border-top-right-radius: 0.25rem;
}

.agripulse-bubble {
    background-color: #E5E7EB;
    color: #1F2937;
    margin-right: auto; /* Aligns to the left */
    border-top-left-radius: 0.25rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    background-color: #E5E7EB;
    max-width: 80px; /* Make it small */
    margin-right: auto;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: #9CA3AF;
    border-radius: 50%;
    margin-right: 4px;
    animation: bounce 1.4s infinite ease-in-out;
}

.dot:nth-child(2) {
    animation-delay: 0.2s;
}

.dot:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-5px);
    }
}

/* Loading Spinner */
.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-state {
    text-align: center;
    padding: 2rem 0;
}

/* Skeleton Loader */
.skeleton-loader {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Connection Status Indicator */
[data-connection="offline"]::before {
    content: "⚠️ Offline - Some features may be limited";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #f59e0b;
    color: white;
    text-align: center;
    padding: 8px;
    z-index: 1000;
    font-size: 14px;
    font-weight: 500;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
    max-width: 400px;
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
}

.notification.show {
    transform: translateX(0);
}

.notification.info {
    background-color: #3B82F6;
    color: white;
}

.notification.success {
    background-color: #10B981;
    color: white;
}

.notification.warning {
    background-color: #F59E0B;
    color: white;
}

.notification.error {
    background-color: #EF4444;
    color: white;
}

/* Error States */
.error-state {
    text-align: center;
    padding: 2rem;
    color: #6B7280;
}

.error-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #9CA3AF;
}

/* Form Validation Styles */
.input-error {
    border-color: #EF4444 !important;
}

.error-message {
    color: #EF4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Responsive improvements for very small screens */
@media (max-width: 640px) {
    .chat-bubble {
        max-width: 90%;
    }
    
    .notification {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .page-content {
        display: block !important;
    }
    
    .chart-container {
        page-break-inside: avoid;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-primary: #005a00;
        --color-primary-dark: #003d00;
    }
    
    .theme-blue {
        --color-primary: #000080;
        --color-primary-dark: #000050;
    }
    
    .theme-earth {
        --color-primary: #804000;
        --color-primary-dark: #502800;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .fade-in,
    .fade-out-up {
        animation: none;
    }
}