/* Reset and base styles */
html {
    scroll-behavior: smooth;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4F46E5; /* Indigo */
    --primary-color-dark: #3730A3;
    --primary-color-light: rgba(79, 70, 229, 0.1);
    --secondary-color: #F59E0B; /* Amber */
    --background: #F3F4F6; /* Cool Gray */
    --light-background: #E5E7EB;
    --card-background: #FFFFFF;
    --text-color: #111827; /* Gray */
    --light-text: #6B7280;
    --border-color: #D1D5DB;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 15px rgba(0, 0, 0, 0.1);
    --error-color: #DC2626;
    --success-color: #16A34A;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

/* Add Tailwind CSS-inspired animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

.fade-in {
    animation: fadeIn var(--transition);
}

.slide-in {
    animation: slideIn var(--transition);
}

/* Header styles */
header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--background);
    color: var(--text-color);
    box-shadow: var(--shadow);
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    position: relative;
}

.logo h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

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

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

.search-bar {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    background: var(--light-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.95rem;
}

.search-bar i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--light-text);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
    transition: var(--transition);
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: var(--transition);
}

.nav-links a:hover {
    background: var(--primary-color-light);
    color: var(--primary-color);
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

/* Enhanced Hero section */
#hero {
    background: linear-gradient(135deg, var(--background), var(--light-background));
    padding: 6rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 20%, var(--primary-color-light) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, var(--primary-color-light) 0%, transparent 50%);
    opacity: 0.15;
    animation: gradientShift 15s ease-in-out infinite alternate;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 0%;
    }
    100% {
        background-position: 100% 100%;
    }
}

.hero-content {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    animation: fadeInUp 1s ease-out;
}

.hero-content h2 {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: slideInDown 1s ease-out;
}

.hero-content p {
    font-size: 1.25rem;
    color: var(--light-text);
    margin-bottom: 2.5rem;
    line-height: 1.8;
    animation: fadeIn 1.2s ease-out;
}

.hero-features {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-top: 3rem;
    flex-wrap: wrap;
}

.hero-feature {
    background: var(--light-background);
    padding: 1rem 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
    animation: fadeInUp 0.8s ease-out;
    animation-fill-mode: both;
}

.hero-feature:nth-child(1) { animation-delay: 0.2s; }
.hero-feature:nth-child(2) { animation-delay: 0.4s; }
.hero-feature:nth-child(3) { animation-delay: 0.6s; }

.hero-feature:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-hover);
    background: var(--primary-color-light);
}

.hero-cta {
    margin-top: 2rem;
}

.hero-cta .tool-button {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-weight: 500;
}

.hero-cta .tool-button:hover {
    background: var(--primary-color-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Tools grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 24px;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Enhanced Tool Cards */
.tool-card {
    background: var(--card-background);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 2rem;
    border-radius: 16px;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    min-height: 200px;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
    -webkit-transform: translateY(0);
    transform: translateY(0);
    -webkit-transition: -webkit-transform 0.3s ease, box-shadow 0.3s ease;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-color);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.tool-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.tool-card:hover::before {
    transform: scaleX(1);
}

.tool-card i {
    font-size: 2.5rem;
    color: var(--primary-color);
    transition: var(--transition);
    margin-bottom: 0.5rem;
}

.tool-card:hover i {
    transform: scale(1.1) rotate(5deg);
    color: var(--primary-color-dark);
}

.tool-card h3 {
    font-size: 1.5rem;
    color: var(--text-color);
    margin: 0;
    font-weight: 600;
    transition: var(--transition);
}

.tool-card:hover h3 {
    color: var(--primary-color);
}

.tool-card p {
    color: var(--light-text);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
}

.tool-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem 1.75rem;
    min-width: 120px;
    min-height: 44px;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.tool-button:disabled {
    background: var(--light-text);
    color: var(--background);
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.tool-button:disabled:hover {
    background: var(--light-text);
    transform: none;
    box-shadow: none;
}

.tool-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.tool-button:hover {
    background: var(--primary-color-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    text-decoration: underline;
}

.tool-button:hover::before {
    width: 300px;
    height: 300px;
}

/* Tool Page Layouts */
.tool-page-container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--background);
    border-radius: 10px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.3s ease;
    contain: layout paint;
    isolation: isolate;
    position: relative;
    z-index: 1;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Tool Error States */
.tool-error {
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    color: var(--error-color);
    font-size: 0.9rem;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.tool-loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.tool-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.5rem;
    height: 1.5rem;
    margin: -0.75rem;
    border: 2px solid var(--primary-color-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Tool Input/Output Areas with better isolation */
.tool-input-area, .tool-output-area {
    background: var(--light-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1rem 0;
    position: relative;
    z-index: 2;
}

.tool-input-area:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-light);
}

/* Tool Input Areas */
.tool-input-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tool-input-field {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--light-background);
    transition: var(--transition);
}

.tool-input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-light);
    outline: none;
}

/* Tool Controls */
.tool-controls {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Tool Output Areas */
.tool-output-area {
    background: var(--light-background);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.tool-output-area.active {
    opacity: 1;
    transform: translateY(0);
}

/* Tool Options */
.tool-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--light-background);
    border-radius: 8px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .tool-page-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .tool-input-area, .tool-output-area {
        padding: 1rem;
    }
    
    .tool-controls {
        flex-direction: column;
    }
    
    .tool-button {
        width: 100%;
        justify-content: center;
    }
    
    .tool-options {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
}

/* Grid system test styles */
.grid-test {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 24px;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.grid-test .tool-card {
    min-height: 250px;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
}

@supports not (min: min(300px, 100%)) {
    .grid-test {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* Screen size indicator for testing */
.screen-size-indicator {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    z-index: 1000;
    display: none;
}

@media (max-width: 1024px) {
    .screen-size-indicator {
        display: block;
        content: "Desktop";
    }
}

@media (max-width: 768px) {
    .screen-size-indicator {
        content: "Tablet";
    }
}

@media (max-width: 480px) {
    .screen-size-indicator {
        content: "Mobile";
    }
}

/* Footer */
footer {
    background: var(--light-background);
    padding: 4rem 2rem 2rem;
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 3rem;
}

.footer-section h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    position: relative;
    display: inline-block;
}

.footer-section h3::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    width: 40px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

.footer-section p {
    color: var(--light-text);
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.footer-section p:last-child {
    color: var(--primary-color);
    font-weight: 500;
    margin-top: 1rem;
}

.footer-section a {
    color: var(--light-text);
    text-decoration: none;
    display: block;
    margin-bottom: 0.75rem;
    transition: var(--transition);
}

.footer-section a:hover {
    color: var(--primary-color);
    transform: translateX(5px);
}

.footer-bottom {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--light-text);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

/* Loading Animation */
.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--primary-color-light);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

/* Form elements */
input, select, textarea {
    background: var(--light-background);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: var(--transition);
    border-color: var(--border-color);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-color-light);
    outline: none;
}

label {
    color: var(--light-text);
}

.form-label {
    color: var(--light-text);
    font-weight: 500;
}

/* Disabled states */
input:disabled, select:disabled, textarea:disabled, .button:disabled {
    background: var(--light-background);
    color: var(--light-text);
    cursor: not-allowed;
}

/* Improved input handling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    height: 4px;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover,
input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    background: var(--primary-color-dark);
}

/* Fix for Firefox focus rings */
::-moz-focus-inner {
    border: 0;
}

/* Better touch targets on mobile */
@media (max-width: 768px) {
    .tool-button,
    .case-button,
    input[type="range"] {
        min-height: 44px;
    }

    input[type="range"]::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }

    input[type="range"]::-moz-range-thumb {
        width: 20px;
        height: 20px;
    }
}

/* Metadata and timestamps */
.metadata, .timestamp {
    color: var(--light-text);
    font-size: 0.9rem;
}

/* Additional components */
.error-message {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error-color);
    border-radius: 8px;
    padding: 1rem;
}

.success-message {
    color: var(--success-color);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success-color);
    border-radius: 8px;
    padding: 1rem;
}

/* About section */
.about-section {
    background: var(--light-background);
    padding: 4rem 2rem;
    position: relative;
    overflow: hidden;
}

.about-content {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.about-header {
    text-align: center;
    margin-bottom: 3rem;
}

.about-header h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.about-header p {
    font-size: 1.1rem;
    color: var(--light-text);
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
}

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

.feature-card {
    background: var(--card-background);
    border-radius: 12px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.feature-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-hover);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: var(--primary-color-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.feature-icon i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.feature-card h3 {
    font-size: 1.25rem;
    color: var(--text-color);
    margin: 0;
}

.feature-card p {
    color: var(--light-text);
    margin: 0;
    line-height: 1.6;
}

@media (max-width: 1024px) {
    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
        padding: 1.5rem;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    nav {
        padding: 1rem;
    }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--background);
        padding: 1rem;
        border-top: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        display: none;
        box-shadow: var(--shadow);
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links a {
        padding: 0.75rem;
        text-align: center;
    }

    #hero {
        padding: 3rem 1rem;
        min-height: auto;
    }

    .hero-content h2 {
        font-size: clamp(2rem, 5vw, 4rem);
    }
    
    .hero-content p {
        font-size: 1.1rem;
    }
    
    .hero-features {
        gap: 1rem;
        justify-content: center;
    }
    
    .hero-feature {
        padding: 0.75rem 1.25rem;
    }

    .about-section {
        padding: 3rem 1rem;
    }

    .about-header h2 {
        font-size: 1.75rem;
    }

    .about-header p {
        font-size: 1.1rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .tools-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding: 1rem;
    }

    .hero-content {
        padding: 0 1rem;
    }

    .feature-card {
        padding: 1.5rem;
    }
}

/* Cross-browser compatibility improvements */
@supports not (gap: 1rem) {
    .nav-links {
        margin: -0.5rem;
    }
    .nav-links > * {
        margin: 0.5rem;
    }
}

/* Fallback for browsers that don't support CSS Grid */
@supports not (display: grid) {
    .tools-grid {
        display: flex;
        flex-wrap: wrap;
        margin: -12px;
    }
    
    .tools-grid > * {
        flex: 1 1 300px;
        margin: 12px;
    }
}

/* Smooth scrolling with fallback */
@media screen and (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Cross-browser tool fixes */
.tool-page-content {
    contain: content;
    -webkit-contain: content;
    min-height: 200px;
}

/* Prevent text selection during drag operations */
.dragging {
    user-select: none;
    -webkit-user-select: none;
}

.social-share {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.share-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.share-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}