:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #f1f5f9;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --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 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
}

.app-container {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: var(--background);
    position: relative;
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    flex: 1;
    padding-bottom: 40px;
}

.view.active {
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.app-header {
    background-color: var(--surface);
    padding: calc(16px + env(safe-area-inset-top)) 20px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    flex: 1;
    letter-spacing: -0.02em;
}

.btn-back {
    background: var(--primary-light);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Content */
.content {
    padding: 20px;
    flex: 1;
}

/* Cards */
.listas-grid, .itens-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lista-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.lista-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.lista-card:active {
    transform: scale(0.98);
}

.lista-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.lista-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

.lista-card-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Total Card */
.total-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    color: white;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.total-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.total-label {
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.total-value {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

/* Items */
.item-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.item-card.comprado {
    background-color: #f8fafc;
    border-color: transparent;
    opacity: 0.7;
}

.item-card.comprado .item-produto {
    text-decoration: line-through;
    color: var(--text-muted);
}

.checkbox {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    background: var(--surface);
}

.checkbox.checked {
    background: var(--secondary);
    border-color: var(--secondary);
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-produto {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-main);
}

.item-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.item-details span {
    display: flex;
    align-items: center;
}

.item-details strong {
    color: var(--text-main);
    margin-left: 3px;
}

.item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-icon {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

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

.btn-icon.edit { color: var(--primary); }
.btn-icon.delete { color: var(--danger); }

.btn-icon:active { 
    transform: scale(0.9);
}

/* Inline Forms */
.inline-form-container {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    border: 2px solid var(--primary-light);
    box-shadow: var(--shadow);
    animation: slideDown 0.3s ease-out;
}

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

.inline-form-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group {
    margin-bottom: 12px;
    position: relative;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-muted);
}

.input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
    background: #fff;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.btn {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

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

.btn-secondary {
    background: var(--background);
    color: var(--text-muted);
}

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

/* Add Button Inline */
.btn-add-inline {
    width: 100%;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.btn-add-inline:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Autocomplete */
.suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    margin-top: 4px;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-item:hover {
    background: var(--primary-light);
}

.suggestion-name {
    font-weight: 500;
}

.suggestion-price {
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-top: 20px;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    color: var(--border);
}

.empty-state p {
    color: var(--text-muted);
    font-weight: 500;
}

/* Utility */
.hidden { display: none !important; }

/* Modals (keeping for compatibility but will be unused) */
.modal { display: none; }

/* Estilos Adicionais para Pesquisa e Estatísticas */
.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-stats {
    text-align: right;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    opacity: 0.8;
    font-weight: 700;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
}

.search-container {
    margin-bottom: 16px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    padding-left: 40px !important;
    background: var(--surface);
    border-radius: var(--radius-md);
    border-color: var(--border);
}

.search-input:focus {
    border-color: var(--primary);
    background: #fff;
}
