/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem 0;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
}

.nav-logo i {
    margin-right: 10px;
}

.nav-menu {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-link:hover {
    color: #ffd700;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 120px 0 80px;
    text-align: center;
    margin-top: 70px;
}

.hero-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.cta-button {
    display: inline-block;
    background: #ffd700;
    color: #333;
    padding: 12px 30px;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

/* Utilities Section */
.utilities-section {
    padding: 80px 0;
    background: white;
}

.utilities-section h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
}

.utilities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.utility-card {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.utility-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.utility-icon {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.utility-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #333;
}

.utility-card p {
    color: #666;
    line-height: 1.6;
}

/* About Section */
.about-section {
    padding: 80px 0;
    background: #f8f9fa;
    text-align: center;
}

.about-section h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #333;
}

.about-section p {
    font-size: 1.1rem;
    color: #666;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.8;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

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

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    color: white;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: #ffd700;
}

.modal-body {
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
}

footer p {
    margin: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-menu {
        gap: 1rem;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
    
    .utilities-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .utility-card {
        padding: 1.5rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .modal-body {
        padding: 1rem;
    }
}

/* Utility-specific styles */
.calculator {
    max-width: 400px;
    margin: 0 auto;
}

.calc-display {
    width: 100%;
    height: 80px;
    font-size: 2rem;
    text-align: right;
    padding: 0 20px;
    border: 2px solid #ddd;
    border-radius: 10px;
    margin-bottom: 20px;
    background: #f8f9fa;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.calc-btn {
    height: 60px;
    font-size: 1.2rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.calc-btn.number {
    background: #e9ecef;
    color: #333;
}

.calc-btn.operator {
    background: #667eea;
    color: white;
}

.calc-btn.equals {
    background: #28a745;
    color: white;
}

.calc-btn.clear {
    background: #dc3545;
    color: white;
}

.calc-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.image-generator {
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    background: #667eea;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s ease;
}

.btn:hover {
    background: #5a6fd8;
}

.generated-image {
    margin-top: 20px;
    border: 2px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
}

.download-link {
    display: inline-block;
    margin-top: 10px;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.download-link:hover {
    text-decoration: underline;
}

/* Accessibility Styles */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    z-index: 10000;
    transition: top 0.3s ease;
}

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

/* Focus indicators */
*:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.nav-link:focus,
.cta-button:focus,
.utility-card:focus {
    outline: 3px solid #ffd700;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .utility-card {
        border: 2px solid #000;
    }
    
    .nav-link:hover {
        background: rgba(255, 255, 255, 0.2);
        border-radius: 4px;
        padding: 4px 8px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .utility-card:hover {
        transform: none;
    }
    
    .cta-button:hover {
        transform: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .utilities-section {
        background: #2d2d2d;
    }
    
    .utility-card {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #555;
    }
    
    .utility-card h3 {
        color: #fff;
    }
    
    .utility-card p {
        color: #ccc;
    }
    
    .about-section {
        background: #2d2d2d;
    }
    
    .about-section h2 {
        color: #fff;
    }
    
    .about-section p {
        color: #ccc;
    }
}

/* Screen reader only content */
.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;
}

/* Improved button accessibility */
button, .btn, .calc-btn {
    min-height: 44px;
    min-width: 44px;
}

/* Better color contrast for links */
a {
    color: #0066cc;
}

a:visited {
    color: #551a8b;
}

a:hover, a:focus {
    color: #004499;
}

/* Modal accessibility improvements */
.modal[aria-hidden="true"] {
    display: none;
}

.modal[aria-hidden="false"] {
    display: block;
}

.modal-content {
    position: relative;
}

.modal-content:focus {
    outline: none;
}

/* Form accessibility */
input:invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

input:valid {
    border-color: #28a745;
}

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

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error states */
.error {
    color: #dc3545;
    font-weight: 600;
}

.error-border {
    border-color: #dc3545 !important;
}

/* Success states */
.success {
    color: #28a745;
    font-weight: 600;
}

.success-border {
    border-color: #28a745 !important;
}
