/* Enhanced UX CSS - Site-wide improvements for better user experience */

/* Smooth transitions for all interactive elements */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

/* Improved focus states for accessibility */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Enhanced button styles site-wide */
.cta,
.form-button,
.popup-link,
button {
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.cta:hover,
.form-button:hover,
.popup-link:hover,
button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Improved card animations */
.card,
.form-card,
.territory-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover,
.form-card:hover,
.territory-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

/* Enhanced loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #4a90e2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Improved form styling */
input,
select,
textarea {
    transition: all 0.3s ease;
    border: 2px solid #e0e0e0;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

input.valid {
    border-color: #28a745;
}

input.invalid {
    border-color: #dc3545;
}

/* Enhanced navigation */
.nav-link {
    position: relative;
    transition: all 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: #4a90e2;
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* Improved scrollbar styling */
::-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;
}

/* Enhanced tooltips */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    font-size: 14px;
    margin-bottom: 5px;
}

[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
    z-index: 1000;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Enhanced animations for page elements */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.6s ease forwards;
}

/* Staggered animations for multiple elements */
.animate-stagger > * {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.animate-stagger > *:nth-child(1) { animation-delay: 0.1s; }
.animate-stagger > *:nth-child(2) { animation-delay: 0.2s; }
.animate-stagger > *:nth-child(3) { animation-delay: 0.3s; }
.animate-stagger > *:nth-child(4) { animation-delay: 0.4s; }
.animate-stagger > *:nth-child(5) { animation-delay: 0.5s; }

/* Improved mobile touch targets */
@media (max-width: 768px) {
    button,
    .cta,
    .form-button,
    .nav-link {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-card,
    .territory-card,
    .card {
        border: 2px solid #000;
    }
    
    .cta,
    .form-button {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print styles */
@media print {
    .header,
    .sidebar,
    .footer,
    .enhancement-notice,
    .enhancement-popup {
        display: none !important;
    }
    
    .main {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
    }
    
    .form-card,
    .territory-card {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
    border-radius: 0 0 4px 4px;
}

.skip-link:focus {
    top: 0;
}

/* Enhanced error and success states */
.error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-message::before {
    content: '⚠️';
}

.success-message {
    color: #28a745;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.success-message::before {
    content: '✅';
}

/* Improved spacing and typography */
.main {
    line-height: 1.6;
}

.main h1,
.main h2,
.main h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.main p {
    margin-bottom: 1em;
}

/* Enhanced responsive design */
@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 200px 1fr;
    }
}

@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .sidebar {
        order: 2;
        position: static;
        height: auto;
    }
    
    .main {
        order: 1;
        padding: 1rem;
    }
}