/* Custom CSS for Voltage Drop Calculator */

/* Smooth transitions */
* {
    transition: all 0.3s ease;
}

/* Calculator mode buttons */
.calc-mode-btn {
    position: relative;
    overflow: hidden;
}

.calc-mode-btn::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;
}

.calc-mode-btn:hover::before {
    left: 100%;
}

/* Form inputs focus state */
input:focus, select:focus, textarea:focus {
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

/* Results cards animation */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-card {
    animation: slideInUp 0.6s ease-out;
}

.result-card:nth-child(2) { animation-delay: 0.1s; }
.result-card:nth-child(3) { animation-delay: 0.2s; }
.result-card:nth-child(4) { animation-delay: 0.3s; }

/* Gradient text */
.gradient-text {
    background: linear-gradient(45deg, #1e40af, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Premium badge animation */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.premium-badge {
    animation: pulse 2s infinite;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* Fix Chart.js canvas height issues */
canvas {
    max-height: 400px !important;
}

#voltageDistanceChart,
#voltageWireChart,
#efficiencyChart,
#costAnalysisChart {
    max-height: 300px !important;
    height: 300px !important;
}

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

.loading-spinner {
    animation: spin 1s linear infinite;
}

/* Tooltip styles */
.tooltip {
    position: relative;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #1f2937;
    color: white;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Table styles */
.comparison-table {
    border-collapse: separate;
    border-spacing: 0;
}

.comparison-table th {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: white;
    font-weight: 600;
    padding: 1rem;
    text-align: left;
    border-bottom: 2px solid #1d4ed8;
}

.comparison-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    background-color: white;
}

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

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

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

/* NEC Compliance indicators */
.nec-pass {
    color: #059669;
    background-color: #d1fae5;
    border-color: #10b981;
}

.nec-warning {
    color: #d97706;
    background-color: #fef3c7;
    border-color: #f59e0b;
}

.nec-fail {
    color: #dc2626;
    background-color: #fee2e2;
    border-color: #ef4444;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .calc-mode-btn {
        font-size: 0.75rem;
        padding: 0.5rem;
    }
    
    .comparison-table {
        font-size: 0.875rem;
    }
    
    .comparison-table th,
    .comparison-table td {
        padding: 0.5rem;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
    }
    
    .bg-gray-50 {
        background: white !important;
    }
    
    .shadow-lg,
    .shadow-sm {
        box-shadow: none !important;
    }
}

/* Dark mode support (for future implementation) */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #111827;
        color: #f9fafb;
    }
    
    .bg-white {
        background-color: #1f2937 !important;
    }
    
    .text-gray-800 {
        color: #f3f4f6 !important;
    }
    
    .border-gray-300 {
        border-color: #4b5563 !important;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Button hover effects */
.btn-hover-effect {
    position: relative;
    overflow: hidden;
}

.btn-hover-effect::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.6s;
}

.btn-hover-effect:hover::before {
    left: 100%;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators for keyboard navigation */
input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 2px solid #1e40af;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bg-gray-50 {
        background-color: white;
    }
    
    .text-gray-600 {
        color: black;
    }
    
    .border-gray-300 {
        border-color: black;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #1e40af;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translate(-50%, -50%);
}

/* Error states */
.error {
    border-color: #ef4444 !important;
    background-color: #fef2f2 !important;
}

.error:focus {
    ring-color: #ef4444 !important;
}

/* Success states */
.success {
    border-color: #10b981 !important;
    background-color: #f0fdf4 !important;
}

.success:focus {
    ring-color: #10b981 !important;
}

/* Form layout fixes */
.space-y-6 > * + * {
    margin-top: 1.5rem !important;
}

.space-y-4 > * + * {
    margin-top: 1rem !important;
}

/* Ensure form fields have proper spacing */
form .grid.gap-4 {
    gap: 1rem !important;
}

/* Prevent overlap in mobile view */
@media (max-width: 768px) {
    .grid.grid-cols-1.md\:grid-cols-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* Extra spacing for mobile forms */
    form .space-y-6 > * + * {
        margin-top: 2rem !important;
    }
}

/* Fix modal z-index issues */
.fixed.inset-0 {
    z-index: 9999 !important;
}

/* Ensure buttons don't overlap */
.flex.space-x-2 > * + * {
    margin-left: 0.5rem !important;
}

/* Prevent table overflow scrolling issues */
.overflow-y-auto {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* Fix input group alignment */
.flex input, .flex select {
    min-width: 0;
}

.flex > input {
    flex: 1 1 auto;
}

.flex > select {
    flex: 0 0 auto;
}