/* =========================
   RESET
========================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: Inter, Segoe UI, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: .3s;
    overflow-x: hidden;
}

/* =========================
   TEMA
========================= */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #111827;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --success-dark: #059669;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --shadow: 0 10px 25px rgba(0,0,0,.08);
    --radius: 18px;
}

.dark {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f8fafc;
    --text-light: #94a3b8;
    --border: #334155;
    --shadow: 0 10px 25px rgba(0,0,0,.35);
}

/* =========================
   LAYOUT
========================= */

.page {
    width: 100%;
    max-width: 1400px;
    margin: auto;
    padding: 30px;
}

.fade-in {
    animation: fade .5s ease;
}

@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================
   TOPBAR
========================= */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.topbar h1 {
    font-size: 32px;
    margin-bottom: 5px;
}

.topbar p {
    color: var(--text-light);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* =========================
   BOTÃO TEMA
========================= */

.theme-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: var(--card);
    box-shadow: var(--shadow);
    font-size: 20px;
    transition: all .3s ease;
    flex-shrink: 0;
}

.theme-btn:hover {
    transform: translateY(-3px) scale(1.05);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
}

/* =========================
   BOTÃO SAIR
========================= */

.logout-btn {
    text-decoration: none;
    color: white;
    background: linear-gradient(135deg, var(--danger), var(--danger-dark));
    padding: 12px 24px;
    border-radius: 12px;
    transition: all .3s ease;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.logout-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.35);
    opacity: 0.95;
}

/* =========================
   ALERTAS
========================= */

.alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 600;
}

.success {
    background: #dcfce7;
    color: #166534;
}

.error {
    background: #fee2e2;
    color: #991b1b;
}

.expired {
    background: #fef2f2;
    color: #dc2626;
    margin-top: 15px;
}

.dark .success {
    background: rgba(16,185,129,.15);
    color: #6ee7b7;
}

.dark .error {
    background: rgba(239,68,68,.15);
    color: #fca5a5;
}

.dark .expired {
    background: rgba(239,68,68,.15);
    color: #fca5a5;
}

/* =========================
   CARD PADRÃO
========================= */

.create-checklist-card,
.checklist-card,
.auth-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
}

/* =========================
   NOVA CHECKLIST
========================= */

.create-checklist-card {
    margin-bottom: 30px;
}

.create-checklist-card h2 {
    margin-bottom: 20px;
}

/* =========================
   GRID
========================= */

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

/* =========================
   INPUTS E SELECTS GERAIS
========================= */

input,
select,
textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    background: var(--card);
    color: var(--text);
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

/* =========================
   BOTÕES PRINCIPAIS
========================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all .3s ease;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
    text-decoration: none;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Botão específico para "Adicionar Item" */
.btn-add-item {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-add-item:hover {
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

/* Botão de salvar edição de mercado */
.market-edit button {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all .3s ease;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.market-edit button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.market-edit button:active {
    transform: scale(0.97);
}

/* =========================
   GRID DE CHECKLISTS
========================= */

.checklists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 25px;
}

/* =========================
   CARD CHECKLIST
========================= */

.checklist-card {
    position: relative;
    overflow: hidden;
    transition: all .3s ease;
}

.checklist-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 35px rgba(0,0,0,.12);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
}

.card-header h3 {
    font-size: 22px;
    margin-bottom: 8px;
    word-break: break-word;
}

/* =========================
   BADGE
========================= */

.badge {
    display: inline-block;
    background: rgba(79,70,229,.12);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.dark .badge {
    background: rgba(99,102,241,.2);
}

/* =========================
   DEADLINE
========================= */

.deadline {
    margin-bottom: 15px;
    color: var(--text-light);
    font-size: 14px;
}

/* =========================
   PROGRESSO
========================= */

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--border);
    margin-bottom: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4f46e5, #6366f1);
    transition: width .5s ease;
}

/* =========================
   ITENS
========================= */

.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 25px;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(0,0,0,.02);
}

.dark .item-row {
    background: rgba(255,255,255,.04);
}

.item-content {
    display: flex;
    gap: 12px;
    width: 100%;
}

.item-title {
    font-weight: 600;
    margin-bottom: 4px;
    transition: .3s;
}

.completed {
    text-decoration: line-through;
    opacity: .6;
}

.item-content small {
    color: var(--text-light);
    line-height: 1.5;
    white-space: pre-line;
}

/* =========================
   VARIEDADE E UNIDADE (edição na lista)
========================= */

.variety-unit-edit {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.variety-unit-edit select {
    flex: 1;
    min-width: 120px;
    padding: 10px 14px;
    font-size: 0.95rem;
    font-family: inherit;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    transition: border-color 0.3s, box-shadow 0.3s;
    appearance: auto;
    cursor: pointer;
}

.variety-unit-edit select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.variety-unit-edit select option {
    background: var(--card);
    color: var(--text);
}

@media (max-width: 600px) {
    .variety-unit-edit {
        flex-direction: column;
        gap: 8px;
    }
    .variety-unit-edit select {
        min-width: 100%;
    }
}

/* =========================
   BOTÃO CHECK
========================= */

.check-btn {
    background: none;
    border: none;
    font-size: 24px;
    padding: 4px 8px;
    border-radius: 12px;
    transition: background 0.3s, transform 0.2s;
    cursor: pointer;
}

.check-btn:hover {
    background: rgba(79, 70, 229, 0.1);
    transform: scale(1.1);
}

/* =========================
   EXCLUIR ITEM
========================= */

.delete-item-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 20px;
    padding: 6px 10px;
    border-radius: 12px;
    transition: background 0.3s, transform 0.2s;
    cursor: pointer;
}

.delete-item-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

/* =========================
   EXCLUIR CHECKLIST
========================= */

.delete-btn {
    text-decoration: none;
    font-size: 24px;
    padding: 4px 8px;
    border-radius: 12px;
    transition: background 0.3s, transform 0.2s;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: rotate(10deg) scale(1.1);
}

/* =========================
   FORM ITEM
========================= */

.add-item-box {
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.add-item-box h4 {
    margin-bottom: 15px;
}

.item-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-form .btn {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    font-size: 1.2rem;
}

/* =========================
   MERCADO - EDIÇÃO
========================= */

.market-edit {
    display: flex;
    gap: 8px;
    margin-top: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.market-edit input {
    width: 80px;
    padding: 10px;
    font-size: 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-family: inherit;
}

/* =========================
   EMPTY ITEMS
========================= */

.empty-items {
    color: var(--text-light);
    text-align: center;
    padding: 15px;
}

/* =========================
   EMPTY STATE
========================= */

.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 70px;
    margin-bottom: 20px;
}

.empty-state h2 {
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-light);
    max-width: 500px;
    margin: auto;
    line-height: 1.7;
}

/* =========================
   FOOTER
========================= */

.footer {
    margin-top: 50px;
    text-align: center;
    color: var(--text-light);
    padding: 20px;
}

/* =========================
   LOGIN / CADASTRO
========================= */

.auth-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 25px;
    background: linear-gradient(135deg, rgba(79,70,229,.08), rgba(99,102,241,.03));
}

.auth-card {
    width: 100%;
    max-width: 450px;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 34px;
}

.auth-card h2 {
    text-align: center;
    margin-bottom: 25px;
    font-size: 22px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* =========================
   ESTATÍSTICAS
========================= */

.stats-grid {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.stat-card {
    background: var(--card);
    padding: 20px 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    flex: 1;
    min-width: 120px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.price-avg {
    display: block;
    color: #2d7a2d;
    font-size: 0.8rem;
    margin-top: 2px;
}

.total-estimado {
    margin-top: 10px;
    padding: 8px 12px;
    background: #e8f5e9;
    border-radius: 8px;
    font-size: 1rem;
    color: #1b5e20;
    text-align: right;
}

.dark .total-estimado {
    background: #2e7d32;
    color: #fff;
}

/* =========================
   CORES POR TIPO
========================= */

.type-mercado {
    border: 4px solid green !important;
}

.type-exercicios {
    border: 4px solid orange !important;
}

.type-estudos {
    border: 4px solid blue !important;
}

.type-rotina {
    border: 4px solid purple !important;
}

.type-tarefas {
    border: 4px solid red !important;
}

/* =========================
   SCROLLBAR
========================= */

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* =========================
   RESPONSIVIDADE TABLET
========================= */

@media (max-width: 900px) {
    .page {
        padding: 20px;
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-actions {
        width: 100%;
        justify-content: stretch;
    }

    .logout-btn {
        text-align: center;
        flex: 1;
    }

    .theme-btn {
        flex-shrink: 0;
    }

    .checklists-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================
   RESPONSIVIDADE 425px
========================= */

@media (max-width: 425px) {
    .page {
        padding: 15px;
    }

    .topbar h1 {
        font-size: 28px;
    }

    .topbar p {
        font-size: 14px;
    }

    .card-header {
        flex-direction: column;
    }

    .item-row {
        flex-direction: column;
        align-items: stretch;
    }

    .item-content {
        width: 100%;
    }

    .delete-item-btn {
        align-self: flex-end;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .logout-btn {
        width: 100%;
    }

    .checklist-card {
        padding: 18px;
    }

    .create-checklist-card {
        padding: 18px;
    }

    .auth-card {
        padding: 18px;
    }

    .stat-card {
        min-width: 80px;
        padding: 15px 20px;
    }

    .stat-number {
        font-size: 1.6rem;
    }

    .market-edit input {
        width: 60px;
    }
}

/* =========================
   RESPONSIVIDADE 375px
========================= */

@media (max-width: 375px) {
    .page {
        padding: 12px;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .topbar p {
        font-size: 13px;
    }

    .card-header h3 {
        font-size: 20px;
    }

    .badge {
        font-size: 11px;
        padding: 4px 10px;
    }

    .progress-info {
        font-size: 13px;
    }

    .checklist-card {
        padding: 15px;
    }

    .create-checklist-card {
        padding: 15px;
    }

    .item-row {
        padding: 10px;
    }

    .check-btn {
        font-size: 20px;
    }

    .stat-card {
        min-width: 70px;
        padding: 12px 15px;
    }

    .stat-number {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .market-edit input {
        width: 50px;
        font-size: 12px;
    }

    .market-edit button {
        padding: 8px 12px;
        font-size: 12px;
    }

    .empty-icon {
        font-size: 50px;
    }

    .empty-state {
        padding: 40px 10px;
    }

    .empty-state h2 {
        font-size: 20px;
    }
}

/* =========================
   RESPONSIVIDADE 320px
========================= */

@media (max-width: 320px) {
    .page {
        padding: 10px;
    }

    .topbar h1 {
        font-size: 22px;
    }

    .topbar p {
        font-size: 12px;
    }

    .topbar-actions {
        gap: 8px;
    }

    .theme-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .logout-btn {
        padding: 10px 14px;
        font-size: 14px;
    }

    .card-header h3 {
        font-size: 18px;
    }

    .badge {
        font-size: 10px;
        padding: 3px 8px;
    }

    .progress-info {
        font-size: 12px;
    }

    .progress-bar {
        height: 8px;
    }

    .checklist-card {
        padding: 12px;
    }

    .create-checklist-card {
        padding: 12px;
    }

    .create-checklist-card h2 {
        font-size: 20px;
    }

    .item-row {
        padding: 8px;
        gap: 10px;
    }

    .item-title {
        font-size: 15px;
    }

    .check-btn {
        font-size: 18px;
    }

    .delete-item-btn {
        font-size: 16px;
    }

    input,
    select,
    textarea {
        padding: 10px;
        font-size: 14px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .stat-card {
        min-width: 60px;
        padding: 10px 12px;
    }

    .stat-number {
        font-size: 1.2rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stats-grid {
        gap: 12px;
    }

    .market-edit {
        gap: 4px;
    }

    .market-edit input {
        width: 45px;
        font-size: 11px;
        padding: 4px;
    }

    .market-edit button {
        padding: 4px 8px;
        font-size: 11px;
    }

    .empty-icon {
        font-size: 40px;
    }

    .empty-state {
        padding: 30px 10px;
    }

    .empty-state h2 {
        font-size: 18px;
    }

    .empty-state p {
        font-size: 14px;
    }

    .footer {
        font-size: 12px;
        padding: 15px;
    }
}