:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #f43f5e;
    --success: #10b981;
    --warning: #f59e0b;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 16px;
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    user-select: none;
}

.screen {
    min-height: 100vh;
    width: 100%;
    position: relative;
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Loading Screen */
#loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    z-index: 9999;
}

.loader-container {
    text-align: center;
}

.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--primary);
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    animation: rotation 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-small {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-bottom-color: white;
    border-radius: 50%;
    display: inline-block;
    animation: rotation 0.6s linear infinite;
}

/* Auth Screens */
.auth-header {
    padding: 3rem 2rem;
    text-align: center;
}

.logo {
    width: 80px;
    margin-bottom: 1.5rem;
}

.auth-card {
    padding: 2rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin: 0 1.5rem;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.5s ease-out;
}

.input-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    transition: 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 0.875rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Family Management Screen */
#family-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.family-box {
    background: white;
    padding: 2.5rem 2rem;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.family-box h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.family-box p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.tabs {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 10px;
    transition: 0.3s;
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.tab-content {
    animation: fadeIn 0.3s ease-out;
}

.tab-content input {
    margin-bottom: 1rem;
    text-align: center;
}

.btn-secondary {
    width: 100%;
    padding: 0.875rem;
    background: white;
    color: var(--text-main);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.2s;
}

.btn-secondary:active {
    transform: scale(0.98);
}
.app-header {
    background: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mini-logo {
    width: 32px;
}

.app-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Stats Bar */
/* Stats Bar Styles Removed */

/* Items List */
.items-list {
    padding: 1.5rem 1.5rem 6rem;
}

.item-card {
    background: white;
    border-radius: 20px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    animation: fadeIn 0.4s ease-out;
    position: relative;
    border: 1px solid rgba(0,0,0,0.02);
}

.item-card.purchased {
    opacity: 0.6;
}

.item-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
}

.item-img {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
    background: #f1f5f9;
}

.item-info {
    flex: 1;
}

.item-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.item-qty {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 0.5rem;
    white-space: nowrap;
}

/* .item-meta removed */

.item-tag {
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 0.25rem;
}

.btn-delete {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    opacity: 0.3;
    transition: 0.2s;
}

.btn-delete:hover {
    opacity: 1;
    color: var(--secondary);
}

/* FAB */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.fab svg {
    width: 24px;
    height: 24px;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    z-index: 2000;
}

.modal-content {
    background: white;
    width: 100%;
    border-radius: 30px 30px 0 0;
    padding: 2rem 1.5rem;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.suggestions-grid {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding: 0.5rem 0 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.suggestion-chip {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    white-space: nowrap;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.suggestion-chip.frequent {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}


/* Header & Menu Button */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    background: white;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.icon-btn span {
    display: block;
    width: 24px;
    height: 3px;
    background-color: var(--text-main);
    border-radius: 2px;
    transition: 0.3s;
}

/* Utilities */
.input-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.hidden {
    display: flex !important; /* Override hidden */
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
}

.sidebar-content {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.avatar-circle {
    width: 48px;
    height: 48px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.user-details h4 {
    margin: 0;
    font-size: 1rem;
}

.user-details span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.menu-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-main);
    border-radius: 12px;
    text-align: left;
    transition: 0.2s;
}

.menu-item:hover {
    background: #f8fafc;
}

.menu-item.logout {
    color: var(--secondary);
}

.menu-item .icon {
    font-size: 1.25rem;
}

.sidebar-footer {
    margin-top: auto;
    text-align: center;
    font-size: 0.8rem;
    color: #cbd5e1;
    padding-top: 2rem;
}

/* Frequent Items Grid */
.frequent-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.frequent-item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-align: center;
}

.frequent-item-img {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    object-fit: contain;
    padding: 2px;
    background: white;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
}

.frequent-item-card:hover .frequent-item-img {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.frequent-item-name {
    font-size: 0.75rem;
    color: var(--text-color);
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.close-btn-large {
    background: #f1f5f9;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: 0.2s;
}
.close-btn-large:hover {
    background: #e2e8f0;
    color: var(--secondary);
}
