/* Ninja Speedi KI - Mobile-First Styles */

:root {
    --primary: #e63946;
    --primary-dark: #c1121f;
    --secondary: #457b9d;
    --background: #1a1a2e;
    --surface: #16213e;
    --surface-light: #1f2b4a;
    --text: #f1faee;
    --text-muted: #a8b2c1;
    --success: #2a9d8f;
    --error: #e63946;
    --warning: #e9c46a;
    --border-radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* Container */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Login Card */
.login-card {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 30px 24px;
    box-shadow: var(--shadow);
    margin-top: 10vh;
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 5px;
}

.tagline {
    color: var(--text-muted);
    font-size: 14px;
}

/* Forms */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    background: var(--background);
    color: var(--text);
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    text-decoration: none;
}

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

.btn-primary:hover,
.btn-primary:active {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text);
    border: 2px solid var(--secondary);
}

.btn-secondary:hover {
    background: var(--secondary);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Switch Mode */
.switch-mode {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.switch-mode a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: rgba(230, 57, 70, 0.15);
    border: 1px solid var(--error);
    color: #ff6b6b;
}

.alert-success {
    background: rgba(42, 157, 143, 0.15);
    border: 1px solid var(--success);
    color: #6bccc2;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--surface-light);
}

.dashboard-header h1 {
    font-size: 20px;
}

.logout-btn {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
}

.welcome-msg {
    color: var(--text-muted);
    margin-bottom: 30px;
}

/* Scan Buttons */
.scan-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 30px;
}

.scan-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--surface);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.scan-btn:hover,
.scan-btn:active {
    background: var(--surface-light);
    transform: translateY(-2px);
}

.scan-btn .icon {
    font-size: 36px;
}

.scan-btn .text h3 {
    font-size: 16px;
    margin-bottom: 4px;
}

.scan-btn .text p {
    font-size: 13px;
    color: var(--text-muted);
}

/* Camera / Upload Page */
.scan-container {
    text-align: center;
}

.scan-container h2 {
    margin-bottom: 10px;
}

.scan-container .subtitle {
    color: var(--text-muted);
    margin-bottom: 30px;
}

.camera-area {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 40px 20px;
    margin-bottom: 20px;
    border: 2px dashed var(--surface-light);
    transition: border-color 0.2s;
}

.camera-area.dragover {
    border-color: var(--primary);
}

.camera-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.camera-area p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

#preview {
    max-width: 100%;
    border-radius: var(--border-radius);
    display: none;
    margin-bottom: 20px;
}

#preview.visible {
    display: block;
}

.camera-input {
    display: none;
}

.upload-options {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.upload-options .btn {
    flex: 1;
}

/* Loading Spinner */
.loading {
    display: none;
    text-align: center;
    padding: 40px;
}

.loading.active {
    display: block;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--surface-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Ingredients List */
.ingredients-container {
    background: var(--surface);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-top: 20px;
}

.ingredients-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.ingredients-header h3 {
    font-size: 18px;
}

.ingredient-count {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.ingredient-list {
    list-style: none;
}

.ingredient-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--surface-light);
}

.ingredient-item:last-child {
    border-bottom: none;
}

.ingredient-checkbox {
    width: 22px;
    height: 22px;
    margin-right: 12px;
    accent-color: var(--primary);
}

.ingredient-name {
    flex: 1;
    font-size: 15px;
}

.ingredient-category {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--surface-light);
    color: var(--text-muted);
    text-transform: uppercase;
}

.ingredient-category.base { background: #3d5a80; color: white; }
.ingredient-category.protein { background: #9d4edd; color: white; }
.ingredient-category.vegetable { background: #2a9d8f; color: white; }
.ingredient-category.seasoning { background: #e9c46a; color: #1a1a2e; }
.ingredient-category.topping { background: #f4a261; color: #1a1a2e; }

/* Add Ingredient */
.add-ingredient {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--surface-light);
}

.add-ingredient input {
    flex: 1;
    padding: 12px;
    font-size: 14px;
    border: 2px solid var(--surface-light);
    border-radius: var(--border-radius);
    background: var(--background);
    color: var(--text);
}

.add-ingredient button {
    padding: 12px 20px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
}

/* Back Link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 20px;
    font-size: 14px;
}

.back-link:hover {
    color: var(--text);
}

/* Recent Scans */
.recent-scans {
    margin-top: 30px;
}

.recent-scans h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.scan-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--surface);
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    text-decoration: none;
    color: var(--text);
}

.scan-item .scan-icon {
    font-size: 24px;
}

.scan-item .scan-info {
    flex: 1;
}

.scan-item .scan-info .date {
    font-size: 12px;
    color: var(--text-muted);
}

.scan-item .scan-count {
    color: var(--text-muted);
    font-size: 14px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Mobile optimizations */
@media (max-width: 380px) {
    .container {
        padding: 16px;
    }

    .login-card {
        padding: 24px 20px;
        margin-top: 5vh;
    }

    .logo h1 {
        font-size: 22px;
    }
}

/* PWA Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--surface);
    padding: 16px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: none;
    z-index: 1000;
}

.install-prompt.visible {
    display: flex;
    align-items: center;
    gap: 12px;
}

.install-prompt p {
    flex: 1;
    font-size: 14px;
}

.install-prompt button {
    padding: 10px 16px;
    font-size: 14px;
}

/* Safe Area for iPhone */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}
