/**
 * Garden Management System - Enhanced Stylesheet
 * Mobile-First Responsive Design with Dark Mode
 * Version: 3.0.0
 */

/* ========================================
   CSS VARIABLES - Light Mode (Default)
   ======================================== */
:root {
    /* Colors */
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-light: #8b9ff5;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    --gradient-warning: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);

    /* Background & Surfaces */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f0;
    --surface-color: #ffffff;
    --surface-elevated: #ffffff;

    /* Text Colors */
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --text-light: #adb5bd;

    /* Borders */
    --border-color: #dee2e6;
    --border-light: #e9ecef;

    /* Grays */
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.15);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s ease;
    --transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ========================================
   DARK MODE VARIABLES
   ======================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #121212;
        --bg-secondary: #1e1e1e;
        --bg-tertiary: #2a2a2a;
        --surface-color: #1e1e1e;
        --surface-elevated: #2a2a2a;

        --text-primary: #f5f5f5;
        --text-secondary: #b0b0b0;
        --text-muted: #888888;
        --text-light: #666666;

        --border-color: #333333;
        --border-light: #2a2a2a;

        --gray-100: #1a1a1a;
        --gray-200: #2a2a2a;
        --gray-300: #3a3a3a;
        --gray-400: #4a4a4a;
        --gray-500: #6a6a6a;
        --gray-600: #8a8a8a;
        --gray-700: #aaaaaa;
        --gray-800: #cccccc;
        --gray-900: #f5f5f5;

        --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
        --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
        --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
        --shadow-xl: 0 20px 50px rgba(0,0,0,0.5);
    }
}

/* Manual dark mode class */
body.dark-mode {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2a2a2a;
    --surface-color: #1e1e1e;
    --surface-elevated: #2a2a2a;

    --text-primary: #f5f5f5;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --text-light: #666666;

    --border-color: #333333;
    --border-light: #2a2a2a;

    --gray-100: #1a1a1a;
    --gray-200: #2a2a2a;
    --gray-300: #3a3a3a;
    --gray-400: #4a4a4a;
    --gray-500: #6a6a6a;
    --gray-600: #8a8a8a;
    --gray-700: #aaaaaa;
    --gray-800: #cccccc;
    --gray-900: #f5f5f5;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.5);
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent double-tap zoom on interactive elements */
button, a, input, select, textarea, .btn {
    touch-action: manipulation;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: var(--spacing-md);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary-dark);
}

small {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ========================================
   LAYOUT COMPONENTS
   ======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.dashboard-container {
    padding: var(--spacing-md);
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   BUTTONS - Mobile First
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all var(--transition-base);
    font-size: 0.9375rem;
    line-height: 1.5;
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* Touch target */
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
    transform: translateY(-2px);
}

.btn-warning {
    background: var(--warning-color);
    color: var(--gray-900);
}

.btn-warning:hover:not(:disabled) {
    background: #e0a800;
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.8125rem;
    min-height: 36px;
}

.btn-large {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-icon {
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
}

/* ========================================
   FORMS - Mobile First
   ======================================== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="file"],
input[type="search"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-base);
    background: var(--surface-color);
    color: var(--text-primary);
    min-height: 48px; /* Touch target */
    -webkit-appearance: none;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: var(--spacing-sm);
    cursor: pointer;
    accent-color: var(--primary-color);
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* Form helper text */
.form-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: var(--spacing-xs);
}

/* ========================================
   CARDS - Mobile First
   ======================================== */
.card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-md);
    transition: all var(--transition-base);
    border: 1px solid var(--border-light);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--border-light);
}

.card-title {
    font-size: 1.125rem;
    margin-bottom: 0;
    font-weight: 600;
}

.card-body {
    padding: var(--spacing-sm) 0;
}

.card-footer {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-light);
}

/* ========================================
   STATISTICS CARDS
   ======================================== */
.stats-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-primary);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

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

.stat-card h3 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.stat-number.harvest {
    color: var(--success-color);
}

.stat-number.warning {
    color: var(--warning-color);
}

.stat-card small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

@keyframes stat-update {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.stat-update {
    animation: stat-update 0.5s ease;
}

/* ========================================
   ALERTS & NOTIFICATIONS
   ======================================== */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    position: relative;
    border-left: 4px solid currentColor;
    font-size: 0.9375rem;
}

.alert.flash {
    animation: slideIn 0.3s var(--transition-base);
}

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

.alert-success {
    background: rgba(40, 167, 69, 0.1);
    border-color: var(--success-color);
    color: var(--success-color);
}

.alert-error,
.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

.alert-warning {
    background: rgba(255, 193, 7, 0.1);
    border-color: var(--warning-color);
    color: #856404;
}

.alert-info {
    background: rgba(23, 162, 184, 0.1);
    border-color: var(--info-color);
    color: var(--info-color);
}

.close-alert {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.6;
    padding: 4px;
    line-height: 1;
}

.close-alert:hover {
    opacity: 1;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-md);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    max-width: calc(100vw - 2rem);
}

.toast {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    background: var(--surface-elevated);
    box-shadow: var(--shadow-lg);
    animation: toastSlideIn 0.3s ease;
    max-width: 350px;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-primary { background: var(--primary-color); color: white; }
.badge-success { background: var(--success-color); color: white; }
.badge-danger { background: var(--danger-color); color: white; }
.badge-warning { background: var(--warning-color); color: var(--gray-900); }
.badge-info { background: var(--info-color); color: white; }
.badge-secondary { background: var(--gray-500); color: white; }

/* Plant status badges */
.badge-germinating { background: #8bc34a; color: white; }
.badge-seedling { background: #4caf50; color: white; }
.badge-vegetative { background: #009688; color: white; }
.badge-flowering { background: #e91e63; color: white; }
.badge-fruiting { background: #ff9800; color: white; }
.badge-harvesting { background: #ff5722; color: white; }
.badge-dormant { background: #9e9e9e; color: white; }
.badge-deceased { background: #424242; color: white; }

/* Health status badges */
.badge-excellent { background: #4caf50; color: white; }
.badge-good { background: #8bc34a; color: white; }
.badge-fair { background: #ffc107; color: var(--gray-900); }
.badge-poor { background: #ff9800; color: white; }
.badge-critical { background: #f44336; color: white; }

/* ========================================
   TASKS & TIMELINE
   ======================================== */
.tasks-section {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--border-light);
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.task-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--gray-400);
    transition: all var(--transition-base);
}

.task-item:active {
    transform: scale(0.99);
}

.task-item.priority-high {
    border-left-color: var(--danger-color);
}

.task-item.priority-medium {
    border-left-color: var(--warning-color);
}

.task-item.priority-low {
    border-left-color: var(--info-color);
}

.task-content {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.task-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.task-details {
    flex: 1;
    min-width: 0;
}

.task-details strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}

.task-details span {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.complete-task-btn {
    align-self: flex-end;
}

.no-tasks {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
}

/* Activity Timeline */
.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.activity-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-left: 3px solid var(--border-color);
    position: relative;
}

.activity-item::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid var(--surface-color);
}

.activity-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.activity-time {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 2px;
}

/* ========================================
   GARDEN GRID - Touch Optimized
   ======================================== */
.garden-grid-container {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.garden-grid {
    display: grid;
    gap: var(--spacing-sm);
    margin: var(--spacing-md) 0;
    transition: transform var(--transition-base);
}

.grid-cell {
    aspect-ratio: 1;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    min-height: 80px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.grid-cell.empty:hover,
.grid-cell.empty:active {
    border-color: var(--primary-color);
    border-style: solid;
    background: rgba(102, 126, 234, 0.08);
}

.grid-cell.occupied {
    border-style: solid;
    border-color: var(--success-color);
    background: var(--surface-color);
}

.grid-cell.drag-over {
    background: rgba(102, 126, 234, 0.15);
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.grid-cell.touch-active {
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.05);
}

.cell-position {
    font-size: 0.625rem;
    color: var(--text-muted);
    font-weight: 600;
    position: absolute;
    top: 4px;
    left: 4px;
}

.cell-action {
    font-size: 1.5rem;
    color: var(--text-light);
    line-height: 1;
}

.plant-in-cell {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xs);
    cursor: grab;
    touch-action: none;
}

.plant-in-cell:active {
    cursor: grabbing;
}

.plant-in-cell.dragging {
    opacity: 0.5;
}

.plant-emoji {
    font-size: 1.5rem;
    margin-bottom: 2px;
}

.plant-name {
    font-weight: 600;
    font-size: 0.625rem;
    text-align: center;
    color: var(--text-primary);
    line-height: 1.2;
    word-break: break-word;
}

.plant-variety {
    font-size: 0.5rem;
    color: var(--text-muted);
    text-align: center;
}

.plant-status {
    font-size: 0.5rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 2px;
}

/* Health status colors */
.health-excellent { background: rgba(76, 175, 80, 0.15); }
.health-good { background: rgba(139, 195, 74, 0.15); }
.health-fair { background: rgba(255, 193, 7, 0.15); }
.health-poor { background: rgba(255, 152, 0, 0.15); }
.health-critical { background: rgba(244, 67, 54, 0.15); }

/* ========================================
   AI CHAT - Mobile Optimized
   ======================================== */
.chat-wrapper {
    position: fixed;
    bottom: 80px;
    right: var(--spacing-md);
    width: calc(100vw - 2rem);
    max-width: 380px;
    max-height: calc(100vh - 160px);
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    z-index: 997;
    animation: chatSlideUp 0.3s ease;
    border: 1px solid var(--border-light);
}

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

.chat-header {
    padding: var(--spacing-md);
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    color: white;
}

.chat-plant-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    font-size: 0.8125rem;
    opacity: 0.9;
}

.chat-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.chat-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    max-height: 300px;
    -webkit-overflow-scrolling: touch;
}

.message {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    animation: messageSlide 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.message-user .message-avatar {
    background: var(--gray-400);
}

.message-system .message-avatar {
    background: var(--info-color);
}

.message-error .message-avatar {
    background: var(--danger-color);
}

.message-content {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
}

.message-user .message-content {
    background: var(--primary-color);
    color: white;
}

.message-time {
    font-size: 0.625rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.typing-indicator {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

.quick-questions {
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    border-top: 1px solid var(--border-light);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.quick-btn {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    color: var(--text-secondary);
}

.quick-btn:hover,
.quick-btn:active {
    background: var(--primary-color);
    color: white;
}

.chat-input-area {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-light);
}

#chat-input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
    resize: none;
    min-height: 44px;
    max-height: 100px;
    background: var(--surface-color);
    color: var(--text-primary);
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-footer {
    padding: var(--spacing-sm);
    text-align: center;
    border-top: 1px solid var(--border-light);
}

.chat-footer small {
    color: var(--text-muted);
    font-size: 0.625rem;
}

/* ========================================
   MODALS - Mobile Optimized
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
}

.modal.active {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--surface-color);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 2px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--surface-color);
    z-index: 1;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 8px;
    margin: -8px;
    transition: color var(--transition-base);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    position: sticky;
    bottom: 0;
    background: var(--surface-color);
}

/* Modal handle for mobile */
.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: var(--spacing-sm) auto;
}

/* ========================================
   TABLES - Mobile Optimized
   ======================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--spacing-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    min-width: 600px;
}

thead {
    background: var(--bg-tertiary);
}

th {
    padding: var(--spacing-md);
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

td {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-light);
    color: var(--text-primary);
}

tr:hover {
    background: var(--bg-tertiary);
}

/* Mobile card view for tables */
.mobile-card-view {
    display: none;
}

/* ========================================
   UTILITIES
   ======================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary-color); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }

.font-bold { font-weight: 600; }
.font-normal { font-weight: 400; }

.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }

.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }

.p-1 { padding: var(--spacing-xs); }
.p-2 { padding: var(--spacing-sm); }
.p-3 { padding: var(--spacing-md); }
.p-4 { padding: var(--spacing-lg); }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* ========================================
   LOADING & SPINNERS
   ======================================== */
.spinner {
    border: 3px solid var(--border-light);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: var(--spacing-lg) auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

body.dark-mode .loading-overlay,
.loading-overlay:where(body.dark-mode *) {
    background: rgba(18, 18, 18, 0.95);
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border-light) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   EMPTY STATES
   ======================================== */
.empty-state {
    text-align: center;
    padding: var(--spacing-xxl) var(--spacing-lg);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.empty-state p {
    margin-bottom: var(--spacing-lg);
}

/* ========================================
   PULL TO REFRESH
   ======================================== */
.pull-to-refresh {
    text-align: center;
    padding: var(--spacing-md);
    color: var(--text-muted);
    font-size: 0.875rem;
    display: none;
}

.pull-to-refresh.active {
    display: block;
}

/* ========================================
   RESPONSIVE - Tablet
   ======================================== */
@media (min-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }

    .dashboard-container {
        padding: var(--spacing-lg);
    }

    .card {
        padding: var(--spacing-lg);
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        flex-direction: row;
    }

    .task-item {
        flex-direction: row;
        align-items: center;
    }

    .complete-task-btn {
        align-self: center;
    }

    /* Modal centered on tablet+ */
    .modal.active {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius-xl);
        max-width: 600px;
        max-height: 85vh;
    }

    .modal-footer {
        flex-direction: row;
        justify-content: flex-end;
    }

    .modal-handle {
        display: none;
    }

    /* Chat widget */
    .chat-wrapper {
        bottom: var(--spacing-lg);
        right: var(--spacing-lg);
        width: 380px;
    }
}

/* ========================================
   RESPONSIVE - Desktop
   ======================================== */
@media (min-width: 1024px) {
    h1 { font-size: 2.25rem; }

    .dashboard-container {
        padding: var(--spacing-xl);
    }

    .stats-row {
        grid-template-columns: repeat(4, 1fr);
    }

    .stat-number {
        font-size: 2.5rem;
    }

    .garden-grid {
        gap: var(--spacing-md);
    }

    .grid-cell {
        min-height: 100px;
    }

    .plant-emoji {
        font-size: 2rem;
    }

    .plant-name {
        font-size: 0.75rem;
    }
}

/* ========================================
   RESPONSIVE - Large Desktop
   ======================================== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }

    .dashboard-container {
        max-width: 1600px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .navigation,
    .navbar,
    .btn,
    .chat-wrapper,
    .modal,
    .bottom-nav,
    .mobile-sidebar,
    .sidebar-overlay {
        display: none !important;
    }

    body {
        background: white;
        color: black;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .dashboard-container {
        padding: 0;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: var(--spacing-sm) var(--spacing-md);
    z-index: 100000;
    transition: top var(--transition-base);
}

.skip-link:focus {
    top: 0;
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) var(--bg-tertiary);
}
