:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-gradient: linear-gradient(135deg, #f5f7ff 0%, #e0e7ff 100%);
    --text-color: #1e293b;
    --text-muted: #475569;
    --card-bg: rgba(255, 255, 255, 0.7);
    --border-color: rgba(255, 255, 255, 0.5);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(79, 70, 229, 0.1), 0 10px 10px -5px rgba(79, 70, 229, 0.04);
    --accent-color: #10b981;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    line-height: 1.5;
    padding: 20px;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.background-decoration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.2) 0%, rgba(147, 51, 234, 0.2) 100%);
    filter: blur(80px);
    border-radius: 50%;
    z-index: -1;
}

.blob-1 {
    top: -100px;
    right: -100px;
    animation: floating 15s infinite alternate ease-in-out;
}

.blob-2 {
    bottom: -150px;
    left: -100px;
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    animation: floating 20s infinite alternate-reverse ease-in-out;
}

.blob-3 {
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, rgba(245, 158, 11, 0.05) 100%);
    animation: floating 25s infinite alternate ease-in-out;
}

@keyframes floating {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(30px, 50px) rotate(10deg);
    }

    66% {
        transform: translate(-20px, 20px) rotate(-5deg);
    }

    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

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

header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--text-color);
    letter-spacing: -0.04em;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary-color), #9333ea);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header .subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 4px;
}

/* Gallery Section */
.gallery-section {
    margin-bottom: 24px;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    padding: 4px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-add {
    aspect-ratio: 1;
    border-radius: 12px;
    border: 2px dashed var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--card-bg);
}

.gallery-item-add:hover {
    border-color: var(--primary-color);
    background-color: #f1f5f9;
}

.add-icon {
    font-size: 24px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.gallery-item-add span {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.gallery-item-add span.hint {
    font-size: 0.625rem;
    opacity: 0.7;
    margin-top: 2px;
}

/* Action Section */
.action-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 30px;
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.primary-btn {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.4);
}

.secondary-btn-outline {
    background-color: white;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 14px 20px;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn-outline:hover {
    background-color: #f1f5f9;
    color: var(--text-color);
    border-color: var(--text-muted);
}

.primary-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.primary-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Gallery Deletion */
.photo-delete-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    border: 1.5px solid rgba(255, 255, 255, 0.8);
    transition: background-color 0.2s ease;
    z-index: 10;
}

.photo-delete-btn:hover {
    background-color: #ef4444;
}

/* Results Section */
.result-section {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    background-color: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 30px -5px rgba(79, 70, 229, 0.15), 0 15px 15px -5px rgba(79, 70, 229, 0.06);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
}

.results-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.results-table th:nth-child(1) {
    width: auto;
}

.results-table th:nth-child(2) {
    width: 80px;
}

.results-table th:nth-child(3) {
    width: 80px;
}

.results-table th:nth-child(4) {
    width: 35px;
    text-align: center;
}

.results-table td {
    padding: 10px 4px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
}

.results-table td:nth-child(1) {
    padding-left: 8px;
}

.results-table td:last-child {
    text-align: center;
    padding-right: 8px;
}

.results-table tr:last-child td {
    border-bottom: none;
}

/* Table Actions */
.table-actions {
    display: flex;
    justify-content: center;
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.secondary-btn {
    background-color: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

/* Brand Section */
.brand-section {
    margin-top: 24px;
}

.brand-card {
    border-left: 4px solid var(--accent-color);
}

.brand-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--accent-color);
}

.brand-item {
    padding: 12px;
    background: rgba(16, 185, 129, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(16, 185, 129, 0.1);
    margin-bottom: 10px;
}

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

.brand-name {
    font-weight: 700;
    color: var(--text-color);
}

.search-link {
    font-size: 0.75rem;
    color: var(--primary-color);
    text-decoration: none;
    background: white;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--primary-color);
    transition: all 0.2s ease;
}

.search-link:hover {
    background: var(--primary-color);
    color: white;
}

.brand-nutrition {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Footer Section */
footer {
    position: sticky;
    bottom: 20px;
    margin-top: 20px;
}

.total-calories {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    padding: 16px 24px;
    border-radius: 16px;
    color: white;
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

.total-label {
    font-weight: 500;
    opacity: 0.9;
}

.total-value {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Loading State */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.hidden {
    display: none;
}

/* Weight Input Styling */
.weight-input-container {
    display: flex;
    align-items: center;
    gap: 4px;
}

.weight-input {
    width: 65px;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    background-color: white;
}

.weight-input:focus,
.name-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.name-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-color);
    background-color: transparent;
    transition: all 0.2s ease;
}

.name-input:hover {
    background-color: rgba(59, 130, 246, 0.05);
    border-color: var(--border-color);
}

.name-input:focus {
    background-color: white;
    border-color: var(--primary-color);
}

.unit-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.item-calories {
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

.delete-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Responsive adjustment */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    header {
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: 16px;
    }

    .results-table th {
        font-size: 0.65rem;
        padding: 6px 4px;
    }

    .results-table td {
        padding: 8px 2px;
        font-size: 0.8rem;
    }

    .name-input {
        font-size: 0.8rem;
        padding: 4px 6px;
    }

    .weight-input {
        width: 50px;
        font-size: 0.8rem;
        padding: 2px 4px;
    }

    .unit-text {
        font-size: 0.7rem;
    }

    .item-calories {
        font-size: 0.8rem;
    }

    .delete-btn {
        font-size: 0.8rem;
        padding: 0px 2px;
    }

    .total-calories {
        padding: 12px 18px;
    }

    .total-value {
        font-size: 1.1rem;
    }
}