/* ============================================================
   JustNEasy — Backoffice CSS
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block');

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    vertical-align: middle;
    user-select: none;
}

:root {
    --primary: #C96B4B;
    --secondary: #B55C3D;
    --background: #F5F6F6;
    --text: #4A4540;
    --sidebar-bg: #1F272B;
    --sidebar-text: #ffffff;
    --sidebar-text-rgb: 255, 255, 255;
    --sidebar-width: 240px;
    --white: #ffffff;
    --gray-100: #f8f8f8;
    --gray-200: #eeeeee;
    --gray-300: #dddddd;
    --gray-500: #999999;
    --gray-600: #777777;
    --gray-700: #555555;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #f44336;
    --info: #2196F3;
    --radius: 8px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
    --transition: 0.2s ease;
    --surface: #ffffff;
    --page-bg: #f5f5f5;
    --accent: #4FC7C5;

    /* Hero ícones */
    --hero-icon-bg: rgba(255,255,255,0.8);
    --hero-icon-border: rgba(255,255,255,0.9);
    --hero-stat-icon-bg: rgba(255,255,255,0.7);
    --hero-badge-bg: #d9f8f4;
    --hero-badge-color: #0e9d87;

    /* Topbar */
    --topbar-height: 72px;
    --color-primary-soft: #e8faf7;
    --color-text-muted: #6f7782;
    --color-border: #e6e9ed;
    --shadow-topbar: 0 4px 18px rgba(24, 39, 51, 0.07);
}

[data-theme="dark"] {
    color-scheme: dark;
    --background: #1F242B;
    --text: #f0f0f0;
    --white: #2A3038;
    --gray-100: #363D47;
    --gray-200: #434B56;
    --gray-300: #535C68;
    --gray-400: #8A939F;
    --gray-500: #AEB7C2;
    --gray-600: #AEB7C2;
    --gray-700: #d4dae0;
    --surface: #2A3038;
    --page-bg: #1F242B;
    --shadow: 0 2px 12px rgba(0,0,0,0.5);
    --color-border: #363D47;
    --color-text-muted: #8A939F;
    --sidebar-bg: #181E23;
    --sidebar-text: #e8ecf0;

    /* Hero ícones — dark */
    --hero-icon-bg: rgba(255,255,255,0.08);
    --hero-icon-border: rgba(255,255,255,0.10);
    --hero-stat-icon-bg: rgba(255,255,255,0.07);
    --hero-badge-bg: #1a3a38;
    --hero-badge-color: #3ab8b0;
}

/* Dark mode — body e headings explícitos */
[data-theme="dark"] body {
    background: #1F242B;
    color: #f0f0f0;
}
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] p,
[data-theme="dark"] span,
[data-theme="dark"] strong,
[data-theme="dark"] label {
    color: inherit;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ============================================================
   ACESSIBILIDADE — FOCO E TOQUE
   ============================================================
   Corrige o contorno/sombra azul visível ao tocar/clicar em botões e
   cards — dois efeitos distintos do próprio browser, nenhum deles vindo
   de CSS deste projeto (sem Tailwind, sem "ring" nenhum — confirmado por
   grep ao repositório inteiro):
   1) -webkit-tap-highlight-color — o "flash" translúcido que o Chrome/
      WebView do Android desenha sobre qualquer elemento tocado, mesmo
      sem esse elemento alguma vez ganhar foco a sério.
   2) O contorno azul nativo de :focus do browser em botões/links/campos
      sem estilo de foco próprio.
   A correção nunca é "outline: none" cego — isso tiraria a indicação de
   foco a quem navega por teclado. Em vez disso, a regra :focus (abaixo)
   tira o contorno por defeito, e a regra :focus-visible a seguir
   repõe-no só quando o foco É de teclado — como as duas têm a mesma
   especificidade, a ordem no ficheiro é o que decide (:focus-visible
   por último, ganha nos casos em que as duas se aplicam ao mesmo
   elemento). Global de propósito, à semelhança do
   .topbar button:focus-visible mais abaixo — corrige a origem uma vez,
   em vez de repetir por componente (o projeto não tem CSS modules). */
* {
    -webkit-tap-highlight-color: transparent;
}

button:focus,
a:focus,
[role="button"]:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
}

button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* App do cliente — modal de detalhe (DetailModal.jsx): bottom sheet a
   toda a largura em ecrãs estreitos (telemóvel), modal centrado com
   cantos arredondados dos dois lados a partir de 640px (tablet/desktop).
   Cores/animações do próprio componente ficam inline (o resto do projeto
   é assim); só a mudança de layout por breakpoint precisa mesmo de CSS. */
.jne-detail-overlay {
    align-items: flex-end;
}
.jne-detail-sheet {
    border-radius: 24px 24px 0 0;
    max-height: 92vh;
}
@media (min-width: 640px) {
    .jne-detail-overlay {
        align-items: center;
        padding: 24px;
        box-sizing: border-box;
    }
    .jne-detail-sheet {
        border-radius: 24px;
        max-height: 88vh;
    }
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: #F5F6F6;
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}
.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 22px 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header > div {
    text-align: center;
    width: 100%;
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--primary);
}

.sidebar-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--sidebar-text);
    letter-spacing: 0.01em;
}

.sidebar-subtitle {
    font-size: 11px;
    color: rgba(var(--sidebar-text-rgb), 0.45);
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
    scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin: 1px 8px;
    color: rgba(var(--sidebar-text-rgb), 0.58);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
    background: rgba(var(--sidebar-text-rgb), 0.08);
    color: rgba(var(--sidebar-text-rgb), 0.95);
}

.nav-item:hover > .material-symbols-outlined {
    color: #4FC7C5;
}

.nav-item.active {
    background: rgba(79, 199, 197, 0.1);
    color: #fff;
    box-shadow: inset 3px 0 0 #4FC7C5;
}

.nav-item.active > .material-symbols-outlined {
    color: #4FC7C5;
}

.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

/* Item da sidebar que é uma ação (ex: Platform → "Jobs do sistema") — <button>
   com o mesmo aspeto do .nav-item: só repõe o que o browser traz de origem num
   botão (fundo, borda, tipo de letra, largura). :hover/.active continuam a vir do
   .nav-item (mais específicos) e o foco por teclado do button:focus-visible global. */
button.nav-item {
    width: calc(100% - 16px);
    background: none;
    border: 0;
    font: inherit;
    font-size: 13.5px;
    text-align: start;
    cursor: pointer;
}

.nav-separator {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 6px 16px;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(var(--sidebar-text-rgb), 0.07);
    font-size: 12px;
    color: rgba(var(--sidebar-text-rgb), 0.5);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-logout {
    background: none;
    border: none;
    color: rgba(var(--sidebar-text-rgb), 0.5);
    cursor: pointer;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.btn-logout:hover { color: var(--white); background: rgba(255,255,255,0.1); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */

.main {
    margin-left: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}
@media (min-width: 1024px) {
    body.sidebar-open .main { margin-left: var(--sidebar-width); }
}

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px 30px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 24px;
    margin: 10px 10px 0 10px;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-topbar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.topbar__left,
.topbar__actions {
    display: flex;
    align-items: center;
}
.topbar__left  { min-width: 0; gap: 22px; }
.topbar__actions { gap: 14px; flex-shrink: 0; }

/* Hamburger */
.topbar__menu-button {
    width: 42px;
    height: 42px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}
.topbar__menu-button:hover  { background: #f2f4f5; }
.topbar__menu-button:active { transform: scale(0.96); }
.topbar__menu-button span {
    width: 24px;
    height: 2px;
    display: block;
    border-radius: 999px;
    background: var(--primary);
}

/* Divisória */
.topbar__divider {
    width: 1px;
    height: 36px;
    flex-shrink: 0;
    background: var(--color-border);
}

/* Breadcrumb */
.topbar__breadcrumb {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    white-space: nowrap;
}
.topbar__breadcrumb-parent {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text-muted);
}
.topbar__breadcrumb-separator {
    color: #a1a7ae;
    font-size: 20px;
    line-height: 1;
}
.topbar__breadcrumb-current {
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
    color: #14171a;
}

/* Botões de ícone */
.topbar__icon-button {
    position: relative;
    width: 44px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: #ffffff;
    color: #1d2327;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.topbar__icon-button:hover {
    background: #f8f9fa;
    border-color: #d8dde2;
    box-shadow: 0 4px 12px rgba(18, 38, 63, 0.08);
}
.topbar__icon-button:active { transform: scale(0.96); }

.topbar__notification-button { overflow: visible; }
.topbar__bell { display: block; font-size: 22px; }

.topbar__notification-badge {
    position: absolute;
    top: -8px;
    right: -7px;
    min-width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 3px solid #ffffff;
    border-radius: 999px;
    background: #ef1d28;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

/* Avatar */
.topbar__avatar {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    font: inherit;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.topbar__avatar:hover {
    background: var(--secondary);
    box-shadow: 0 4px 12px rgba(201, 107, 75, 0.3);
}
.topbar__avatar:active { transform: scale(0.96); }

/* Acessibilidade */
.topbar button:focus-visible,
.topbar a:focus-visible {
    outline: 3px solid rgba(49, 196, 178, 0.28);
    outline-offset: 3px;
}

/* Responsivo */
@media (max-width: 900px) {
    .topbar { padding-inline: 18px; }
    .topbar__breadcrumb-parent,
    .topbar__breadcrumb-separator { display: none; }
}
@media (max-width: 600px) {
    .topbar { min-height: 62px; gap: 12px; padding: 9px 12px; }
    .topbar__left { gap: 10px; }
    .topbar__divider { display: none; }
    .topbar__breadcrumb { max-width: 145px; font-size: 14px; }
    .topbar__actions { gap: 8px; }
    .topbar__icon-button,
    .topbar__avatar { width: 40px; height: 40px; min-height: 40px; }
}

.topbar-title { font-size: 20px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.save-bar {
    position: sticky;
    top: var(--topbar-height);
    z-index: 49;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: #fff8e6;
    border-bottom: 2px solid #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.18);
    animation: save-bar-in 0.2s ease;
}

@keyframes save-bar-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.content { padding: 24px; flex: 1; display: flex; flex-direction: column; }

/* ============================================================
   CARDS & KPIs
   ============================================================ */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.kpi-label { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
}

.card-body { padding: 20px; }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--secondary); }
.btn-primary:active { transform: scale(0.95); box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.btn-secondary { background: var(--gray-200); color: var(--text); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-secondary:active { transform: scale(0.95); box-shadow: inset 0 2px 4px rgba(0,0,0,0.15); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { opacity: 0.9; }
.btn-danger:active { transform: scale(0.95); box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { opacity: 0.9; }
.btn-success:active { transform: scale(0.95); box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; border-radius: 6px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ============================================================
   TOOLTIP
   ============================================================ */
#app-tooltip {
    position: fixed;
    z-index: 9999;
    background: #333;
    color: #fff;
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    max-width: 220px;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
}

@keyframes btnSpin {
    to { transform: rotate(360deg); }
}
.btn-loading {
    pointer-events: none;
    opacity: 0.75;
}
.btn-loading::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
    margin-right: 4px;
    flex-shrink: 0;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    background: var(--gray-100);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
}
tbody td { padding: 12px; border-bottom: 1px solid var(--gray-200); }
tbody tr:hover { background: var(--gray-100); }
tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   FORMS
   ============================================================ */

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    background: var(--white);
    transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--primary); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-window {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 16px;
}

.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-500);
    line-height: 1;
}
.btn-close:hover { color: var(--text); }

/* ============================================================
   BADGES & STATUS
   ============================================================ */

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-pending   { background: #FFF3E0; color: #E65100; }
.badge-queued    { background: #FFF8E1; color: #F57F17; }
.badge-preparing { background: #E3F2FD; color: #1565C0; }
.badge-ready     { background: #E8F5E9; color: #2E7D32; }
.badge-picked_up { background: #F3E5F5; color: #6A1B9A; }
.badge-cancelled { background: #FFEBEE; color: #B71C1C; }
.badge-basic { background: var(--gray-200); color: var(--gray-700); }
.badge-standard { background: #E3F2FD; color: #1565C0; }
.badge-premium { background: #FFF8E1; color: #F57F17; }

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */

.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--gray-300);
    border-radius: 22px;
    transition: var(--transition);
}

.toggle-slider:before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--white);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-success { background: #E8F5E9; color: #2E7D32; border: 1px solid #A5D6A7; }
.alert-danger { background: #FFEBEE; color: #B71C1C; border: 1px solid #FFCDD2; }
.alert-info { background: #E3F2FD; color: #1565C0; border: 1px solid #BBDEFB; }
.alert-warning { background: #FFF8E1; color: #F57F17; border: 1px solid #FFE082; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    width: 100%;
    background: var(--background);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-logo {
    font-size: 40px;
    margin-bottom: 8px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 32px;
}

/* ============================================================
   UTILITIES
   ============================================================ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); font-size: 13px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ============================================================
   SIDEBAR — GRUPOS
   ============================================================ */

.nav-group-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(79,199,197,0.5);
    padding: 16px 18px 5px;
}

.nav-group { margin-bottom: 2px; }

.nav-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin: 1px 8px;
    color: rgba(255,255,255,0.6);
    font-size: 13.5px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}

.nav-group-header:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-group-header.active {
    color: #fff;
}

.nav-group-arrow {
    margin-left: auto;
    font-size: 10px;
    color: rgba(255,255,255,0.3);
}

.nav-group-items { overflow: hidden; }

.nav-item-child {
    padding-left: 26px;
    font-size: 13px;
}

/* SIDEBAR CARDS */
.nav-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;
}
.nav-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 10px;
    text-decoration: none;
    color: rgba(255,255,255,0.8);
    transition: var(--transition);
    border: 2px solid transparent;
    text-align: center;
}
.nav-card:hover {
    background: rgba(255,255,255,0.18);
    color: white;
}
.nav-card.active {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.4);
    color: white;
}
.nav-card-icon { font-size: 22px; }
.nav-card-label { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; }

/* ============================================================
   SIDEBAR — FAVORITOS
   ============================================================ */

.nav-fav-section {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(79,199,197,0.5);
    padding: 10px 18px 4px;
}

.nav-fav-btn {
    opacity: 0;
    background: none;
    border: none;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    font-size: 14px;
    padding: 0 0 0 4px;
    margin-left: auto;
    line-height: 1;
    transition: color 0.15s, transform 0.15s, opacity 0.15s;
    flex-shrink: 0;
}

.nav-item:hover .nav-fav-btn {
    opacity: 1;
}

.nav-fav-btn.is-fav {
    opacity: 1;
    color: #4FC7C5;
}

.nav-fav-btn:hover {
    color: #4FC7C5 !important;
    transform: scale(1.2);
}

/* Cards variant */
.nav-card { position: relative; }

.nav-fav-btn-card {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 11px;
    padding: 0;
    margin-left: 0;
}

.nav-card:hover .nav-fav-btn-card {
    opacity: 1;
}

.nav-cards-fav-label {
    grid-column: 1 / -1;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: rgba(255,255,255,0.4);
    padding: 6px 4px 0;
}

.nav-cards-divider {
    grid-column: 1 / -1;
    height: 1px;
    background: rgba(255,255,255,0.12);
    margin: 4px 0;
}

.nav-collapse-btn {
    width: 100%;
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 16px;
    text-align: left;
    cursor: pointer;
    transition: color 0.15s;
}
.nav-collapse-btn:hover { color: rgba(255,255,255,0.8); }

.nav-edit-favs-btn {
    display: block;
    width: calc(100% - 24px);
    margin: 8px 12px 4px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: rgba(255,255,255,0.5);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
}
.nav-edit-favs-btn:hover {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.85);
}
.nav-edit-favs-btn.is-editing {
    background: rgba(76,175,80,0.18);
    border-color: rgba(76,175,80,0.4);
    color: #81c784;
}
.nav-edit-favs-btn.is-editing:hover {
    background: rgba(76,175,80,0.28);
    color: #a5d6a7;
}

.nav-edit-hint {
    font-size: 11px;
    color: rgba(255,255,255,0.35);
    padding: 6px 16px 0;
    font-style: italic;
}

/* ============================================================
   RESPONSIVO
   ============================================================ */

.btn-menu {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--text);
    align-items: center;
    line-height: 1;
    flex-shrink: 0;
}
.btn-menu:hover { background: var(--gray-200); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 150;
}
.sidebar-overlay.open { display: block; }
@media (min-width: 1024px) {
    .sidebar-overlay { display: none !important; }
}

/* Tablet */
@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .form-row-3 { grid-template-columns: 1fr 1fr; }
    .btn-menu {
        display: flex;
    }
    .topbar__left { gap: 12px; }
}

/* Mobile */
@media (max-width: 768px) {
    .content {
        padding: 16px;
    }
    .grid-2, .grid-3 {
        grid-template-columns: min(480px, 100%);
        justify-content: center;
    }
    .form-row, .form-row-3 {
        grid-template-columns: 1fr;
    }
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
    .login-card {
        padding: 28px 20px;
    }

    /* ── Heroes: compactos em mobile ────────────────────── */
    .page-hero {
        padding: 16px 20px !important;
        min-height: unset !important;
        gap: 12px !important;
    }
    /* Bloco decorativo (sempre 2º filho direto do hero) */
    .page-hero > div:nth-child(2) {
        display: none !important;
    }
    /* Stats do hero (2º filho dentro do 1º bloco) */
    .page-hero > div:first-child > div:nth-child(2) {
        display: none !important;
    }
    /* Hero do dashboard já tem classes próprias */
    .dash-hero.page-hero { padding: 16px 20px !important; }
    .dash-hero-deco { display: none !important; }
    .dash-hero-stats { display: none !important; }

    /* ── Touch targets mínimos 44px ─────────────────────── */
    .btn-close,
    .btn-icon,
    .modal-close {
        min-width: 44px !important;
        min-height: 44px !important;
    }
    /* Botão ⋮ dos cards */
    .btn-icon {
        min-width: 44px !important;
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* ── Topbar em mobile ────────────────────────────────── */
    .topbar {
        padding: 10px 14px !important;
        border-radius: 12px !important;
        margin: 8px 8px 0 !important;
    }
}

/* Telemóvel pequeno */
@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: min(360px, 100%);
        justify-content: center;
    }
}

/* ============================================================
   TOUCH MODE
   ============================================================ */

body.touch-mode .sidebar,
body.touch-mode .sidebar-overlay { display: none !important; }

body.touch-mode .main { margin-left: 0 !important; }

body.touch-mode .topbar { padding: 0 16px; }

body.touch-mode .btn-menu { display: none; }

/* Topbar — dark mode */
[data-theme="dark"] .topbar {
    background: rgba(31, 36, 43, 0.96);
    border-bottom-color: #363D47;
}
[data-theme="dark"] .topbar__menu-button span { background: #AEB7C2; }
[data-theme="dark"] .topbar__menu-button:hover { background: rgba(255,255,255,0.06); }
[data-theme="dark"] .topbar__divider { background: #363D47; }
[data-theme="dark"] .topbar__breadcrumb-parent { color: #8A939F; }
[data-theme="dark"] .topbar__breadcrumb-separator { color: #535C68; }
[data-theme="dark"] .topbar__breadcrumb-current { color: #f0f0f0; }
[data-theme="dark"] .topbar__icon-button {
    background: #2A3038;
    border-color: #363D47;
    color: #AEB7C2;
}
[data-theme="dark"] .topbar__icon-button:hover {
    background: #363D47;
    border-color: #434B56;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .topbar__notification-badge { border-color: #1F242B; }
[data-theme="dark"] .topbar__avatar {
    background: var(--primary);
    border-color: transparent;
    color: #ffffff;
}
[data-theme="dark"] .topbar__avatar:hover {
    background: var(--secondary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Badges — dark mode */
[data-theme="dark"] .badge-pending   { background: rgba(230, 81, 0, 0.18);  color: #ffab6b; }
[data-theme="dark"] .badge-queued    { background: rgba(245, 127, 23, 0.18); color: #ffd470; }
[data-theme="dark"] .badge-preparing { background: rgba(21, 101, 192, 0.18); color: #7ab6f5; }
[data-theme="dark"] .badge-ready     { background: rgba(46, 125, 50, 0.18);  color: #6dd47a; }
[data-theme="dark"] .badge-picked_up { background: rgba(106, 27, 154, 0.18); color: #c98ef5; }
[data-theme="dark"] .badge-cancelled { background: rgba(183, 28, 28, 0.18);  color: #f77; }
[data-theme="dark"] .badge-basic     { background: #363D47; color: #AEB7C2; }
[data-theme="dark"] .badge-standard  { background: rgba(21, 101, 192, 0.18); color: #7ab6f5; }
[data-theme="dark"] .badge-premium   { background: rgba(245, 127, 23, 0.18); color: #ffd470; }

/* Alerts — dark mode */
[data-theme="dark"] .alert-success { background: rgba(46, 125, 50, 0.15);  color: #6dd47a; border-color: rgba(46, 125, 50, 0.3); }
[data-theme="dark"] .alert-danger  { background: rgba(183, 28, 28, 0.15);  color: #f77;    border-color: rgba(183, 28, 28, 0.3); }
[data-theme="dark"] .alert-info    { background: rgba(21, 101, 192, 0.15); color: #7ab6f5; border-color: rgba(21, 101, 192, 0.3); }
[data-theme="dark"] .alert-warning { background: rgba(245, 127, 23, 0.15); color: #ffd470; border-color: rgba(245, 127, 23, 0.3); }

/* Save-bar — dark mode */
[data-theme="dark"] .save-bar {
    background: rgba(245, 158, 11, 0.12);
    border-bottom-color: #b07a00;
}

/* Page hero — Normal mode */
.page-hero {
    background:
        radial-gradient(circle at 78% 20%, rgba(74,213,196,0.18), transparent 20%),
        linear-gradient(110deg, #eefbff 0%, #f7ffff 55%, #edfafa 100%);
    border: 1px solid #d8ecea;
}
[data-theme="dark"] .page-hero {
    background:
        radial-gradient(circle at 78% 20%, rgba(74,213,196,0.08), transparent 20%),
        linear-gradient(110deg, #1a2530 0%, #1F242B 55%, #1c2830 100%);
    border: 1px solid #2a3a40;
}

body.touch-mode .touch-home-btn {
    display: inline-flex !important;
    align-items: center; justify-content: center;
    width: 44px; height: 44px;
    border: none; border-radius: var(--radius);
    background: var(--gray-100);
    color: var(--text);
    cursor: pointer;
    font-size: 22px;
    flex-shrink: 0;
    transition: background 0.15s;
}

body.touch-mode .touch-home-btn:hover {
    background: var(--gray-200);
}

body.touch-mode .btn {
    min-height: 52px;
    font-size: 15px;
    padding: 12px 20px;
}

body.touch-mode .form-control,
body.touch-mode select.form-control,
body.touch-mode input.form-control,
body.touch-mode textarea.form-control {
    min-height: 52px;
    font-size: 16px;
    padding: 12px 14px;
}

body.touch-mode table td,
body.touch-mode table th {
    padding: 14px 12px;
    font-size: 14px;
}

body.touch-mode .modal-window { max-height: 95vh; overflow-y: auto; }

/* Touch dashboard — hide charts, show only KPIs */
body.touch-mode .touch-hide { display: none !important; }
body.touch-mode .kpi-card { padding: 20px; }
body.touch-mode .kpi-card .kpi-value { font-size: 28px; }

/* Touch POS */
body.touch-mode .category-tabs { gap: 10px; padding: 10px 0; }
body.touch-mode .category-tabs button { min-height: 48px; padding: 10px 18px; font-size: 14px; }
body.touch-mode .product-card { min-height: 130px; }

/* Touch orders */
body.touch-mode .order-status-btn { min-height: 56px; font-size: 15px; }

/* Touch select page */
.touch-select-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--background);
    padding: 32px 24px;
    gap: 24px;
}

.touch-select-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
}

.touch-select-subtitle {
    font-size: 14px;
    color: var(--gray-500);
    text-align: center;
    margin-top: -12px;
}

.touch-select-options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 560px;
}

.touch-select-btn {
    flex: 1;
    min-width: 200px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    border: 3px solid transparent;
    border-radius: 16px;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 24px;
    font-family: inherit;
}

.touch-select-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(0,0,0,0.14); }
.touch-select-btn.primary { border-color: var(--primary); }
.touch-select-btn .ts-icon { font-size: 48px; color: var(--primary); }
.touch-select-btn .ts-label { font-size: 18px; font-weight: 700; color: var(--text); }
.touch-select-btn .ts-desc { font-size: 12px; color: var(--gray-500); text-align: center; line-height: 1.4; }

/* Touch home page */
.touch-home-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--text);
}

.touch-home-header {
    padding: 24px 24px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.touch-home-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.touch-home-logo img { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; }
.touch-home-company { font-size: 18px; font-weight: 700; color: white; }
.touch-home-user { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 2px; }

.touch-home-actions { display: flex; gap: 8px; }
.touch-home-actions button {
    background: rgba(255,255,255,0.12);
    border: none;
    border-radius: 10px;
    color: white;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}
.touch-home-actions button:hover { background: rgba(255,255,255,0.2); }

.touch-home-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 16px 24px 32px;
}

.touch-tile {
    background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px 16px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    min-height: 140px;
}

.touch-tile:hover, .touch-tile:active {
    background: rgba(255,255,255,0.16);
    border-color: var(--primary);
    transform: scale(0.97);
}

.touch-tile-icon {
    font-size: 40px;
    color: white;
}

.touch-tile-label {
    font-size: 16px;
    font-weight: 600;
    color: white;
    text-align: center;
}

.touch-tile-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--danger);
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    min-width: 28px;
    text-align: center;
}

.touch-tile.highlight {
    background: var(--primary);
    border-color: var(--primary);
}

@keyframes tile-wiggle {
    0%, 100% { transform: translateX(0px); }
    50% { transform: translateX(-3px); }
}

.touch-home-grid.is-editing .touch-tile {
    animation: tile-wiggle 1.2s ease-in-out infinite;
    cursor: grab;
}

.touch-home-grid.is-editing .touch-tile:nth-child(even) {
    animation-delay: 0.6s;
}

.touch-tile-ghost {
    opacity: 0.3;
}

.touch-tile-chosen {
    cursor: grabbing !important;
    animation: none !important;
    transform: scale(1.04);
    box-shadow: 0 8px 28px rgba(0,0,0,0.25);
    z-index: 10;
}

.touch-edit-done-btn {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 28px;
    padding: 14px 36px;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 100;
    display: none;
}

.touch-edit-done-btn.visible { display: block; }

/* Touch home — tema dia */
.touch-home-page.theme-light {
    background: #f0f2f5 !important;
}
.theme-light .touch-home-company { color: #1a1a1a; }
.theme-light .touch-home-user { color: #555; }
.theme-light .touch-home-actions button {
    background: rgba(0,0,0,0.07);
    color: #333;
}
.theme-light .touch-home-actions button:hover { background: rgba(0,0,0,0.13); }
.theme-light .touch-tile {
    background: white;
    border: 2px solid #e5e7eb;
}
.theme-light .touch-tile:hover, .theme-light .touch-tile:active {
    background: #f8f9fa;
    border-color: var(--primary);
}
.theme-light .touch-tile-icon { color: var(--primary); }
.theme-light .touch-tile-label { color: #1a1a1a; }
.theme-light .touch-tile.highlight .touch-tile-icon,
.theme-light .touch-tile.highlight .touch-tile-label { color: white; }
.theme-light .touch-home-footer { color: rgba(0,0,0,0.25); }

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================================
   MOBILE — Evitar auto-zoom do Android/iOS em campos de formulário
   Chrome Android faz zoom automático quando font-size < 16px num input focado.
   Esta regra aplica-se apenas a dispositivos de toque, sem afectar desktop.
   O !important é necessário para sobrepor inline styles dos componentes React.
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
    select,
    textarea,
    [contenteditable="true"] {
        font-size: max(16px, 1em) !important;
    }

    /* Sobrepõe especificamente .form-control (CSS class) */
    .form-control {
        font-size: 16px !important;
    }

    /* Login — contentor não deve esconder conteúdo quando o teclado virtual abre */
    .login-page {
        overflow-y: auto !important;
        position: relative !important;
        min-height: 100dvh !important;
        height: auto !important;
    }
}

/* ============================================================
   POS — layout responsivo (catálogo + carrinho)
   O !important é necessário para sobrepor o gridTemplateColumns
   inline de Pos.jsx.
   ============================================================ */
@media (max-width: 1300px) {
    .pos-main-grid {
        grid-template-columns: 1fr 340px !important;
    }
}

@media (max-width: 950px) {
    .pos-main-grid {
        grid-template-columns: 1fr !important;
    }
    .pos-cart-panel {
        position: static !important;
    }
}
