/* Global Styles */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #4895ef;
    --success-color: #4cc9f0;
    --warning-color: #f72585;
    --danger-color: #ff4d6d;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Header Styles */
.navbar {
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 15px rgba(0,0,0,0.05);
    padding: 1rem 0;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: var(--primary-color);
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    padding: 4rem 0;
    margin-bottom: 3rem;
    border-radius: 15px;
}

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

.search-container {
    max-width: 600px;
    margin: 2rem auto;
}

.search-bar {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.search-bar input {
    border: none;
    padding: 1rem;
    font-size: 1rem;
}

.search-bar button {
    padding: 1rem 2rem;
    background: var(--primary-color);
    border: none;
    color: white;
    font-weight: 600;
}

/* Category Cards */
.category-card {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.category-card .card {
    border: none;
    border-radius: 15px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
}

.category-card:hover .card {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.category-card i {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Tool Cards */
.tool-card {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.tool-card .card {
    border: none;
    border-radius: 15px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    height: 100%;
}

.tool-card:hover .card {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

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

/* Search Results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-top: 0.5rem;
    z-index: 1000;
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.search-result-item:last-child {
    border-bottom: none;
}

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

.footer-links a {
    color: var(--dark-color);
    text-decoration: none;
    display: block;
    padding: 0.5rem 0;
}

.social-links a {
    color: var(--dark-color);
    font-size: 1.5rem;
    margin-right: 1rem;
    text-decoration: none;
}

.social-links a:hover {
    color: var(--primary-color);
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary-color);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

/* Loading States */
.loading-container {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.placeholder-card {
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 15px;
}

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

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

/* Section Titles */
.section-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 2rem;
    position: relative;
    padding-bottom: 1rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    border-radius: 2px;
}

/* Ad Containers */
.ad-container {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
    margin: 2rem 0;
}

.ad-placeholder {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: 12px;
    font-weight: 500;
    color: var(--gray-500);
}

/* Tool-specific styles */
.code-editor {
    font-family: monospace;
    resize: vertical;
}

.color-preview {
    cursor: pointer;
}

/* 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;
}

/* Focus styles */
a:focus,
button:focus,
input:focus,
textarea:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: var(--gray-900);
        color: var(--gray-100);
    }

    .navbar {
        background-color: rgba(33, 37, 41, 0.95);
    }

    .card {
        background-color: var(--gray-800);
        color: var(--gray-100);
    }

    .tool-card .card-text,
    .category-card p {
        color: var(--gray-400);
    }

    .search-bar input {
        background: var(--gray-800);
        color: var(--gray-100);
    }

    .ad-placeholder {
        background: var(--gray-800);
        color: var(--gray-400);
    }

    .nav-link:hover {
        background-color: var(--gray-800);
    }

    .category-card .card,
    .tool-card .card {
        background: var(--gray-800);
    }

    .category-card:hover .card::after {
        opacity: 0.2;
    }

    .tool-card .card-title {
        color: var(--gray-100);
    }

    .search-result-item {
        border-bottom-color: var(--gray-700);
    }

    .search-result-item:hover {
        background: var(--gray-700);
    }

    .filter-button {
        background: var(--gray-700);
        color: var(--gray-300);
    }

    .filter-button:hover {
        background: var(--gray-600);
        color: white;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero-section {
        padding: 4rem 0;
        margin-bottom: 2rem;
    }

    .hero-section h1 {
        font-size: 2.5rem;
    }

    .search-bar input,
    .search-bar button {
        padding: 1rem;
    }

    .section-title {
        font-size: 1.75rem;
    }

    .category-card .card-body,
    .tool-card .card-body {
        padding: 1.5rem;
    }

    .category-card i {
        font-size: 2rem;
        margin-bottom: 1rem;
    }

    .category-card h5 {
        font-size: 1.1rem;
    }

    footer {
        padding: 3rem 0 1.5rem;
        margin-top: 4rem;
    }

    footer h5 {
        margin-top: 2rem;
    }

    .footer-bottom {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }

    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }

    .search-results {
        max-height: 300px;
    }

    .category-filters {
        gap: 0.25rem;
    }

    .filter-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}

/* Tool Page Specific Styles */
.tool-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

.tool-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tool-content {
    background-color: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tool-form {
    margin-bottom: 2rem;
}

.tool-result {
    margin-top: 2rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 5px;
    display: none;
}

.tool-result.show {
    display: block;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 1rem auto;
}

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

/* Calculator Specific Styles */
.calculator {
    max-width: 800px;
    margin: 0 auto;
}

.calculator .form-group {
    margin-bottom: 1.5rem;
}

.calculator .result {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
}

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

.tool-card, .category-card {
    animation: fadeIn 0.6s ease-out forwards;
}

/* Improved Loading States */
.loading-container {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spinner 1s linear infinite;
}

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

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

/* Search Results Improvements */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 0.5rem;
    display: none;
}

.search-results.show {
    display: block;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
    transition: all 0.3s ease;
}

.search-result-item:hover {
    background: var(--gray-100);
}

.search-result-item:last-child {
    border-bottom: none;
}

/* Category Filters */
.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.filter-button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 20px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: pointer;
}

.filter-button:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.filter-button.active {
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    color: white;
}

/* Loading Placeholder Animation */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.placeholder-card {
    background: linear-gradient(to right, var(--gray-100) 8%, var(--gray-200) 18%, var(--gray-100) 33%);
    background-size: 2000px 100%;
    animation: shimmer 2s linear infinite;
    border-radius: 16px;
    height: 200px;
} 