/* =========================
   VARIÁVEIS (DESIGN SYSTEM)
========================= */
:root {
    --verde: #4CAF50;
    --verde-escuro: #2E7D32;
    --verde-claro: #81C784;
    --laranja: #FF7A00;
    --laranja-claro: #FFA726;
    --laranja-escuro: #E65100;

    --branco: #FFFFFF;
    --cinza-claro: #F5F5F5;
    --cinza: #9E9E9E;
    --cinza-escuro: #333333;
    --cinza-fundo: #FAFAFA;

    --radius: 16px;
    --radius-sm: 8px;
    --radius-lg: 24px;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-card: 0 2px 12px rgba(0,0,0,0.06);

    --sidebar-width: 280px;
    --topbar-height: 60px;
}

/* =========================
   RESET & BASE
========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--cinza-fundo);
    color: var(--cinza-escuro);
    min-height: 100vh;
    overflow-x: hidden;
}

/* =========================
   SIDEBAR (MENU LATERAL)
========================= */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--verde-escuro) 0%, var(--verde) 100%);
    z-index: 1000;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.user-avatar {
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 32px;
}

.sidebar-header h3 {
    color: var(--branco);
    font-size: 22px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.1);
    color: var(--branco);
    border-left-color: var(--laranja);
}

.nav-item i {
    font-size: 20px;
    width: 24px;
}

.sidebar-footer {
    padding: 20px;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer p {
    color: rgba(255,255,255,0.6);
    font-size: 14px;
}

/* =========================
   OVERLAY
========================= */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* =========================
   MAIN CONTENT
========================= */
.main-content {
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* =========================
   TOP BAR
========================= */
.top-bar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--branco);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 100;
}

.menu-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--cinza-claro);
    border-radius: var(--radius-sm);
    font-size: 20px;
    color: var(--cinza-escuro);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.menu-btn:hover {
    background: var(--cinza);
    color: var(--branco);
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--verde-escuro);
}

.top-bar-spacer {
    width: 44px;
}

/* =========================
   PÁGINAS
========================= */
.page {
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

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

/* =========================
   WELCOME SECTION
========================= */
.welcome-section {
    margin-bottom: 24px;
}

.welcome-card {
    background: linear-gradient(135deg, var(--verde) 0%, var(--verde-escuro) 100%);
    border-radius: var(--radius-lg);
    padding: 30px;
    text-align: center;
    color: var(--branco);
    box-shadow: 0 8px 30px rgba(76, 175, 80, 0.3);
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.welcome-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-card p {
    font-size: 14px;
    opacity: 0.9;
}

/* =========================
   STATS SECTION
========================= */
.stats-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--branco);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
}

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

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.stat-verde {
    background: rgba(76, 175, 80, 0.1);
    color: var(--verde);
}

.stat-laranja {
    background: rgba(255, 122, 0, 0.1);
    color: var(--laranja);
}

.stat-verde-escuro {
    background: rgba(46, 125, 50, 0.1);
    color: var(--verde-escuro);
}

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

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--cinza-escuro);
}

.stat-label {
    font-size: 11px;
    color: var(--cinza);
}

/* =========================
   QUICK ACTIONS
========================= */
.quick-actions {
    margin-bottom: 24px;
}

.quick-actions h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--cinza);
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-primary {
    background: linear-gradient(135deg, var(--laranja) 0%, var(--laranja-escuro) 100%);
    color: var(--branco);
    box-shadow: 0 4px 15px rgba(255, 122, 0, 0.3);
}

.action-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 122, 0, 0.4);
}

/* =========================
   ÚLTIMAS LISTAS
========================= */
.ultimas-listas h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--cinza);
    text-transform: uppercase;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.listas-vazio, .itens-vazio, .historico-vazio {
    background: var(--branco);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    box-shadow: var(--shadow-card);
}

.listas-vazio i, .itens-vazio i, .historico-vazio i {
    font-size: 48px;
    color: var(--cinza);
    margin-bottom: 16px;
    opacity: 0.5;
}

.listas-vazio p, .itens-vazio p, .historico-vazio p {
    color: var(--cinza);
    font-size: 14px;
    margin-bottom: 16px;
}

.btn-small {
    padding: 12px 24px;
    background: var(--laranja);
    color: var(--branco);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* =========================
   PÁGINA DE LISTAS
========================= */
.page-header {
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--cinza-escuro);
}

.page-header.with-back {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--cinza-claro);
    border-radius: var(--radius-sm);
    font-size: 18px;
    color: var(--cinza-escuro);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:hover {
    background: var(--cinza);
    color: var(--branco);
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--verde);
    border-radius: var(--radius-sm);
    font-size: 18px;
    color: var(--branco);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

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

/* =========================
   FAB (Floating Action Button)
========================= */
.fab-add {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--laranja) 0%, var(--laranja-escuro) 100%);
    border: none;
    border-radius: 50%;
    font-size: 28px;
    color: var(--branco);
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255, 122, 0, 0.4);
    transition: all 0.2s ease;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-add:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(255, 122, 0, 0.5);
}

/* =========================
   LISTAS GRID
========================= */
.listas-grid {
    display: grid;
    gap: 12px;
    padding-bottom: 80px;
}

.lista-card {
    background: var(--branco);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.lista-card-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.lista-card-info span {
    font-size: 13px;
    color: var(--cinza);
}

.lista-card-actions {
    display: flex;
    gap: 8px;
}

.lista-card-actions button {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--cinza-claro);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--cinza);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lista-card-actions button:hover {
    background: var(--cinza);
    color: var(--branco);
}

.lista-card-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--verde) 0%, var(--verde-escuro) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--branco);
    font-size: 20px;
}

/* =========================
   ADICIONAR ITEM
========================= */
.add-item-section {
    background: var(--branco);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.input-wrapper .input {
    flex: 1;
    margin-bottom: 0;
}

.input {
    width: 100%;
    padding: 16px 18px;
    border: 2px solid #E0E0E0;
    border-radius: 14px;
    font-size: 16px;
    font-family: inherit;
    background: var(--branco);
    color: var(--cinza-escuro);
    transition: all 0.2s ease;
    outline: none;
}

.input:focus {
    border-color: var(--verde);
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.1);
}

.input::placeholder {
    color: var(--cinza);
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 48px;
    cursor: pointer;
}

.add-btn {
    width: 56px;
    height: 56px;
    background: var(--laranja);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 20px;
    color: var(--branco);
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-btn:hover {
    background: var(--laranja-claro);
}

.item-options {
    display: flex;
    gap: 8px;
}

.item-options .input {
    flex: 1;
    margin-bottom: 0;
}

.input-qtd {
    max-width: 80px;
    text-align: center;
}

/* =========================
   ITENS LIST
========================= */
.itens-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 80px;
}

.item-card {
    background: var(--branco);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.item-card.comprado {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
}

.item-check {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid var(--cinza);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 18px;
    background: var(--branco);
    transition: all 0.2s ease;
}

.item-card.comprado .item-check {
    background: var(--verde);
    border-color: var(--verde);
    color: var(--branco);
}

.item-details {
    flex: 1;
}

.item-name {
    font-size: 16px;
    font-weight: 500;
}

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

.item-meta {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.item-categoria {
    font-size: 12px;
    background: var(--laranja);
    color: var(--branco);
    padding: 2px 8px;
    border-radius: 10px;
}

.item-qtd-badge {
    font-size: 12px;
    background: var(--cinza-claro);
    color: var(--cinza);
    padding: 2px 8px;
    border-radius: 10px;
}

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

.item-actions button {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--cinza-claro);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--cinza);
    cursor: pointer;
}

.item-actions button:hover {
    background: var(--cinza);
    color: var(--branco);
}

/* =========================
   HISTÓRICO
========================= */
.historico-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

.historico-card {
    background: var(--branco);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-card);
}

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

.historico-header h4 {
    font-size: 16px;
    font-weight: 600;
}

.historico-valor {
    font-size: 18px;
    font-weight: 700;
    color: var(--verde);
}

.historico-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--cinza);
    margin-bottom: 12px;
}

.historico-actions {
    display: flex;
    justify-content: flex-end;
}

.historico-actions button {
    padding: 8px 16px;
    background: var(--laranja);
    color: var(--branco);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

/* =========================
   MODAL
========================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--branco);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h3 {
    color: var(--verde-escuro);
    margin-bottom: 24px;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

.modal .input {
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.modal-cancelar {
    background: var(--cinza-claro);
    color: var(--cinza-escuro);
}

.modal-confirmar {
    background: var(--laranja);
    color: var(--branco);
}

/* =========================
   TOAST
========================= */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: linear-gradient(135deg, var(--verde) 0%, var(--verde-escuro) 100%);
    color: var(--branco);
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 8px 30px rgba(76, 175, 80, 0.4);
    animation: toastIn 0.3s ease;
}

.toast.erro {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    box-shadow: 0 8px 30px rgba(244, 67, 54, 0.4);
}

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

/* =========================
   RESPONSIVO
========================= */
@media (max-width: 480px) {
    .stats-section {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 14px;
    }

    .page {
        padding: 16px;
    }

    .fab-add {
        bottom: 20px;
        right: 20px;
    }
}