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

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

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

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

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

.logo-icon {
    width: 48px;
    height: 48px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0;
}

.subtitle {
    font-size: 1.125rem;
    opacity: 0.9;
    font-weight: 300;
}

.main-content {
    background: var(--bg-primary);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: var(--shadow-xl);
    min-height: 500px;
}

.upload-section {
    max-width: 600px;
    margin: 0 auto;
}

.upload-card {
    border: 3px dashed var(--border-color);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-card:hover {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
}

.upload-card.drag-over {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    transform: scale(1.02);
}

.upload-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    color: var(--primary-color);
}

.upload-icon svg {
    width: 100%;
    height: 100%;
}

.upload-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-description {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-formats {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary svg {
    width: 20px;
    height: 20px;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
}

.btn-secondary svg {
    width: 18px;
    height: 18px;
}

.file-info {
    margin-top: 2rem;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 1rem;
}

.file-icon {
    width: 40px;
    height: 40px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.file-text {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.btn-remove {
    background: transparent;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.1);
}

.btn-remove svg {
    width: 20px;
    height: 20px;
}

.btn-analyze {
    width: 100%;
    background: linear-gradient(135deg, var(--success-color), #059669);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
}

.btn-analyze:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-analyze svg {
    width: 20px;
    height: 20px;
}

.loading-section {
    text-align: center;
    padding: 4rem 2rem;
}

.loading-spinner {
    width: 64px;
    height: 64px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 2rem;
}

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

.loading-section h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.loading-section p {
    color: var(--text-secondary);
}

.results-section {
    animation: fadeIn 0.5s ease;
}

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

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-size: 2rem;
    color: var(--text-primary);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.result-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.card-header svg {
    width: 24px;
    height: 24px;
    color: var(--primary-color);
}

.card-header h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.diagnosis-card {
    grid-column: 1 / -1;
}

.diagnosis-text {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.severity-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.severity-badge.low {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.severity-badge.medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.severity-badge.high {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.info-card {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
}

.info-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.info-content h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.info-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.error-section {
    text-align: center;
    padding: 4rem 2rem;
}

.error-card {
    max-width: 500px;
    margin: 0 auto;
}

.error-icon {
    width: 64px;
    height: 64px;
    color: var(--danger-color);
    margin: 0 auto 1.5rem;
}

.error-section h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.error-section p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    color: white;
}

.footer p {
    margin: 0.5rem 0;
    opacity: 0.9;
}

.footer-contact a {
    color: white;
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.footer-contact a:hover {
    opacity: 0.8;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

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

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

    .upload-card {
        padding: 2rem 1rem;
    }

    .upload-icon {
        width: 60px;
        height: 60px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-header h2 {
        font-size: 1.5rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .file-details {
        flex-wrap: wrap;
    }
}

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

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .subtitle {
        font-size: 1rem;
    }

    .main-content {
        padding: 1.5rem 1rem;
    }

    .btn-primary,
    .btn-analyze {
        padding: 0.75rem 1.5rem;
        font-size: 0.875rem;
    }
}

/* ===========================
   Authentifizierung & Benutzer-UI
   =========================== */

.auth-section {
    max-width: 450px;
    margin: 0 auto;
}

.auth-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.auth-form {
    display: none;
}

.auth-form.active,
.auth-form:first-of-type {
    display: block;
}

.auth-form h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.auth-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.auth-form input {
    width: 100%;
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-error {
    padding: 0.875rem 1rem;
    margin-bottom: 1rem;
    background: #fee;
    border: 1px solid var(--danger-color);
    border-radius: 8px;
    color: var(--danger-color);
    font-size: 0.875rem;
}

.user-menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.btn-logout {
    padding: 0.5rem 1rem;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

/* ===========================
   Tabs & Navigation
   =========================== */

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border-color);
}

.tab {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===========================
   Scan-Verlauf
   =========================== */

.history-content {
    display: none;
}

.scans-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.scan-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.scan-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

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

.scan-header h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin: 0;
}

.scan-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.scan-detail {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
}

.loading-text,
.no-scans,
.error-text {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.no-scans {
    color: var(--text-primary);
}

.error-text {
    color: var(--danger-color);
}

/* ===========================
   Responsive Updates
   =========================== */

@media (max-width: 768px) {
    .auth-section {
        max-width: 100%;
    }

    .user-menu {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .tabs {
        flex-direction: column;
    }

    .tab {
        border-bottom: 1px solid var(--border-color);
        border-left: 3px solid transparent;
    }

    .tab.active {
        border-bottom-color: var(--border-color);
        border-left-color: var(--primary-color);
    }

    .scan-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .scan-details {
        grid-template-columns: 1fr;
    }
}

/* ===========================
   Enhanced Mobile Responsiveness for PWA
   =========================== */

@media (max-width: 768px) {
    body {
        font-size: 16px;
    }

    .container {
        padding: 1rem 0.75rem;
    }

    .header {
        margin-bottom: 2rem;
    }

    .logo {
        gap: 0.75rem;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .main-content {
        border-radius: 16px;
        padding: 1.5rem 1rem;
    }

    .btn-primary,
    .btn-analyze {
        min-height: 48px;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        justify-content: center;
    }

    .btn-secondary {
        min-height: 44px;
        padding: 0.75rem 1.25rem;
        width: 100%;
        justify-content: center;
    }

    .upload-card {
        padding: 2rem 1rem;
        border-width: 2px;
    }

    .upload-icon {
        width: 64px;
        height: 64px;
    }

    .upload-card h2 {
        font-size: 1.25rem;
    }

    .file-details {
        padding: 1.25rem;
        flex-wrap: nowrap;
    }

    .file-name {
        font-size: 0.9375rem;
    }

    .file-size {
        font-size: 0.8125rem;
    }

    .btn-remove {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .results-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .results-header h2 {
        font-size: 1.5rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .result-card {
        padding: 1.5rem;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .metric-value {
        font-size: 1.25rem;
    }

    .info-card {
        padding: 1.25rem;
        flex-direction: column;
        gap: 0.75rem;
    }

    .auth-tabs {
        gap: 0;
    }

    .auth-tab {
        padding: 0.875rem;
        font-size: 0.9375rem;
    }

    .auth-form h2 {
        font-size: 1.5rem;
    }

    .auth-form input {
        padding: 0.875rem;
        font-size: 1rem;
        min-height: 48px;
    }

    .tabs {
        gap: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab {
        padding: 0.875rem 1.25rem;
        white-space: nowrap;
        font-size: 0.9375rem;
    }

    .footer {
        margin-top: 2rem;
        padding-top: 1.5rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem 0.5rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .subtitle {
        font-size: 0.9375rem;
    }

    .main-content {
        padding: 1.25rem 0.875rem;
        border-radius: 12px;
    }

    .upload-card {
        padding: 1.5rem 0.875rem;
    }

    .upload-icon {
        width: 56px;
        height: 56px;
    }

    .upload-card h2 {
        font-size: 1.125rem;
    }

    .upload-description {
        font-size: 0.875rem;
    }

    .upload-formats {
        font-size: 0.8125rem;
    }

    .btn-primary,
    .btn-analyze {
        padding: 0.875rem 1.25rem;
        font-size: 0.9375rem;
    }

    .file-details {
        padding: 1rem;
    }

    .file-icon {
        width: 32px;
        height: 32px;
    }

    .result-card {
        padding: 1.25rem;
    }

    .card-header h3 {
        font-size: 1.125rem;
    }

    .diagnosis-text {
        font-size: 1rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }

    .metric-label {
        font-size: 0.8125rem;
    }

    .metric-value {
        font-size: 1.125rem;
    }

    .info-card {
        padding: 1rem;
    }

    .info-content h4 {
        font-size: 0.9375rem;
    }

    .info-content p {
        font-size: 0.8125rem;
    }

    .loading-spinner {
        width: 48px;
        height: 48px;
    }

    .loading-section h3 {
        font-size: 1.25rem;
    }

    .error-icon {
        width: 48px;
        height: 48px;
    }

    .error-section h3 {
        font-size: 1.25rem;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .btn-primary,
    .btn-secondary,
    .btn-analyze,
    .btn-remove,
    .btn-logout,
    .auth-tab,
    .tab {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .upload-card {
        cursor: default;
    }

    .btn-primary:active,
    .btn-analyze:active {
        transform: scale(0.98);
    }

    .btn-secondary:active,
    .btn-remove:active {
        transform: scale(0.95);
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        margin-bottom: 1.5rem;
    }

    .main-content {
        padding: 1.5rem;
    }

    .upload-card {
        padding: 1.5rem;
    }

    .upload-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 1rem;
    }

    .loading-section {
        padding: 2rem 1rem;
    }

    .error-section {
        padding: 2rem 1rem;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }

    .main-content {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }
}

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Smooth scrolling for mobile */
html {
    scroll-behavior: smooth;
}

/* Optimize for mobile performance */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent pull-to-refresh on mobile */
body {
    overscroll-behavior-y: contain;
}
