/**
 * Quadro Design System (v3.2) - Enterprise Grade
 * Tokens de design baseados na estética ONYX e AXIS
 */

:root {
    /* Colors - Design Tokens (Cozy Paper-Cut) */
    --q-dark-base: #fdfbf7;
    --q-elevation: #f5ede3;
    --q-border: #ebdcd0;
    --q-text-high: #2d2a26;
    --q-text-muted: #7c7267;
    --q-primary: #5c7a64;
    --q-primary-hover: #48614e;
    --q-success: #5c7a64;
    --q-error: #bd5b40;
    --q-warning: #df9a3f;
    --q-acid: #df9a3f;

    /* Novos tokens Cozy de suporte */
    --q-accent: #df9a3f;
    --q-danger: #bd5b40;
    --q-card-darker: #e5d7c8;
    --q-paper-yellow: #fffbeb;
    --q-paper-blue: #f0f7ff;
    --q-paper-green: #f2f8f3;
    --q-paper-pink: #fff5f5;

    /* ── Tipografia — Sistema de 2 Fontes ── */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-handwritten: 'Gochi Hand', cursive;

    /* Escala Tipográfica (Major Third — ratio 1.25) */
    --text-xs: 0.64rem;
    /* 10.24px */
    --text-sm: 0.8rem;
    /* 12.8px  */
    --text-base: 1rem;
    /* 16px    */
    --text-lg: 1.25rem;
    /* 20px    */
    --text-xl: 1.563rem;
    /* 25px    */
    --text-2xl: 1.953rem;
    /* 31.25px */
    --text-3xl: 2.441rem;
    /* 39px    */
    --text-4xl: 3.052rem;
    /* 48.8px  */

    /* Pesos Tipográficos */
    --weight-light: 300;
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;

    /* Spacing System */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;

    /* Border Radius */
    --q-radius: 12px;

    /* Motion & Transitions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-default: 300ms var(--ease-out-expo);
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--q-dark-base);
    color: var(--q-text-high);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-primary);
    font-weight: var(--weight-bold);
    letter-spacing: -0.02em;
}

.handwritten {
    font-family: var(--font-handwritten);
}

/* ============================================
   BACKGROUND PATTERNS
   ============================================ */

.bg-dots {
    background-image: radial-gradient(var(--q-border) 1px, transparent 1px);
    background-size: 20px 20px;
}

.bg-grid-main {
    background-size: 40px 40px;
    background-image: linear-gradient(to right, rgba(235, 220, 208, 0.4) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(235, 220, 208, 0.4) 1px, transparent 1px);
}

/* ============================================
   COMPONENTS: ONYX FRAME
   ============================================ */

.onyx-frame {
    position: relative;
    border: 1px solid var(--q-border);
}

.onyx-frame::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--q-primary);
    border-left: 2px solid var(--q-primary);
}

.onyx-frame::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    border-bottom: 2px solid var(--q-primary);
    border-right: 2px solid var(--q-primary);
}

/* ============================================
   COMPONENTS: FLASHLIGHT CARD
   ============================================ */

.flashlight-card {
    position: relative;
    background: var(--q-elevation);
    border: 1px solid var(--q-border);
    border-radius: var(--q-radius);
    overflow: hidden;
}

.flashlight-card::before {
    content: "";
    position: absolute;
    inset: 0px;
    background: radial-gradient(400px circle at var(--mouse-x, 0) var(--mouse-y, 0),
            rgba(92, 122, 100, 0.08),
            transparent 40%);
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

.flashlight-card:hover::before {
    opacity: 1;
}

/* ============================================
   GLASS NAVIGATION
   ============================================ */

.glass-nav {
    background: rgba(253, 251, 247, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--q-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Glass Frosted Effect (Shower Box / Box de Banheiro) */
.glass-frosted {
    background: rgba(253, 251, 247, 0.95) !important;
    backdrop-filter: blur(60px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(60px) saturate(180%) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.03);
}

/* Mobile Menu Active State */
#mobile-menu.active {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    background-color: rgba(253, 251, 247, 0.98) !important; /* Cozy Cream */
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}

body.menu-open {
    overflow: hidden;
    background-color: rgba(235, 161, 15, 0.98) !important;
}

/* HTMX Indicator Control */
.htmx-indicator {
    display: none !important;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: flex !important;
}

/* ============================================
   ANIMATIONS & SYSTEMS
   ============================================ */

.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s var(--ease-out-expo), transform 0.8s var(--ease-out-expo);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.chart-bar {
    transform-origin: bottom;
    animation: grow 1.5s var(--ease-out-expo) forwards;
}

@keyframes grow {
    from {
        transform: scaleY(0);
    }

    to {
        transform: scaleY(1);
    }
}

@keyframes modal-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--q-border);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--q-primary);
}

/* Dialog Reset & Animation */
dialog[open] {
    animation: modal-fade-in 0.4s var(--ease-out-expo) forwards;
}

dialog::backdrop {
    animation: fade-in 0.4s var(--ease-out-expo) forwards;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.container-base {
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--space-2);
    /* Mobile first */
}

@media (min-width: 768px) {
    .container-base {
        padding: var(--space-4);
        /* Desktop padding */
    }
}

.text-muted {
    color: var(--q-text-muted);
}

.btn-q {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: var(--q-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-default);
    border: none;
    gap: 8px;
    text-decoration: none;
    background-color: var(--q-primary);
    color: white;
}

.btn-q:hover {
    background-color: var(--q-primary-hover);
    transform: translateY(-1px);
}

/* ============================================
   PRO BADGE
   ============================================ */
.badge-pro {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: linear-gradient(135deg, var(--q-primary), #8B5CF6);
    color: white;
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    user-select: none;
}

/* ============================================
   COZY PAPER-CUT BASE COMPONENTS (Fase 1)
   ============================================ */

/* Efeito de Camadas de Papel Físico */
.paper-layer {
    background-color: var(--q-elevation);
    border: 1px solid var(--q-border);
    box-shadow: 0 4px 12px rgba(110, 101, 92, 0.08),
        0 1px 3px rgba(110, 101, 92, 0.05);
    border-radius: 20px;
}

/* Botões Estilo Papel Acolhedor */
.btn-cozy-primary {
    background-color: var(--q-primary);
    color: var(--q-dark-base);
    box-shadow: 0 4px 8px rgba(92, 122, 100, 0.25);
    transition: all 0.2s ease;
    border-radius: 9999px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
}

.btn-cozy-primary:hover {
    background-color: var(--q-primary-hover);
    transform: translateY(-1px);
}

.btn-cozy-secondary {
    background-color: transparent;
    color: var(--q-text-high);
    border: 1.5px solid var(--q-border);
    transition: all 0.2s ease;
    border-radius: 9999px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    text-decoration: none;
}

.btn-cozy-secondary:hover {
    background-color: rgba(110, 101, 92, 0.05);
    border-color: var(--q-text-high);
}

.btn-cozy-danger {
    background-color: var(--q-danger);
    color: white;
    border-radius: 9999px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-cozy-danger:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Bilhetes / Post-its com Ímã de Topo */
.post-it {
    position: relative;
    box-shadow: 0 10px 25px -5px rgba(110, 101, 92, 0.15),
        0 8px 10px -6px rgba(110, 101, 92, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-it::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--q-danger) 0%, #3a1510 130%);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    z-index: 10;
}

.badge-pro iconify-icon {
    font-size: 10px;
}

/* ============================================
   MOBILE-FIRST: Touch States
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    .btn-q:hover {
        background-color: var(--q-primary);
        transform: none;
    }

    .btn-q:active {
        background-color: var(--q-primary-hover);
        transform: translateY(1px);
    }

    .flashlight-card:hover::before {
        opacity: 0 !important;
    }
}

/* ============================================
   TASK INSIGHTS & INSIGHTS MODALS (COMPATIBILITY & CENTER)
   ============================================ */
#taskInsightsModal,
#insightsModal {
    border: none !important;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    padding: 0;
    width: 90%;
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    margin: 0 !important;
    outline: none !important;
    border-radius: 32px !important; /* Acompanha o rounded-[32px] da div interna */
    overflow: visible !important; /* Permite que o botão de fechar flutue para fora sem corte */
    z-index: 1000;
}

#taskInsightsModal {
    max-width: 384px;
}

#insightsModal {
    max-width: 672px; /* max-w-2xl */
}

#taskInsightsModal::backdrop,
#insightsModal::backdrop {
    background-color: rgba(45, 42, 38, 0.7) !important; /* Tom café escuro com opacidade */
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}