:root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;
    --primary: 221.2 83.2% 53.3%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96%;
    --secondary-foreground: 222.2 84% 4.9%;
    --muted: 210 40% 96%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96%;
    --accent-foreground: 222.2 84% 4.9%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 210 40% 98%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 221.2 83.2% 53.3%;
    --radius: 0.75rem;
    --chart-1: 12 76% 61%;
    --chart-2: 173 58% 39%;
    --chart-3: 197 37% 24%;
    --chart-4: 43 74% 66%;
    --chart-5: 27 87% 67%;
}

/* Base styles */
* {
    border-color: hsl(var(--border));
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-feature-settings: "rlig" 1, "calt" 1;
}

/* Utility Classes */
.bg-background {
    background-color: hsl(var(--background));
}

.bg-foreground {
    background-color: hsl(var(--foreground));
}

.bg-card {
    background-color: hsl(var(--card));
}

.bg-border {
    background-color: hsl(var(--border));
}

.bg-input {
    background-color: hsl(var(--input));
}

.bg-ring {
    background-color: hsl(var(--ring));
}

.bg-primary {
    background-color: hsl(var(--primary));
}

.bg-primary-foreground {
    background-color: hsl(var(--primary-foreground));
}

.bg-secondary {
    background-color: hsl(var(--secondary));
}

.bg-secondary-foreground {
    background-color: hsl(var(--secondary-foreground));
}

.bg-muted {
    background-color: hsl(var(--muted));
}

.bg-muted-foreground {
    background-color: hsl(var(--muted-foreground));
}

.bg-accent {
    background-color: hsl(var(--accent));
}

.bg-accent-foreground {
    background-color: hsl(var(--accent-foreground));
}

.bg-destructive {
    background-color: hsl(var(--destructive));
}

.bg-destructive-foreground {
    background-color: hsl(var(--destructive-foreground));
}

.text-foreground {
    color: hsl(var(--foreground));
}

.text-card-foreground {
    color: hsl(var(--card-foreground));
}

.text-popover-foreground {
    color: hsl(var(--popover-foreground));
}

.text-primary {
    color: hsl(var(--primary));
}

.text-primary-foreground {
    color: hsl(var(--primary-foreground));
}

.text-secondary-foreground {
    color: hsl(var(--secondary-foreground));
}

.text-muted-foreground {
    color: hsl(var(--muted-foreground));
}

.text-accent-foreground {
    color: hsl(var(--accent-foreground));
}

.text-destructive-foreground {
    color: hsl(var(--destructive-foreground));
}

.border-border {
    border-color: hsl(var(--border));
}

.border-input {
    border-color: hsl(var(--input));
}

.border-ring {
    border-color: hsl(var(--ring));
}

/* Background gradient */
.gradient-bg {
    background: linear-gradient(to bottom right, #38bdf8, #818cf8, #c084fc, #f472b6);
    background-size: 400% 400%;
    animation: gradient-shift 15s ease infinite;
}

@keyframes gradient-shift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Glass morphism effect */
.glass-effect {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Card hover effect */
.card-hover {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.card-hover::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.card-hover:hover::before {
    left: 100%;
}

.card-hover:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

/* Pulse animation */
@keyframes pulse-slow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.animate-pulse-slow {
    animation: pulse-slow 3s ease-in-out infinite;
}

/* Status online animation */
.status-online {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
        transform: scale(1);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
        transform: scale(1);
    }
}

/* Chart container */
.chart-container {
    position: relative;
    height: 300px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(5px);
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    outline: none;
    padding: 12px 24px; /* Added proper padding */
    font-size: 14px;
    line-height: 1.5;
    text-decoration: none;
    min-height: 44px; /* Touch-friendly size */
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.btn:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(to right, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.1);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(to right, #2563eb, #1d4ed8);
    box-shadow: 0 6px 8px rgba(59, 130, 246, 0.15);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-secondary:active:not(:disabled) {
    transform: translateY(0);
    background: #cbd5e1;
}

.btn-history {
    background: linear-gradient(to right, #8b5cf6, #7c3aed);
    color: white;
    box-shadow: 0 4px 6px rgba(139, 92, 246, 0.1);
}

.btn-history:hover:not(:disabled) {
    background: linear-gradient(to right, #7c3aed, #6d28d9);
    box-shadow: 0 6px 8px rgba(139, 92, 246, 0.15);
    transform: translateY(-1px);
}

.btn-history:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.1);
}

.btn-download {
    background: linear-gradient(to right, #10b981, #059669);
    color: white;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.1);
}

.btn-download:hover:not(:disabled) {
    background: linear-gradient(to right, #059669, #047857);
    box-shadow: 0 6px 8px rgba(16, 185, 129, 0.15);
    transform: translateY(-1px);
}

.btn-download:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.1);
}

.btn-icon {
    padding: 8px;
    min-height: 40px;
    min-width: 40px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-light {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(229, 231, 235, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn-light:hover:not(:disabled) {
    background: rgba(243, 244, 246, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-light:active:not(:disabled) {
    transform: translateY(0);
}

/* Button size variants */
.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
    min-height: 36px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
    min-height: 52px;
}

/* Form elements */
.form-input, .form-select {
    display: block;
    width: 100%;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    padding: 12px 16px; /* Improved padding */
    font-size: 14px;
    transition: all 0.2s;
    outline: none;
    line-height: 1.5;
    min-height: 44px; /* Touch-friendly size */
}

.form-input:focus, .form-select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

.form-input::placeholder {
    color: #94a3b8;
}

/* Override for specific width inputs */
.form-input[style*="width"], .form-select[style*="width"] {
    width: auto; /* Allow inline width styles */
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-error {
    background: #fecaca;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Loading animation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f4f6;
    border-radius: 50%;
    border-top-color: #3b82f6;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Table styles */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
}

.table tbody tr:hover {
    background: #f9fafb;
}

/* Water level specific styles */
.water-level-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.water-level-high {
    background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
}

.water-level-medium {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.water-level-low {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

/* Responsive utilities */
@media (max-width: 768px) {
    .glass-effect {
        backdrop-filter: blur(5px);
        -webkit-backdrop-filter: blur(5px);
    }

    .card-hover:hover {
        transform: translateY(-4px);
    }

    /* Add padding for mobile export bar */
    body {
        padding-bottom: 80px;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Focus visible for accessibility */
.focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

/* Smooth transitions */
* {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}