@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette - Vibrant & Premium */
    --primary-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --bg-primary: #050505;
    --bg-secondary: #0f0f12;
    --bg-card: rgba(15, 15, 18, 0.7);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-tertiary: #6b6b7b;
    --border-color: rgba(255, 255, 255, 0.08);
    --glow-color: rgba(79, 172, 254, 0.4);

    --radius-lg: 16px;
    --radius-xl: 24px;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Gradients */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 10% 20%, rgba(79, 172, 254, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 242, 254, 0.1) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* Header & Logo */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo h1 span {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 300;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    opacity: 0.8;
}

/* Upload Area */
.upload-area {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    text-align: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.upload-area:hover {
    border-color: #4facfe;
    background: rgba(15, 15, 18, 0.8);
    transform: translateY(-4px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 20px var(--glow-color);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1.5rem;
    color: #4facfe;
}

/* Buttons */
.btn-primary {
    background: var(--primary-gradient);
    color: #000;
    font-weight: 600;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px var(--glow-color);
}

/* Library Header */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

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

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-tertiary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.25rem;
    border-radius: 12px;
    font-size: 0.825rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-refresh:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-refresh svg {
    opacity: 0.5;
}

.btn-refresh:hover svg {
    opacity: 1;
}

/* Library Grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.library-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.3s ease;
}

.library-item:hover {
    transform: translateY(-4px);
    border-color: rgba(79, 172, 254, 0.5);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.library-item-preview {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg-secondary);
}

.library-item-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.library-item:hover .library-item-preview img {
    transform: scale(1.05);
}

.library-item-info {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

.library-item-info p {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 0;
}

.library-item-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
}

.library-item-actions button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem;
    font-size: 0.7rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.library-item-actions button:hover {
    background: rgba(79, 172, 254, 0.15);
    border-color: rgba(79, 172, 254, 0.4);
    color: var(--text-primary);
}

.library-item-actions button svg {
    width: 14px;
    height: 14px;
}

.btn-delete:hover {
    background: rgba(255, 82, 82, 0.15) !important;
    border-color: rgba(255, 82, 82, 0.4) !important;
    color: #ff5252 !important;
}

/* Empty Library State */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-tertiary);
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state p {
    margin: 0.25rem 0;
}

.empty-subtitle {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Viewer Modal Styling */
.viewer-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-blur {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
}

.viewer-container {
    position: relative;
    width: 95%;
    height: 90%;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.viewer-canvas-container {
    flex: 1;
}

.badge {
    background: var(--primary-gradient);
    color: #000;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.btn-close-viewer {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.6;
}

.btn-close-viewer:hover {
    opacity: 1;
}

.hidden {
    display: none !important;
}

/* ============================================
   Material Design Components
   ============================================ */

/* FAB Settings Button */
.fab-settings {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary-gradient);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
    transition: all 0.3s ease;
    z-index: 100;
}

.fab-settings:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.6);
}

/* Model Status Chip */
.model-status-chip {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.model-status-chip .material-icons {
    font-size: 16px;
}

/* Settings Overlay */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
}

/* Settings Drawer */
.settings-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 201;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

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

.drawer-header h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 500;
}

.drawer-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.setting-section {
    margin-bottom: 2rem;
}

.setting-section h4 {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    margin-bottom: 1rem;
}

/* Radio Options */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option:hover {
    border-color: rgba(79, 172, 254, 0.5);
    background: rgba(79, 172, 254, 0.1);
}

.radio-option input[type="radio"] {
    accent-color: #4facfe;
    width: 18px;
    height: 18px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.radio-label .material-icons {
    font-size: 18px;
    color: var(--text-secondary);
}

/* Button Styles */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.btn-outlined {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-outlined:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.button-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Status Info */
.status-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.status-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

.status-row span:first-child {
    color: var(--text-tertiary);
}

.status-row span:last-child {
    color: var(--text-primary);
}

/* Snackbar */
.snackbar {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    background: #323232;
    color: white;
    border-radius: 8px;
    font-size: 0.875rem;
    z-index: 300;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.snackbar-action {
    background: none;
    border: none;
    color: #4facfe;
    font-weight: 500;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* Progress Loader */
.model-progress {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
}

.progress-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.progress-content .material-icons {
    font-size: 48px;
    color: #4facfe;
}

.progress-content .spinning {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.progress-text {
    font-size: 1.125rem;
    color: var(--text-primary);
}

.progress-bar {
    width: 300px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary-gradient);
    transition: width 0.3s ease;
}

.progress-percent {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Model Download UI */
.model-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
    margin-bottom: 1rem;
    color: #ffc107;
    font-size: 0.875rem;
}

.model-banner.success {
    background: rgba(76, 175, 80, 0.15);
    border-color: rgba(76, 175, 80, 0.3);
    color: #4caf50;
}

.model-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-download-model {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.btn-download-model:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.option-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.option-divider::before,
.option-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.help-text {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    line-height: 1.5;
}

/* Result Preview Image - Responsive */
#previewImage {
    max-width: 100%;
    max-height: 50vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-lg);
    margin: 0 auto;
    display: block;
}

#resultSection {
    max-width: 800px;
    margin: 0 auto;
}

.result-actions {
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* Server Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-online {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.4);
}

.status-offline {
    background: rgba(255, 82, 82, 0.2);
    color: #ff5252;
    border: 1px solid rgba(255, 82, 82, 0.4);
}

.status-checking {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.4);
}

/* Fix library buttons overflow */
.library-item-actions {
    overflow: hidden;
}

.library-item-actions button {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Setup script download links */
.setting-section a.btn-outlined {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}