:root {
    --bg-base: #0f172a;
    --bg-surface: rgba(30, 41, 59, 0.7);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #8b5cf6;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --danger: #ef4444;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Background animated gradient */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.15) 0%, rgba(139, 92, 246, 0.1) 30%, transparent 60%);
    animation: rotate 60s linear infinite;
    z-index: -1;
}

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

.app-container {
    display: flex;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    gap: 2rem;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Sidebar */
.sidebar {
    width: 320px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: fit-content;
    position: sticky;
    top: 2rem;
}

.logo-area h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.highlight {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Custom Select */
select {
    width: 100%;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 10px;
    font-size: 1rem;
    appearance: none;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Device Toggle */
.device-toggle {
    display: flex;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.device-toggle input[type="radio"] {
    display: none;
}

.device-toggle label {
    flex: 1;
    text-align: center;
    padding: 0.75rem 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.3s ease, color 0.3s;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
}

.device-toggle input[type="radio"]:checked + label {
    background: var(--primary);
    color: white;
}

/* Upload Area */
.hidden-input {
    display: none;
}

.upload-area {
    margin-top: 1rem;
    border: 2px dashed var(--border);
    border-radius: 15px;
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(0,0,0,0.2);
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

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

.upload-content svg {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.browse-link {
    color: var(--primary);
    text-decoration: underline;
}

.file-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px var(--accent);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-muted);
}

/* Status */
.status-box {
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.status-success {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.status-error {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.main-header {
    padding: 1.5rem 2rem;
}

.main-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.main-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 2rem;
    width: 100%;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    text-align: center;
}

.floating-orb {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    filter: blur(20px);
    animation: float 4s ease-in-out infinite;
    margin-bottom: 2rem;
    opacity: 0.6;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* Result Card */
.result-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 15px;
    overflow: hidden;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
}

.result-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255,255,255,0.2);
}

.result-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-comparison {
    display: flex;
    position: relative;
    height: 300px;
    background: #000;
}

.image-comparison > div {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.image-comparison img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.6);
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

/* Loader */
.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

.hidden {
    display: none !important;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        position: relative;
        top: 0;
    }
}

/* Download button for Individual Cards */
.download-btn {
    width: 100%;
    padding: 0.75rem;
    background: rgba(16, 185, 129, 0.15);
    border: none;
    border-top: 1px solid var(--border);
    color: var(--success);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.download-btn:hover {
    background: var(--success);
    color: white;
}

/* Performance Monitor */
.perf-monitor {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 1rem 2rem;
    transition: opacity 0.5s ease;
}

.perf-stat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 25%;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.bar-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 1s ease, background-color 0.5s ease;
}

.stat-val {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    align-self: flex-end;
}
