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

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.hero {
    text-align: center;
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

/* Control Panel */
.control-panel {
    min-width: 0;
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    height: fit-content;
}

.control-panel h2 {
    margin-bottom: 1rem;
    color: #4a5568;
    font-weight: 600;
}

.button-grid {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.api-button {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    text-align: center;
}

.api-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.api-button:active {
    transform: translateY(0);
}

.api-button.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.api-button.secondary {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.api-button.tertiary {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
    color: white;
}

.api-button.info {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    color: #2d3748;
}

.api-button.search {
    background: linear-gradient(135deg, #fa709a, #fee140);
    color: #2d3748;
}

/* Search Section */
.search-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.search-section h3 {
    margin-bottom: 0.75rem;
    color: #4a5568;
    font-size: 1.1rem;
}

.search-section input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    transition: border-color 0.2s ease;
}

.search-section input:focus {
    outline: none;
    border-color: #667eea;
}

/* Results Container */
.results-container {
    min-width: 0;
    overflow: hidden;
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    min-height: 400px;
}

.welcome-message {
    text-align: center;
    color: #4a5568;
}

.welcome-message h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.welcome-message ul {
    text-align: left;
    max-width: 400px;
    margin: 1rem auto;
}

.welcome-message li {
    margin-bottom: 0.5rem;
}

/* Loading Spinner */
.loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Result Display */
.dog-card, .breed-list, .json-display {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dog-card {
    text-align: center;
    padding: 1rem;
}

.dog-card h3 {
    margin-bottom: 1rem;
    color: #2d3748;
}

.dog-card img {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    display: block;
    margin: 0 auto;
}

.dog-info {
    background: #f7fafc;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.breed-list {
    columns: 2;
    column-gap: 2rem;
}

.breed-item {
    break-inside: avoid;
    background: #f7fafc;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.json-display {
    background: #1a202c;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

.json-display pre {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

/* Fallback Content */
.fallback-notice {
    text-align: center;
    padding: 2rem;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    margin-top: 1rem;
}

.fallback-content {
    margin-top: 1rem;
}

.fallback-content ul {
    text-align: left;
    max-width: 300px;
    margin: 0 auto;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: rgba(255,255,255,0.8);
}

.footer a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Utility Classes */
.hidden {
    display: none;
}

.error {
    color: #e53e3e;
    background: #fed7d7;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #feb2b2;
}

/* Cache Management Dashboard */
.cache-dashboard {
    grid-column: 1 / -1;
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    font-family: 'Inter', sans-serif;
    color: #333;
}
.cd-header h2 {
    font-size: 1.25rem;
    color: #4a5568;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.cd-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.cd-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    color: white;
    transition: transform 0.2s;
}
.cd-btn:hover { transform: translateY(-2px); }
.cd-btn-yellow { background-color: #f6ad55; color: #2d3748; }
.cd-btn-green { background-color: #68d391; color: #2d3748; }
.cd-btn-red { background-color: #fc8181; }
.cd-btn-pink { background-color: #f687b3; padding: 0.25rem 0.75rem; font-size: 0.8rem;}

.cd-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.cd-stat-card {
    background: #f7fafc;
    border-radius: 8px;
    padding: 1rem;
}
.cd-stat-card h3 {
    font-size: 0.95rem;
    color: #2d3748;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.25rem;
}
.cd-stat-card p {
    font-size: 0.85rem;
    color: #4a5568;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
}
.cd-text-green { color: #38a169; font-weight: bold; }
.cd-text-red { color: #e53e3e; font-weight: bold; }
.cd-text-blue { color: #3182ce; font-weight: bold; }
.cd-ttl-control {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.cd-ttl-control input {
    width: 60px;
    padding: 0.25rem;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
}

.cd-cached-items {
    background: #2d3748;
    border-radius: 8px;
    padding: 1rem;
    color: white;
    margin-bottom: 1rem;
}
.cd-cached-items h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
    color: #e2e8f0;
}
.cd-keys-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.cd-key-tag {
    background: #4a5568;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}
.cd-key-tag:hover { background: #718096; }
.cd-key-tag.active { background: #667eea; }
.cd-terminal {
    background: #1a202c;
    padding: 1rem;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.85rem;
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
    color: #a0aec0;
}
.cd-status {
    font-size: 0.85rem;
    color: #718096;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .breed-list {
        columns: 1;
    }

    .container {
        padding: 0.5rem;
    }

    .control-panel, .results-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.75rem;
    }

    .hero p {
        font-size: 1rem;
    }
}

/* Comparison View Styles */
.comparison-view {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.comparison-title {
    text-align: center;
    margin-bottom: 2rem;
    color: #4a5568;
}

.comparison-container {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 1rem;
}

.breed-card {
    flex: 1;
    min-width: 300px;
    max-width: 400px;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.breed-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.breed-image {
    width: 100%;
    height: 250px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
}

.breed-image img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    padding: 10px;
    box-sizing: border-box;
}

.breed-info {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.breed-info h3 {
    margin: 0 0 1rem 0;
    color: #2d3748;
    font-size: 1.5rem;
}

.breed-info p {
    margin: 0.5rem 0;
    color: #4a5568;
    line-height: 1.5;
}

.breed-info strong {
    color: #2d3748;
}

/* VS circle styling */
.vs-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: #9f7aea;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2rem;
    margin: 0;
    align-self: center;
    flex-shrink: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .comparison-container {
        flex-direction: column;
        align-items: center;
    }
    
    .vs-circle {
        margin: 20px 0;
        transform: rotate(90deg);
    }
    
    .breed-card {
        width: 100%;
        max-width: 100%;
    }
}

/* Breed Details View (for single breed) */
.breed-details {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

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

.breed-header h2 {
    color: #2d3748;
    margin-bottom: 0.5rem;
}

.breed-header .origin {
    color: #6b7280;
    font-size: 1.1rem;
}

.breed-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Image container for single breed view */
.breed-details .breed-image-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background-color: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.breed-details .breed-main-image {
    width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 4px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .breed-details .breed-image-container {
        padding: 15px;
    }
    
    .breed-details .breed-main-image {
        max-height: 400px;
    }
}

/* Comparison View Breed Cards */


.breed-image-container {
    position: relative;
    width: 100%;
    max-width: 700px;
    margin: 20px auto;
    background-color: #f8f9fa;
    border-radius: 8px;
    min-height: 300px; /* Ensure minimum height */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.breed-image {
    width: 100%;
    height: auto;
    max-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.breed-image img {
    max-width: 100%;
    max-height: 500px;
    width: auto;
    height: auto;
    object-fit: contain;
    object-position: center;
    border-radius: 4px;
}

.breed-info {
    padding: 20px;
}

.vs-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: #9f7aea;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2rem;
    margin: 0 20px;
    align-self: center;
}

@media (max-width: 768px) {
    .comparison-container {
        flex-direction: column;
        align-items: center;
    }
    
    .vs-circle {
        margin: 20px 0;
        transform: rotate(90deg);
    }
}

/* Favorites Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 900px;
    width: 85%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.modal.show .modal-content {
    transform: translateY(0);
    opacity: 1;
}

.modal h2 {
    color: #2d3748;
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.8rem;
    padding: 0 2rem;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 32px;
    font-weight: bold;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    line-height: 1;
}

.close:hover {
    color: #2d3748;
    background-color: #f3f4f6;
    transform: rotate(90deg);
}

.favorites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 25px;
    margin-top: 20px;
    padding: 10px;
}

.favorite-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    background: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.favorite-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.favorite-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.favorite-item:hover img {
    transform: scale(1.03);
}

.remove-favorite {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(220, 38, 38, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.favorite-item:hover .remove-favorite {
    opacity: 1;
    transform: scale(1);
}

.remove-favorite:hover {
    background: #dc2626;
    transform: scale(1.1) !important;
}

.favorite-info {
    padding: 15px;
    text-align: center;
    background: white;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.favorite-info h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #2d3748;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
}

/* Empty state */
.favorites-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #6b7280;
    grid-column: 1 / -1;
}

.favorites-empty p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.favorites-empty .emoji {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 1rem;
}

/* Scrollbar styling */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .modal-content {
        width: 90%;
        padding: 25px;
    }
    
    .favorites-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .modal-content {
        width: 92%;
        margin: 8% auto;
        padding: 20px;
    }
    
    .modal h2 {
        font-size: 1.5rem;
        margin-bottom: 1.2rem;
    }
    
    .favorites-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
    }
    
    .favorite-item img {
        height: 160px;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 12% auto;
        padding: 15px;
    }
    
    .favorites-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .favorite-item img {
        height: 140px;
    }
    
    .favorite-info h3 {
        font-size: 1rem;
    }
    
    .close {
        right: 10px;
        top: 10px;
        font-size: 28px;
    }
}