/* ============================================================================
   SEBASTIAN MOBILE APP - Estilos do layout app nativo
   Inspirado no Asaas - adaptado para gestao juridica
   ============================================================================ */

/* App container - apenas visivel em mobile */
.mapp { display: none; }

@media (max-width: 820px), (pointer: coarse) {

  .mapp {
    display: block;
    padding-bottom: 1rem;
  }

  /* === HEADER === */
  .mapp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.2rem;
    margin-bottom: 0.5rem;
  }

  .mapp-menu-btn {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--txt-main);
    border-radius: 12px; padding: 0;
  }
  .mapp-menu-btn svg { width: 26px; height: 26px; }
  .mapp-menu-btn:active { background: rgba(255,255,255,0.08); transform: scale(0.93); }

  .mapp-header-center { flex: 1; text-align: center; }
  .mapp-logo-text {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-1), #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
  }

  .mapp-header-right {
    display: flex; align-items: center; gap: 0.3rem;
  }

  .mapp-icon-btn {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--txt-sub);
    border-radius: 12px; position: relative; padding: 0;
  }
  .mapp-icon-btn svg { width: 24px; height: 24px; }
  .mapp-icon-btn:active { background: rgba(255,255,255,0.08); transform: scale(0.93); }

  .mapp-notif-dot {
    position: absolute; top: 8px; right: 8px;
    width: 10px; height: 10px;
    background: var(--accent-bad); border-radius: 50%;
    border: 2px solid var(--bg-dark);
    display: none;
  }

  .mapp-profile-btn {
    background: rgba(31,183,199,0.12);
    border: 1px solid rgba(31,183,199,0.2);
  }

  /* === GREETING === */
  .mapp-greeting {
    padding: 0 0.4rem;
    margin-bottom: 1.2rem;
  }
  .mapp-greeting-text {
    font-size: 1.4rem;
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--txt-main);
  }
  .mapp-greeting-sub {
    font-size: 0.85rem;
    color: var(--txt-sub);
    margin-top: 0.15rem;
  }

  /* === QUICK ACTIONS (horizontal scroll like Asaas blue cards) === */
  .mapp-quick-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -0.8rem;
    padding: 0 0.8rem;
  }
  .mapp-quick-scroll::-webkit-scrollbar { display: none; }

  .mapp-quick-actions {
    display: flex;
    gap: 0.65rem;
    padding: 0.2rem 0 1rem;
    width: max-content;
  }

  .mapp-quick-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
    width: 120px;
    min-height: 110px;
    padding: 1rem 0.9rem;
    background: linear-gradient(145deg, var(--accent-1), #1a9aab);
    border: none;
    border-radius: 16px;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 16px rgba(31,183,199,0.25);
  }
  .mapp-quick-card svg {
    width: 28px; height: 28px;
    stroke: #fff; fill: none;
  }
  .mapp-quick-card span {
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
  }
  .mapp-quick-card:active {
    transform: scale(0.95);
    box-shadow: 0 2px 8px rgba(31,183,199,0.3);
  }
  .mapp-quick-card:nth-child(2) {
    background: linear-gradient(145deg, #2563eb, #1d4ed8);
    box-shadow: 0 4px 16px rgba(37,99,235,0.25);
  }
  .mapp-quick-card:nth-child(3) {
    background: linear-gradient(145deg, #7c3aed, #6d28d9);
    box-shadow: 0 4px 16px rgba(124,58,237,0.25);
  }
  .mapp-quick-card:nth-child(4) {
    background: linear-gradient(145deg, #059669, #047857);
    box-shadow: 0 4px 16px rgba(5,150,105,0.25);
  }
  .mapp-quick-card:nth-child(5) {
    background: linear-gradient(145deg, #d97706, #b45309);
    box-shadow: 0 4px 16px rgba(217,119,6,0.25);
  }

  /* === SUMMARY CARD (like Asaas "Saldo" card) === */
  .mapp-summary-card {
    display: flex;
    align-items: center;
    background: var(--bg-box);
    border: 1px solid var(--stroke-soft);
    border-radius: 18px;
    padding: 1.1rem 1.2rem;
    margin-bottom: 1.2rem;
    cursor: pointer;
    transition: transform 0.15s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  }
  .mapp-summary-card:active { transform: scale(0.98); }

  .mapp-summary-row {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
  }

  .mapp-summary-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
  }

  .mapp-summary-label {
    font-size: 0.75rem;
    color: var(--txt-sub);
    letter-spacing: 0.02em;
  }

  .mapp-summary-value {
    font-size: 1.8rem;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--txt-main);
    line-height: 1;
  }

  .mapp-summary-divider {
    width: 1px;
    height: 40px;
    background: var(--stroke-soft);
  }

  .mapp-summary-arrow {
    color: var(--txt-sub);
    flex-shrink: 0;
    margin-left: 0.5rem;
  }

  /* === FEATURE GRID (4x2 like Asaas) === */
  .mapp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.5rem;
  }

  .mapp-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    padding: 0.9rem 0.4rem;
    background: var(--bg-box);
    border: 1px solid var(--stroke-soft);
    border-radius: 16px;
    text-decoration: none;
    color: var(--txt-main);
    transition: transform 0.15s ease;
    cursor: pointer;
  }
  .mapp-grid-item:active { transform: scale(0.93); }

  .mapp-grid-icon {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(31,183,199,0.1);
    border-radius: 14px;
  }
  .mapp-grid-icon svg {
    width: 24px; height: 24px;
    stroke: var(--accent-1); fill: none;
  }

  .mapp-grid-icon--alert {
    position: relative;
  }
  .mapp-grid-icon--alert::after {
    content: '';
    position: absolute; top: -2px; right: -2px;
    width: 10px; height: 10px;
    background: var(--accent-bad);
    border-radius: 50%;
    border: 2px solid var(--bg-box);
    display: none;
  }

  .mapp-grid-item span {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--txt-sub);
    text-align: center;
    line-height: 1.2;
  }

  /* === SECTIONS (Prazos, Publicacoes) === */
  .mapp-section {
    background: var(--bg-box);
    border: 1px solid var(--stroke-soft);
    border-radius: 18px;
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  }

  .mapp-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem 0.5rem;
  }

  .mapp-section-title {
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-display);
    color: var(--txt-main);
  }

  .mapp-section-link {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    color: var(--txt-sub);
    border-radius: 50%;
    text-decoration: none;
  }
  .mapp-section-link:active { background: rgba(255,255,255,0.06); }

  .mapp-section-body {
    padding: 0 0.8rem 0.8rem;
  }

  /* === LIST ITEMS === */
  .mapp-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.75rem 0.3rem;
    border-bottom: 1px solid rgba(148,163,184,0.1);
  }
  .mapp-list-item:last-child { border-bottom: none; }

  .mapp-list-item-main { flex: 1; min-width: 0; }

  .mapp-list-item-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--txt-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mapp-list-item-sub {
    font-size: 0.75rem;
    color: var(--txt-sub);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mapp-list-item-badge {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--txt-sub);
    background: rgba(15,23,42,0.5);
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    white-space: nowrap;
  }

  .mapp-list-item.mapp-urgent .mapp-list-item-badge {
    background: rgba(239,68,68,0.15);
    color: var(--accent-bad);
  }
  .mapp-list-item.mapp-urgent .mapp-list-item-title {
    color: var(--accent-bad);
  }

  /* === EMPTY STATE === */
  .mapp-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--txt-sub);
    font-size: 0.85rem;
  }

  /* === SKELETON LOADING === */
  .mapp-skeleton {
    background: linear-gradient(90deg,
      rgba(255,255,255,0.04) 25%,
      rgba(255,255,255,0.08) 50%,
      rgba(255,255,255,0.04) 75%
    );
    background-size: 200% 100%;
    animation: mappShimmer 1.5s infinite;
    border-radius: 12px;
    margin-bottom: 0.5rem;
  }
  @keyframes mappShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }
}

/* ============================================================================
   MOBILE PAGES - Estilos para TODAS as paginas (nao-dashboard)
   ============================================================================ */

  /* === PAGE HEADER (back + title + menu) === */
  .mpage-header {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.2rem;
    margin-bottom: 0.6rem;
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(11,17,32,0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--stroke-soft);
    margin-left: -0.8rem;
    margin-right: -0.8rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .mpage-back {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--txt-main);
    border-radius: 12px; padding: 0; flex-shrink: 0;
  }
  .mpage-back svg { width: 24px; height: 24px; }
  .mpage-back:active { background: rgba(255,255,255,0.08); transform: scale(0.93); }

  .mpage-title {
    flex: 1;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--txt-main);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mpage-header-right {
    display: flex; align-items: center; gap: 0.2rem;
  }

  .mpage-icon-btn {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--txt-sub);
    border-radius: 12px; padding: 0;
  }
  .mpage-icon-btn svg { width: 24px; height: 24px; }
  .mpage-icon-btn:active { background: rgba(255,255,255,0.08); transform: scale(0.93); }

  /* === SEARCH CARD (clients page) === */
  .mpage-search-card {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 0.5rem !important;
  }
  .mpage-search-card h2 { display: none; }
  .mpage-search-card input {
    border-radius: 14px !important;
    background: var(--bg-box) !important;
    border: 1px solid var(--stroke-soft) !important;
    padding: 0.9rem 1rem !important;
    font-size: 16px !important;
  }

  /* === PILL ACTIONS (clients search buttons) === */
  .mpage-pill-actions {
    display: flex !important;
    gap: 0.4rem !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.3rem;
  }
  .mpage-pill-actions::-webkit-scrollbar { display: none; }
  .mpage-pill-actions button {
    flex-shrink: 0;
    border-radius: 20px !important;
    padding: 0.5rem 1rem !important;
    font-size: 0.82rem !important;
    white-space: nowrap;
    min-height: 38px !important;
  }

  /* === SCROLL TABS (client nav, task tabs, crm nav) === */
  .mpage-scroll-tabs {
    display: flex !important;
    overflow-x: auto !important;
    gap: 0.4rem !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.3rem;
    margin-bottom: 0.5rem;
  }
  .mpage-scroll-tabs::-webkit-scrollbar { display: none; }
  .mpage-scroll-tabs > * {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* === BUTTON GROUPS (actions in cards) === */
  .mpage-btn-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
  }
  .mpage-btn-group button {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    width: auto !important;
    padding: 0.45rem 0.65rem !important;
    font-size: 0.8rem !important;
    white-space: nowrap;
    border-radius: 8px !important;
    min-height: 38px !important;
  }

  /* === CARDS OTIMIZADOS === */
  .mpage-card {
    border-radius: 16px;
  }

  /* === FORM ROWS === */
  .mpage-form-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.6rem !important;
  }

  /* === MODAL BOTTOM SHEET === */
  .mpage-modal {
    border-radius: 16px 16px 0 0;
  }

  /* === FLOATING ACTION BUTTON === */
  .mpage-fab {
    position: fixed;
    bottom: calc(var(--m-nav-h, 68px) + env(safe-area-inset-bottom, 0px) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-1), #38bdf8);
    border: none;
    color: #0a1628;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(31,183,199,0.4);
    z-index: 90;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }
  .mpage-fab svg {
    width: 28px; height: 28px;
  }
  .mpage-fab:active {
    transform: scale(0.9);
    box-shadow: 0 3px 12px rgba(31,183,199,0.3);
  }

  /* === FINANCE SUMMARY TOP === */
  .mpage-finance-summary {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
    margin-bottom: 0.5rem;
  }

  /* === COMPACT CONTROLS === */
  .mpage-compact-controls {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
  }
  .mpage-compact-controls select,
  .mpage-compact-controls input {
    flex: 1;
    min-width: 120px;
  }
  .mpage-compact-controls button {
    flex-shrink: 0;
  }

  /* === PUBLICATION TOOLBAR === */
  .mpage-pub-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }
  .mpage-pub-toolbar input[type="date"] {
    width: 100%;
  }

  /* === CLIENT DETAIL - process cards melhorados === */
  .process-card {
    border-radius: 14px;
    padding: 0.8rem;
  }
  .process-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .process-title {
    font-size: 0.9rem;
    word-break: break-word;
  }
  .process-actions {
    width: 100%;
  }

  /* === ANDAMENTO ITEMS === */
  .andamento-item {
    border-radius: 10px;
    padding: 0.65rem;
  }

  /* === ENTRIES (finance) === */
  .entry-row {
    grid-template-columns: 1fr !important;
    gap: 0.5rem;
    padding: 0.7rem;
    border-radius: 12px;
    background: rgba(15,23,42,0.3);
    border: 1px solid var(--stroke-soft);
    margin-bottom: 0.5rem;
  }

  /* === CRM BOARD improvements === */
  .crm-board {
    padding-bottom: 0.5rem;
  }

  /* === HIDE REDUNDANT ELEMENTS on mobile === */
  .page-subtitle { font-size: 0.8rem; margin-top: 0.1rem; }

/* Small phones - grid 3 columns */
@media (max-width: 360px) {
  .mapp-grid { grid-template-columns: repeat(3, 1fr); }
  .mapp-quick-card { width: 105px; min-height: 100px; padding: 0.85rem 0.75rem; }
  .mapp-greeting-text { font-size: 1.2rem; }
  .mapp-summary-value { font-size: 1.5rem; }
  .mpage-fab { width: 48px; height: 48px; bottom: calc(var(--m-nav-h, 68px) + env(safe-area-inset-bottom, 0px) + 12px); right: 12px; }
  .mpage-fab svg { width: 24px; height: 24px; }
}
