@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #5865F2;
    --primary-light: #7983F5;
    --primary-dark: #4752C4;
    --success: #3BA55C;
    --warning: #FAA61A;
    --danger: #ED4245;
    --background: #FFFFFF;
    --surface: #F9FAFB;
    --surface-hover: #F3F4F6;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;
    --border: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--surface);
    min-height: 100vh;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--background);
    position: relative;
    box-shadow: var(--shadow-xl);
}

.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header */
.header {
    background: var(--background);
    padding: 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.header-button {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--surface);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.header-button:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Dashboard */
.dashboard-content {
    padding: 24px 20px;
}

.welcome-section {
    margin-bottom: 32px;
}

.welcome-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.welcome-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.device-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--surface);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Quick Actions */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.action-button {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover {
    background: var(--surface);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.action-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 14px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.action-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Recent Activity */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.activity-card:hover {
    background: var(--surface);
    box-shadow: var(--shadow);
}

.activity-icon {
    width: 44px;
    height: 44px;
    background: var(--surface);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.activity-info {
    flex: 1;
}

.activity-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.activity-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.activity-status {
    padding: 4px 10px;
    background: var(--surface);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-success {
    background: rgba(59, 165, 92, 0.1);
    color: var(--success);
}

.status-processing {
    background: rgba(88, 101, 242, 0.1);
    color: var(--primary);
}

/* Video Scan Screen */
.scan-container {
    padding: 24px 20px;
}

.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 20px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--background);
}

.upload-area.active {
    background: rgba(88, 101, 242, 0.05);
    border-color: var(--primary);
}

.upload-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 20px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.upload-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-formats {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.format-tag {
    padding: 4px 10px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="file"] {
    display: none;
}

/* Video Preview */
.video-preview {
    margin-top: 24px;
    border-radius: 20px;
    overflow: hidden;
    background: black;
    display: none;
}

.video-preview.active {
    display: block;
}

.video-element {
    width: 100%;
    height: 240px;
    object-fit: cover;
}

/* Frame Extraction */
.extraction-section {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    margin-top: 24px;
    display: none;
}

.extraction-section.active {
    display: block;
}

.extraction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.extraction-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.extraction-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--surface);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.frames-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.frame-thumbnail {
    aspect-ratio: 16/9;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.frame-thumbnail:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.frame-thumbnail.selected {
    border-color: var(--primary);
    background: rgba(88, 101, 242, 0.05);
}

.frame-label {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
}

/* AI Analysis Section */
.ai-section {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    margin-top: 24px;
    display: none;
}

.ai-section.active {
    display: block;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.ai-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #10B981, #059669);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 20px;
}

.ai-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ai-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.analysis-options {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-item:hover {
    background: var(--surface-hover);
}

.option-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.option-item.selected .option-checkbox {
    background: var(--primary);
    border-color: var(--primary);
}

.option-item.selected .option-checkbox::after {
    content: '✓';
    color: white;
    font-size: 12px;
}

.option-text h4 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.option-text p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Buttons */
.button-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.button-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.button-primary:active {
    transform: scale(0.98);
}

/* Results */
.results-section {
    padding: 24px 20px;
    display: none;
}

.results-section.active {
    display: block;
}

.result-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.result-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.result-location {
    font-size: 13px;
    color: var(--text-secondary);
}

.confidence-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.confidence-high {
    background: rgba(59, 165, 92, 0.1);
    color: var(--success);
}

.confidence-medium {
    background: rgba(250, 166, 26, 0.1);
    color: var(--warning);
}

.result-description {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.frame-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.frame-tag {
    padding: 4px 10px;
    background: var(--surface);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: var(--background);
    border-top: 1px solid var(--border);
    padding: 12px 0;
    display: flex;
    justify-content: space-around;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 10px;
}

.nav-item:hover {
    background: var(--surface);
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 20px;
    margin-bottom: 4px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* Toast */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--text-primary);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 430px) {
    .app-container {
        max-width: 100%;
        box-shadow: none;
    }
}

.header-content {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
}