/* Variáveis do Tema (Baseado na paleta solicitada) */
:root {
    --bg-main: #F8FAFC;
    /* Cor de fundo da interface para reduzir o cansaço visual */
    --text-main: #1E293B;
    /* Títulos e números grandes */
    --text-muted: #6b7280;
    /* Gray 500 para textos secundários */
    --bg-card: #FFFFFF;
    /* Fundo dos cards para criar elevação (sombra) */
    --border-color: #e5e7eb;
    /* Gray 200 */

    --primary: #6366F1;
    /* Botão "Novo Hábito" e destaque de navegação */
    --primary-hover: #4f46e5;

    --success: #10B981;
    /* Hábitos concluídos e barras de progresso */
    --success-hover: #059669;

    --pending: #F59E0B;
    /* Hábitos pendentes ou urgentes */
    --pending-hover: #d97706;

    --pill-active-bg: var(--primary);
    --pill-active-text: #ffffff;
    --pill-inactive-bg: #e2e8f0;
    /* Slate 200 */
    --pill-inactive-text: #475569;
    /* Slate 600 */

    --habit-todo-bg: #FFFFFF;
    --habit-todo-border: var(--pending);
    --habit-todo-text: var(--text-main);

    --habit-done-bg: var(--success);
    --habit-done-text: #ffffff;

    --radius-pill: 9999px;
    --radius-card: 12px;

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
}

/* Layout Principal */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header */
.app-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    position: relative;
}

h1 {
    font-size: 2.25rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    flex-grow: 1;
}

/* Quando em mobile, pode quebrar linha ou reorganizar */
@media (max-width: 640px) {
    .app-header {
        flex-direction: column;
        gap: 1.5rem;
    }

    .btn-novo-habito {
        position: static !important;
    }
}

main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Botões Globais */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
}

.btn-novo-habito {
    background-color: var(--primary);
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    position: absolute;
    right: 0;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.btn-novo-habito:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* Seletor de Período (Semana, Mês, Ano) */
.period-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 3rem;
}

.btn-period {
    padding: 0.4rem 1.25rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background-color: var(--pill-inactive-bg);
    color: var(--pill-inactive-text);
    transition: all 0.2s;
}

.btn-period.active {
    background-color: var(--pill-active-bg);
    color: var(--pill-active-text);
}

.btn-period:hover:not(.active) {
    opacity: 0.9;
}

/* Cards Carousel */
.cards-carousel {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    overflow-x: auto;
    padding: 1rem 0.5rem;
    margin-bottom: 3rem;
    justify-content: center;
    /* Hide scrollbar */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.cards-carousel::-webkit-scrollbar {
    display: none;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 1.5rem 2rem;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-card);
    flex-shrink: 0;
}

.card-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
    line-height: 1.1;
}

.card-number-symbol {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Seletor de Data */
.date-selector {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.btn-icon:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

#current-date-display {
    font-size: 1.25rem;
    font-weight: 500;
    min-width: 240px;
    text-align: center;
    color: var(--text-main);
}

/* Áreas de Hábitos (Done e Todo) */
.habits-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.habit-buttons-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    min-height: 48px;
    /* Mantém espaço mesmo vazio */
}

.area-title {
    font-size: 0.875rem;
    color: var(--text-main);
    font-weight: 500;
    margin-bottom: 1rem;
    align-self: flex-start;
    margin-left: 10%;
}

@media (min-width: 640px) {
    .area-title {
        align-self: flex-start;
        margin-left: max(0px, calc(50% - 250px));
        /* Centralizado com limite */
    }
}

/* Botões de Hábito (Pills) */
.habit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 500;
    border: 2px solid transparent;
}

/* Estilo Para Fazer (Todo) */
.habit-btn.todo {
    background-color: var(--habit-todo-bg);
    border-color: var(--habit-todo-border);
    color: var(--text-main);
}

.habit-btn.todo:hover {
    background-color: #fffbeb;
    /* Amber 50 */
    border-color: var(--pending-hover);
}

/* Estilo Feito (Done) */
.habit-btn.done {
    background-color: var(--habit-done-bg);
    color: var(--habit-done-text);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.habit-btn.done:hover {
    background-color: var(--success-hover);
}

/* Resumo Diário */
.daily-summary {
    margin-top: 3rem;
    font-size: 1.125rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-main);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-main);
    border-radius: var(--radius-card);
    width: 90%;
    max-width: 450px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.btn-close {
    background: transparent;
    color: var(--text-muted);
    padding: 0.25rem;
}

.btn-close:hover {
    color: var(--text-main);
}

.btn-close svg {
    width: 24px;
    height: 24px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.input-group input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    background-color: var(--bg-card);
    color: var(--text-main);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-cancel {
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.5rem 1rem;
}

.btn-cancel:hover {
    color: var(--text-main);
}

.btn-save {
    background-color: var(--primary);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 6px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.btn-save:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}