:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-hover: #334155;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);

    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-4: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);

    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animowane tło */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Header */
.header {
    padding: 2rem 0;
    border-bottom: 1px solid var(--border);
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo img {
    height: 80px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
    transition: var(--transition);
}

.logo img:hover {
    filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.5));
    transform: scale(1.05);
}

.logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.nav-link.active {
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.1);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1.5rem;
    right: 1.5rem;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
}

.nav-user {
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-logout {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.nav-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}


/* Main Content */
.main-content {
    padding: 3rem 0;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px var(--shadow);
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 60px var(--shadow);
}

.card-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* QR Section */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    border: 2px dashed var(--border);
}

.qr-code-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    min-height: 200px;
    justify-content: center;
}

.qr-image {
    max-width: 250px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.5s ease;
}

.server-url {
    font-family: 'Courier New', monospace;
    color: var(--primary-light);
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px var(--shadow);
}

.stat-card:hover::before {
    opacity: 0.1;
}

.stat-calories::before {
    background: var(--gradient-2);
}

.stat-protein::before {
    background: var(--gradient-1);
}

.stat-carbs::before {
    background: var(--gradient-4);
}

.stat-fats::before {
    background: var(--gradient-3);
}

.stat-icon {
    font-size: 3rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.stat-content {
    flex: 1;
    position: relative;
    z-index: 1;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Meals Grid */
.meals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.meal-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.meal-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px var(--shadow);
    border-color: var(--primary);
}

.meal-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
}

.meal-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.meal-card:hover .meal-image img {
    transform: scale(1.05);
}

.meal-content {
    padding: 1.5rem;
}

.meal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.meal-time {
    color: var(--primary-light);
    font-size: 0.875rem;
    font-weight: 500;
}

.meal-type-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.meal-type-badge:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.meal-type-badge.śniadanie {
    background: rgba(251, 146, 60, 0.2);
    color: #fb923c;
    border: 1px solid #fb923c;
}

.meal-type-badge.obiad {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid #3b82f6;
}

.meal-type-badge.kolacja {
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    border: 1px solid #a855f7;
}

.meal-type-badge.przekąska {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid #22c55e;
}

.meal-type-badge.inne {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
    border: 1px solid #94a3b8;
}

.meal-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.meal-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.meal-stat {
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.meal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.btn-icon {
    flex: 1;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.btn-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-edit:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: var(--primary-light);
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-recalc:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
    color: var(--success);
}

.loading-inline {
    text-align: center;
    padding: 0.75rem;
    color: var(--primary-light);
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

/* Upload Area */
.upload-area {
    border: 3px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-label {
    cursor: pointer;
    display: block;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.3));
}

.upload-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Preview Area */
.preview-area {
    text-align: center;
}

.preview-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    box-shadow: 0 10px 40px var(--shadow);
}

/* Loading */
.loading-area {
    text-align: center;
    padding: 3rem;
}

.spinner,
.spinner-large {
    border: 4px solid rgba(99, 102, 241, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

.loading-text {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.loading-subtext {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    padding: 0.875rem 2rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Questions Section */
.question-area {
    margin: 2rem 0;
}

.question-box {
    background: rgba(99, 102, 241, 0.1);
    padding: 2rem;
    border-radius: var(--radius-md);
    border: 2px solid var(--primary);
}

.question-text {
    font-size: 1.125rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.answer-input {
    width: 100%;
    padding: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 1rem;
    font-family: inherit;
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.question-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.question-buttons .btn {
    flex: 1;
    min-width: 150px;
}

.question-hint {
    margin-top: 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-style: italic;
    text-align: center;
}

/* Results */
.result-image-container {
    text-align: center;
    margin-bottom: 2rem;
}

.result-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 40px var(--shadow);
}

.result-description {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    text-align: center;
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
}

.result-stat-icon {
    font-size: 2.5rem;
}

.result-stat-value {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.result-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Date Selector */
.date-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.date-label {
    font-weight: 500;
}

.date-select {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 200px;
}

.date-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Animations */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    /* Header mobile */
    .header {
        padding: 0;
    }

    .header-banner {
        max-height: 100px;
    }

    .header-content {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .logo {
        font-size: 1.25rem;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    /* Nawigacja mobile */
    .nav {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* Firefox */
        -ms-overflow-style: none;
        /* IE/Edge */
    }

    .nav::-webkit-scrollbar {
        display: none;
        /* Chrome/Safari */
    }

    .nav-link {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Main content - dodaj padding aby header nie zasłaniał */
    .main-content {
        padding: 2rem 0 2rem 0;
        scroll-margin-top: 80px;
        /* Uwzględnij wysokość headera */
    }

    .card {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }

    .card-title {
        font-size: 1.25rem;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-icon {
        font-size: 2.5rem;
    }

    .stat-value {
        font-size: 2rem;
    }

    /* Meals Grid */
    .meals-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .meal-image {
        height: 180px;
    }

    .meal-content {
        padding: 1.25rem;
    }

    .meal-title {
        font-size: 1rem;
    }

    .meal-actions {
        flex-direction: column;
    }

    .btn-icon {
        width: 100%;
        padding: 0.75rem;
    }

    /* Buttons */
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }

    /* Upload area */
    .upload-area {
        padding: 2rem 1rem;
    }

    .upload-icon {
        font-size: 3rem;
    }

    /* QR Code */
    .qr-container {
        padding: 1.5rem;
    }

    .qr-image {
        max-width: 200px;
    }

    .server-url {
        font-size: 0.875rem;
        padding: 0.625rem 1rem;
        word-break: break-all;
    }

    /* Results */
    .result-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .result-stat {
        padding: 1.25rem;
    }

    .result-stat-value {
        font-size: 1.5rem;
    }

    /* Charts Grid */
    .charts-grid {
        grid-template-columns: 1fr !important;
    }

    /* Google Fit Cards */
    .fit-overview-grid {
        grid-template-columns: 1fr !important;
    }

    .fit-stat-card {
        padding: 1.25rem;
    }

    .fit-stat-icon {
        font-size: 2rem;
        width: 50px;
        height: 50px;
    }

    .fit-stat-value {
        font-size: 1.5rem;
    }

    /* Question area */
    .question-box {
        padding: 1.5rem;
    }

    .question-buttons {
        flex-direction: column;
    }

    .question-buttons .btn {
        width: 100%;
    }

    /* Date selector */
    .date-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .date-select {
        width: 100%;
    }

    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }

    /* Ensure all content is visible below sticky header */
    section:first-of-type {
        scroll-margin-top: 100px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .header {
        padding: 0.75rem 0;
    }

    .logo {
        font-size: 1.125rem;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    .card {
        padding: 1.25rem;
    }

    .card-title {
        font-size: 1.125rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .meal-image {
        height: 150px;
    }

    .upload-icon {
        font-size: 2.5rem;
    }
}

.error {
    color: var(--danger);
    text-align: center;
    padding: 1rem;
}

/* Notes Section - Pole uwag użytkownika */
.notes-section {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: var(--radius-md);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.notes-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.user-notes-input {
    width: 100%;
    padding: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    transition: var(--transition);
}

.user-notes-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--bg-card);
}

.user-notes-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.notes-hint {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-style: italic;
}

/* Modal Stylings */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #1e1e24;
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-title {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.description-textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 1.5rem;
    min-height: 150px;
}

.description-textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}