/* CSS Variables for Light and Dark Themes */
:root {
    --bg-color: #f9f9f9;
    --container-bg: #ffffff;
    --text-color: #000000;
    --text-secondary: #666;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --loader-bg: #e6dcdc;
    --select-bg: #ffffff;
    --select-border: #ccc;
    --focus-color: #007bff;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --container-bg: #2d2d2d;
    --text-color: #f5f5f5;
    --text-secondary: #b0b0b0;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --loader-bg: #3d3d3d;
    --select-bg: #3d3d3d;
    --select-border: #555;
    --focus-color: #66b3ff;
}

/* Accessibility: Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--focus-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 100;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--text-color);
    outline-offset: 2px;
}

/* Accessibility: Focus Styles */
*:focus-visible {
    outline: 2px solid var(--focus-color);
    outline-offset: 2px;
}

button:focus-visible,
select:focus-visible {
    outline: 3px solid var(--focus-color);
    outline-offset: 3px;
}

/* General Body Styling */
body {
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Container Styling */
.container {
    max-width: 600px;
    margin: 50px auto;
    padding: 20px;
    background: var(--container-bg);
    box-shadow: 0px 4px 10px var(--shadow-color);
    border-radius: 10px;
    text-align: center; /* Center all content inside the container */
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

/* Title Styling */
.title {
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--text-color);
}

/* Language Selector Styling */
.language-select {
    margin-bottom: 20px;
}

select {
    padding: 10px;
    font-size: 1em;
    background-color: var(--select-bg);
    color: var(--text-color);
    border: 1px solid var(--select-border);
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.language-select label {
    color: var(--text-color);
}

/* Image Container */
.image-container {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
}

/* Cat Image Styling */
.cat-image {
    width: 100%;
    max-width: 400px;
    height: auto; /* Maintain aspect ratio */
    border-radius: 10px;
    margin: 20px auto; /* Center the image horizontally */
    display: block; /* Ensure image is treated as a block-level element */
    object-fit: contain; /* Ensure the full image fits within the bounds */
}

/* Loading Spinner */
.loading-spinner {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.loading-spinner p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 1em;
}

/* Cat Loader Animation */
.cat-loader {
    position: relative;
    width: 100%;
    max-width: 10em;
    overflow: hidden;
    background-color: #e6dcdc;
}

.cat-loader::before {
    content: '';
    display: block;
    padding-bottom: 100%;
}

.cat-loader:hover > * {
    animation-play-state: paused;
}

.cat-loader:active > * {
    animation-play-state: running;
}

.cat-loader__head,
.cat-loader__tail,
.cat-loader__body {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    animation: rotating 2.79s cubic-bezier(.65, .54, .12, .93) infinite;
}

.cat-loader__head::before,
.cat-loader__tail::before,
.cat-loader__body::before {
    content: '';
    position: absolute;
    width: 50%;
    height: 50%;
    background-size: 200%;
    background-repeat: no-repeat;
    background-image: url('https://images.weserv.nl/?url=i.imgur.com/M1raXX3.png&il');
}

.cat-loader__head::before {
    top: 0;
    right: 0;
    background-position: 100% 0%;
    transform-origin: 0% 100%;
    transform: rotate(90deg);
}

.cat-loader__tail {
    animation-delay: .2s;
}

.cat-loader__tail::before {
    left: 0;
    bottom: 0;
    background-position: 0% 100%;
    transform-origin: 100% 0%;
    transform: rotate(-30deg);
}

.cat-loader__body {
    animation-delay: .1s;
}

.cat-loader__body:nth-of-type(2) {
    animation-delay: .2s;
}

.cat-loader__body::before {
    right: 0;
    bottom: 0;
    background-position: 100% 100%;
    transform-origin: 0% 0%;
}

@keyframes rotating {
    from {
        transform: rotate(720deg);
    }
    to {
        transform: none;
    }
}

/* Button Styling */
.button {
    display: inline-block; /* Default inline block for flexibility */
    padding: 10px 20px;
    font-size: 1em;
    color: #ffffff;
    background-color: #007bff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin: 10px 5px; /* Add space between buttons */
    transition: background-color 0.3s;
    text-align: center;
}

/* Button Hover Effect */
.button:hover {
    background-color: #0056b3;
}

/* Download Button Styling */
.download-button {
    background-color: #28a745;
}

.download-button:hover {
    background-color: #218838;
}

/* Theme Toggle Button Styling */
.theme-toggle-container {
    margin: 15px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.theme-toggle-button {
    background: var(--container-bg);
    border: 2px solid var(--select-border);
    border-radius: 50px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px var(--shadow-color);
}

.theme-toggle-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.theme-toggle-button:active {
    transform: scale(0.95);
}

/* Icon visibility based on theme */
[data-theme="light"] .moon-icon {
    display: inline;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: inline;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

/* Performance: Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
