:root {
    --bg-dark: #3A2525;
    --card-bg: rgba(20, 10, 10, 0.65);
    --primary-accent: #9E2A3A;
    --primary-accent-hover: #FF0000;
    --secondary-accent: #000080;
    --text-main: #f0f4f8;
    --text-muted: #d0c0c0;
    --border-color: rgba(255, 255, 255, 0.08);
}

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

body {
    font-family: 'Outfit', -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Background Blobs for Glassmorphism Context */
.blob-wrapper {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    overflow: hidden;
    z-index: -1;
    pointer-events: none;
}
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 20s infinite ease-in-out;
}
.blob1 {
    top: -10%; left: -10%;
    width: 500px; height: 500px;
    background: radial-gradient(circle, var(--primary-accent), transparent 70%);
    animation-delay: 0s;
}
.blob2 {
    bottom: -20%; right: -10%;
    width: 600px; height: 600px;
    background: radial-gradient(circle, var(--secondary-accent), transparent 70%);
    animation-delay: -5s;
}
.blob3 {
    top: 40%; left: 40%;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(255, 0, 0, 0.3), transparent 70%);
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -50px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

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

h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.accent {
    background: linear-gradient(135deg, #FF0000, #9E2A3A);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Glass Panels */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Upload Section */
.upload-section {
    max-width: 600px;
    margin: 0 auto 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.upload-area {
    width: 100%;
    height: 250px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
    background: rgba(0,0,0,0.2);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary-accent);
    background: rgba(158, 42, 58, 0.1);
}

.upload-content {
    text-align: center;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.upload-area:hover .upload-icon {
    color: var(--primary-accent);
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
}

.upload-hint {
    font-size: 0.85rem;
    color: #718096;
}

#imagePreview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    position: absolute;
    top: 0; left: 0;
}

.hidden {
    display: none !important;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 1rem;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
}

/* Button */
.btn {
    padding: 0.8rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    outline: none;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    color: white;
    box-shadow: 0 4px 15px rgba(158, 42, 58, 0.4);
    min-width: 220px;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(158, 42, 58, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--border-color);
    min-width: 180px;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
}

.close-modal {
    background: rgba(255,255,255,0.05);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-modal:hover {
    background: var(--primary-accent);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

/* Category Tabs */
.tab-scroller {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-transform: capitalize;
}

.tab-btn:hover {
    color: white;
}

.tab-btn.active {
    color: white;
    background: var(--primary-accent);
}

/* Sample Grid */
.sample-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1.5rem;
}

.sample-item {
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.sample-item:hover {
    transform: scale(1.05);
    border-color: var(--primary-accent);
}

.sample-item img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
}

.sample-name {
    padding: 0.5rem;
    font-size: 0.75rem;
    text-align: center;
    color: var(--text-muted);
    background: rgba(15,15,15,0.8);
}

/* Results section */
.results-container {
    animation: fadeIn 0.8s ease forwards;
}

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

.prediction-panel {
    text-align: center;
    margin-bottom: 3rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    background: rgba(158, 42, 58, 0.15);
    border-color: rgba(158, 42, 58, 0.3);
}

.sub-title {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 1rem;
}

.pred-details {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2rem;
}

.pred-class-wrapper, .pred-conf-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.value {
    font-size: 2rem;
    font-weight: 800;
}

.primary-value {
    color: #FF0000;
    text-transform: capitalize;
}

/* Output grid */
.maps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.map-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
}

.map-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    border-color: rgba(255,255,255,0.15);
}

.map-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e2e8f0;
}

.image-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border-color);
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Download Button Styles */
.download-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
}

.download-btn:hover {
    background: var(--primary-accent);
    color: white;
    border-color: var(--primary-accent);
    transform: translateY(-1px);
}

.download-btn svg {
    width: 14px;
    height: 14px;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }
    .maps-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}
