/**
 * Mercadao de Achadinhos - Estilos customizados.
 * @author Dante Testa | https://dantetesta.com.br | 2026-04-11
 */

/* ================================================================
   RESET — isola o plugin dos estilos do tema WordPress
   ================================================================ */
.ma-app-root,
.ma-app-root *,
.ma-app-root *::before,
.ma-app-root *::after {
    box-sizing: border-box;
}

.ma-app-root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    font-size: 16px;
    line-height: 1.5;
    color: #111827;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.ma-app-root a {
    text-decoration: none !important;
}

/* Preserva cores Tailwind text-* em links e botões — nao sobrescreve com inherit */
.ma-app-root a.text-white,
.ma-app-root button.text-white,
.ma-app-root a[class*="text-white"],
.ma-app-root button[class*="text-white"] {
    color: #ffffff !important;
}

.ma-app-root a[class*="text-indigo"],
.ma-app-root button[class*="text-indigo"] {
    color: #4f46e5 !important;
}

.ma-app-root a[class*="text-gray"],
.ma-app-root button[class*="text-gray"] {
    color: #6b7280 !important;
}

.ma-app-root a[class*="text-red"],
.ma-app-root button[class*="text-red"] {
    color: #ef4444 !important;
}

.ma-app-root a[class*="text-green"],
.ma-app-root button[class*="text-green"] {
    color: #059669 !important;
}

.ma-app-root a[class*="text-rose"],
.ma-app-root button[class*="text-rose"] {
    color: #f43f5e !important;
}

/* Mesmas regras para auth e mercadao (fora do ma-app-root) */
.ma-auth-wrap a[class*="text-white"],
.ma-auth-wrap button[class*="text-white"],
.ma-mercadao a[class*="text-white"],
.ma-mercadao button[class*="text-white"] {
    color: #ffffff !important;
}

.ma-auth-wrap a[class*="text-indigo"],
.ma-auth-wrap button[class*="text-indigo"],
.ma-mercadao a[class*="text-indigo"],
.ma-mercadao button[class*="text-indigo"] {
    color: #4f46e5 !important;
}

.ma-auth-wrap a[class*="text-gray"],
.ma-auth-wrap button[class*="text-gray"],
.ma-mercadao a[class*="text-gray"],
.ma-mercadao button[class*="text-gray"] {
    color: #6b7280 !important;
}

.ma-app-root p {
    margin: 0 !important;
    padding: 0;
    font-size: inherit;
    line-height: inherit;
}

.ma-app-root h1,
.ma-app-root h2,
.ma-app-root h3,
.ma-app-root h4,
.ma-app-root h5,
.ma-app-root h6 {
    margin: 0 !important;
    padding: 0;
    font-size: inherit !important;
    font-weight: inherit !important;
    line-height: inherit !important;
    color: inherit;
}

.ma-app-root ul,
.ma-app-root ol {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.ma-app-root img,
.ma-auth-wrap img,
.ma-mercadao img {
    max-width: 100%;
    height: auto;
    display: block;
    border: none;
}

/* Emojis convertidos pelo WP (twemoji) — sem o tema, explodem para 100% */
img.wp-smiley,
.ma-app-root img.wp-smiley,
.ma-auth-wrap img.wp-smiley,
.ma-mercadao img.wp-smiley,
img.emoji,
.ma-app-root img.emoji,
.ma-auth-wrap img.emoji,
.ma-mercadao img.emoji {
    display: inline !important;
    width: 1em !important;
    height: 1em !important;
    max-width: 1em !important;
    border: none !important;
    box-shadow: none !important;
    vertical-align: -0.1em;
    margin: 0 .07em;
    padding: 0;
    background: none;
}

/* SVG: reset de display + tamanhos fixos por classe utilitaria
   Necessario porque o reset global (*) pode sobrescrever width/height via heranca */
.ma-app-root svg,
.ma-auth-wrap svg,
.ma-mercadao svg {
    display: inline-block !important;
    flex-shrink: 0;
    overflow: visible;
    vertical-align: middle;
}

/* Tamanhos fixos em px — nao dependem de font-size nem de heranca */
.ma-app-root svg.w-4,  .ma-auth-wrap svg.w-4,  .ma-mercadao svg.w-4  { width: 16px !important; height: 16px !important; }
.ma-app-root svg.w-5,  .ma-auth-wrap svg.w-5,  .ma-mercadao svg.w-5  { width: 20px !important; height: 20px !important; }
.ma-app-root svg.w-6,  .ma-auth-wrap svg.w-6,  .ma-mercadao svg.w-6  { width: 24px !important; height: 24px !important; }
.ma-app-root svg.w-7,  .ma-auth-wrap svg.w-7,  .ma-mercadao svg.w-7  { width: 28px !important; height: 28px !important; }
.ma-app-root svg.w-10, .ma-auth-wrap svg.w-10, .ma-mercadao svg.w-10 { width: 40px !important; height: 40px !important; }

.ma-app-root input,
.ma-app-root select,
.ma-app-root textarea,
.ma-app-root button {
    font-family: inherit !important;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    margin: 0;
}

.ma-app-root input[type="text"],
.ma-app-root input[type="email"],
.ma-app-root input[type="password"],
.ma-app-root input[type="date"],
.ma-app-root input[type="url"],
.ma-app-root input[type="search"],
.ma-app-root input[type="number"],
.ma-app-root select,
.ma-app-root textarea {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    width: 100%;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ma-app-root input[type="text"]:focus,
.ma-app-root input[type="email"]:focus,
.ma-app-root input[type="password"]:focus,
.ma-app-root input[type="date"]:focus,
.ma-app-root input[type="url"]:focus,
.ma-app-root select:focus,
.ma-app-root textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.ma-app-root textarea {
    resize: vertical;
    min-height: 80px;
}

.ma-app-root input[type="radio"],
.ma-app-root input[type="checkbox"] {
    width: auto;
    padding: 0;
    border: none;
    background: transparent;
    -webkit-appearance: auto;
    appearance: auto;
    flex-shrink: 0;
}

/* ================================================================
   LAYOUT — CSS Grid coloca sidebar ao lado do conteúdo no desktop
   O HTML tem: mobile-header | mobile-nav | sidebar | app-body
   No mobile: empilhados. No desktop: sidebar col-1 | body col-2
   ================================================================ */

.ma-app-root {
    display: block;
    background: #f9fafb;
    min-height: 60vh;
}

@media (min-width: 1024px) {
    .ma-app-root {
        display: grid;
        grid-template-columns: 220px 1fr;
        align-items: start;
        min-height: 80vh;
    }

    /* Remove mobile elements do fluxo do grid */
    .ma-mobile-header,
    #ma-mobile-nav {
        display: none !important;
    }

    /* Sidebar: coluna 1, linha 1 */
    .ma-sidebar {
        display: flex !important;
        flex-direction: column;
        grid-column: 1;
        grid-row: 1;
        position: sticky;
        top: 0;
        min-height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        scrollbar-width: none;
    }

    .ma-sidebar::-webkit-scrollbar { display: none; }

    /* App body: coluna 2, linha 1 */
    .ma-app-body {
        grid-column: 2;
        grid-row: 1;
    }
}

/* ================================================================
   COMPONENTES
   ================================================================ */

.ma-app-body {
    width: 100%;
    display: flex;
    flex-direction: column;
}

.ma-main {
    min-width: 0;
    flex: 1;
    padding: 1.25rem;
    background: #f9fafb;
}

@media (min-width: 1024px) {
    .ma-main {
        padding: 2rem;
    }
}

/* ================================================================
   CONTAINER GLOBAL — padding e max-width para todas as páginas
   ================================================================ */
#ma-page-wrap {
    width: 100%;
    min-height: 100vh;
    background: #f9fafb;
}

/* Mercadão público — layout com padding e max-width */
.ma-mercadao {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

@media (min-width: 640px) {
    .ma-mercadao {
        padding: 2rem 1.5rem;
    }
}

@media (min-width: 1024px) {
    .ma-mercadao {
        padding: 2.5rem 2rem;
    }
}

/* Auth + Mercadão: reset mínimo fora do .ma-app-root */
.ma-auth-wrap,
.ma-auth-wrap *,
.ma-auth-wrap *::before,
.ma-auth-wrap *::after,
.ma-mercadao,
.ma-mercadao *,
.ma-mercadao *::before,
.ma-mercadao *::after {
    box-sizing: border-box;
}

.ma-auth-wrap,
.ma-mercadao {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #111827;
    -webkit-font-smoothing: antialiased;
}

/* Auth pages */
.ma-auth-wrap {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: #f9fafb;
}

/* Line clamp */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Toast notification */
.ma-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(2rem);
    background: #1e293b;
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
}

.ma-toast.ma-toast--show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ma-toast.ma-toast--success { background: #059669; }
.ma-toast.ma-toast--error   { background: #dc2626; }

.ma-fav-btn.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Focus ring acessível */
.ma-app-root a:focus-visible,
.ma-app-root button:focus-visible,
.ma-app-root input:focus-visible,
.ma-app-root select:focus-visible,
.ma-app-root textarea:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Mercadão mobile grid */
@media (max-width: 479px) {
    .ma-mercadao .grid {
        grid-template-columns: 1fr 1fr;
    }
}
