:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --dark: #f8fafc;
    --light: #0f172a;
    --gray-100: #1e293b;
    --gray-200: #334155;
    --gray-300: #475569;
    --gray-400: #64748b;
    --gray-500: #94a3b8;
    --gray-600: #cbd5e1;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;
    --gray-900: #f8fafc;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--light);
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
    transition: var(--transition);
}

.gradient-bg {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    opacity: 0.05;
    z-index: -2;
}

[data-theme="dark"] .gradient-bg {
    opacity: 0.1;
}

.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0.03;
    z-index: -1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.floating-shapes {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    opacity: 0.05;
    filter: blur(40px);
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 300px;
    height: 300px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 200px;
    height: 200px;
    top: 60%;
    right: 10%;
    animation-delay: 5s;
}

.shape-3 {
    width: 250px;
    height: 250px;
    bottom: 10%;
    left: 50%;
    animation-delay: 10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -30px) rotate(90deg); }
    50% { transform: translate(-20px, 20px) rotate(180deg); }
    75% { transform: translate(-30px, -10px) rotate(270deg); }
}

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

.app-header {
    margin-bottom: 2rem;
    animation: slideDown 0.5s ease-out;
}

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

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-2xl);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .header-content {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.logo-text h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.25rem;
}

.tagline {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sync-btn,
.theme-toggle {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--gray-200);
    background: white;
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: var(--transition);
}

[data-theme="dark"] .sync-btn,
[data-theme="dark"] .theme-toggle {
    background: var(--gray-800);
    border-color: var(--gray-700);
    color: var(--gray-300);
}

.sync-btn:hover {
    transform: rotate(360deg);
    border-color: var(--success);
    color: var(--success);
}

.sync-btn.syncing {
    animation: spin 1s linear infinite;
    border-color: var(--primary);
    color: var(--primary);
}

.theme-toggle:hover {
    transform: rotate(20deg);
    border-color: var(--primary);
    color: var(--primary);
}

.sync-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius-2xl);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--success);
}

.sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.sync-status.syncing .sync-dot {
    animation: spin 1s linear infinite;
}

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

.main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.glass-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    transition: var(--transition);
}

[data-theme="dark"] .glass-card {
    background: rgba(30, 41, 59, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
}

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

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

[data-theme="dark"] .section-title {
    color: var(--gray-200);
}

.section-title i {
    color: var(--primary);
    font-size: 1.125rem;
}

.add-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-row {
    display: flex;
    gap: 1rem;
}

.input-wrapper {
    position: relative;
    flex: 1;
}

.input-wrapper.main-input {
    width: 100%;
}

.input-wrapper.quantity-input {
    max-width: 100px;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 1rem;
    pointer-events: none;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: inherit;
    background: white;
    color: var(--dark);
    transition: var(--transition);
}

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select {
    background: var(--gray-800);
    border-color: var(--gray-700);
    color: var(--light);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-focus-border {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.3s, left 0.3s;
}

input:focus ~ .input-focus-border {
    width: 100%;
    left: 0;
}

.btn-add {
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
    white-space: nowrap;
}

.btn-add:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.4);
}

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

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.stat-card.pending::before {
    background: linear-gradient(90deg, var(--warning), #fb923c);
}

.stat-card.completed::before {
    background: linear-gradient(90deg, var(--success), #34d399);
}

.stat-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.stat-card.pending .stat-icon {
    background: linear-gradient(135deg, var(--warning), #fb923c);
}

.stat-card.completed .stat-icon {
    background: linear-gradient(135deg, var(--success), #34d399);
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--gray-800);
    line-height: 1;
    margin-bottom: 0.25rem;
}

[data-theme="dark"] .stat-value {
    color: var(--gray-200);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-500);
    font-weight: 500;
}

.list-section {
    min-height: 400px;
}

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

.list-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filter-tabs {
    display: flex;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 0.25rem;
}

[data-theme="dark"] .filter-tabs {
    background: var(--gray-800);
}

.filter-tab {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-tab i {
    font-size: 0.75rem;
}

.filter-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .filter-tab.active {
    background: var(--gray-700);
}

.btn-clear {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 2px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-clear:hover {
    background: var(--danger);
    color: white;
}

.grocery-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.grocery-list::-webkit-scrollbar {
    width: 6px;
}

.grocery-list::-webkit-scrollbar-track {
    background: var(--gray-100);
    border-radius: var(--radius-lg);
}

.grocery-list::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: var(--radius-lg);
}

.grocery-list::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.grocery-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: var(--gray-50);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    transition: var(--transition);
    animation: slideIn 0.3s ease-out;
}

[data-theme="dark"] .grocery-item {
    background: var(--gray-800);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.grocery-item:hover {
    border-color: var(--primary);
    transform: translateX(5px);
}

.grocery-item.purchased {
    opacity: 0.6;
    background: var(--gray-100);
}

[data-theme="dark"] .grocery-item.purchased {
    background: var(--gray-900);
}

.item-checkbox {
    width: 24px;
    height: 24px;
    margin-right: 1rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.item-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
}

[data-theme="dark"] .item-name {
    color: var(--gray-200);
}

.grocery-item.purchased .item-name {
    text-decoration: line-through;
}

.item-quantity {
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: var(--radius-2xl);
    font-size: 0.875rem;
    font-weight: 600;
}

.item-category {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.875rem;
    background: var(--gray-100);
    color: var(--gray-600);
    border-radius: var(--radius-2xl);
    font-size: 0.875rem;
    font-weight: 500;
    width: fit-content;
}

[data-theme="dark"] .item-category {
    background: var(--gray-700);
    color: var(--gray-300);
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

.delete-btn {
    padding: 0.5rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.delete-btn:hover {
    background: var(--danger);
    color: white;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray-400);
}

.empty-illustration {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--gray-600);
}

[data-theme="dark"] .empty-state h3 {
    color: var(--gray-400);
}

.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-content {
    text-align: center;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.offline-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--warning);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    opacity: 0;
    transition: var(--transition);
}

.offline-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .add-form {
        flex-direction: column;
    }

    .input-row {
        flex-direction: row;
    }

    .stats-section {
        grid-template-columns: 1fr;
    }

    .list-header {
        flex-direction: column;
        align-items: stretch;
    }

    .list-actions {
        flex-direction: column;
    }

    .filter-tabs {
        width: 100%;
        justify-content: space-between;
    }

    .btn-clear {
        width: 100%;
        justify-content: center;
    }
}