/*
 * Mac UX Design System — Copos
 * Tipografia: Poppins (Google Fonts) com fallback para system fonts.
 * Paleta neutra; ajustar quando definir identidade.
 */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
    /* ====== Tipografia ====== */
    --font-sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text',
                 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;

    /* ====== Tokens responsivos ====== */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --container-pad: 28px;
    --btn-h: 40px;
    --btn-h-sm: 32px;
    --btn-h-lg: 48px;
    --input-h: 44px;
    --font-base: 14px;
    --font-h1: 32px;
    --font-h2: 24px;
    --font-h3: 18px;

    /* ====== Backgrounds e textos ====== */
    --bg-base: #f5f5f7;
    --bg-surface: rgba(255,255,255,0.72);
    --bg-surface-solid: #ffffff;
    --bg-elevated: #ffffff;
    --bg-hover: rgba(0,0,0,0.04);
    --bg-active: rgba(0,0,0,0.08);

    --text-primary: #1d1d1f;
    --text-secondary: #515154;
    --text-tertiary: #86868b;
    --text-inverse: #ffffff;

    --border: rgba(0,0,0,0.08);
    --border-strong: rgba(0,0,0,0.16);
    --divider: rgba(0,0,0,0.06);

    /* ====== Cores sistema (macOS Sonoma/Sequoia) ====== */
    --blue:   #007aff;
    --indigo: #5856d6;
    --purple: #af52de;
    --pink:   #ff2d55;
    --red:    #ff3b30;
    --orange: #ff9500;
    --yellow: #ffcc00;
    --green:  #34c759;
    --teal:   #5ac8fa;
    --mint:   #00c7be;

    --accent: var(--blue);
    --accent-hover: #0066d6;
    --accent-contrast: #ffffff;

    /* ====== Gradientes ====== */
    --grad-brand:   linear-gradient(135deg, #007aff, #5856d6, #af52de);
    --grad-sunset:  linear-gradient(135deg, #ff9500, #ff3b30);
    --grad-ocean:   linear-gradient(135deg, #5ac8fa, #007aff);
    --grad-mint:    linear-gradient(135deg, #00c7be, #34c759);

    /* ====== Sombras ====== */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.12);
    --shadow-window: 0 30px 80px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(0,0,0,0.1);

    /* ====== Raios ====== */
    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-pill: 9999px;

    /* ====== Animações ====== */
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dark mode automático */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-base: #0f1115;
        --bg-surface: rgba(28,28,32,0.78);
        --bg-surface-solid: #1c1c20;
        --bg-elevated: #1c1c20;
        --bg-hover: rgba(255,255,255,0.06);
        --bg-active: rgba(255,255,255,0.10);
        --text-primary: #f5f5f7;
        --text-secondary: #c0c0c5;
        --text-tertiary: #80808a;
        --border: rgba(255,255,255,0.10);
        --border-strong: rgba(255,255,255,0.20);
        --divider: rgba(255,255,255,0.08);
        color-scheme: dark;
    }
}
html.force-light { color-scheme: light; }
html.force-dark {
    --bg-base: #0f1115;
    --bg-surface: rgba(28,28,32,0.78);
    --bg-surface-solid: #1c1c20;
    --bg-elevated: #1c1c20;
    --bg-hover: rgba(255,255,255,0.06);
    --bg-active: rgba(255,255,255,0.10);
    --text-primary: #f5f5f7;
    --text-secondary: #c0c0c5;
    --text-tertiary: #80808a;
    --border: rgba(255,255,255,0.10);
    --border-strong: rgba(255,255,255,0.20);
    --divider: rgba(255,255,255,0.08);
    color-scheme: dark;
}

/* ====== Reset ====== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: var(--font-sans);
    font-size: var(--font-base);
    line-height: 1.55;
    color: var(--text-primary);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    letter-spacing: -0.005em;
}

a, a:hover, a:focus, a:active, a:visited { text-decoration: none; }
a { color: var(--accent); }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: var(--font-h1); }
h2 { font-size: var(--font-h2); }
h3 { font-size: var(--font-h3); }
h4 { font-size: 16px; }

p { margin: 0 0 16px; color: var(--text-secondary); }

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

::selection { background: var(--accent); color: #fff; }

/* ====== Scrollbar Mac ====== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.22);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.36); background-clip: padding-box; }

/* ====== Utilidades ====== */
.container { max-width: 1440px; margin: 0 auto; padding: 0 var(--container-pad); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 16px; align-items: center; }
.spacer { flex: 1; }

/* ====== Card / Surface ====== */
.mac-card {
    background: var(--bg-elevated);
    border-radius: var(--r-lg);
    box-shadow: none;
    border: 0.5px solid var(--border);
    padding: 24px;
}

.mac-surface {
    background: var(--bg-surface);
    backdrop-filter: saturate(180%) blur(22px);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    border: 0.5px solid var(--border);
    border-radius: var(--r-lg);
}

/* ====== Botões ====== */
.mac-btn {
    appearance: none;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--btn-h);
    padding: 10px 18px;
    border-radius: var(--r-sm);
    border: 0.5px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: inherit;
    font-weight: 500; font-size: 13.5px;
    letter-spacing: -0.005em;
    cursor: pointer;
    transition: transform 120ms var(--ease), background 120ms var(--ease);
    box-shadow: none;
}
.mac-btn:hover { background: var(--bg-hover); }
.mac-btn:active { transform: scale(0.97); background: var(--bg-active); }
.mac-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.mac-btn-primary {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: transparent;
    box-shadow: none;
}
.mac-btn-primary:hover { background: var(--accent-hover); }

.mac-btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.mac-btn-ghost:hover { background: var(--bg-hover); }

.mac-btn-danger { background: var(--red); color: #fff; border-color: transparent; }
.mac-btn-danger:hover { background: #d9302a; }

/* ====== Inputs ====== */
.mac-input, .mac-textarea, .mac-select {
    width: 100%;
    min-height: var(--input-h);
    padding: 11px 14px;
    border: 0.5px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14.5px;
    outline: none;
    transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.mac-textarea { min-height: 96px; padding: 12px 14px; }
.mac-input:focus, .mac-textarea:focus, .mac-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.22);
}
.mac-input::placeholder { color: var(--text-tertiary); }

.mac-field { display: flex; flex-direction: column; gap: 8px; }
.mac-field label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

/* ====== Janela Mac ====== */
.mac-window {
    background: var(--bg-elevated);
    border-radius: var(--r-xl);
    box-shadow: none;
    overflow: hidden;
    border: 0.5px solid var(--border);
}
.mac-titlebar {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 20px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border-bottom: 0.5px solid var(--divider);
    user-select: none;
}
.mac-traffic { display: flex; gap: 8px; }
.mac-traffic .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.mac-traffic .dot.red    { background: #ff5f57; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.08); }
.mac-traffic .dot.yellow { background: #ffbd2e; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.08); }
.mac-traffic .dot.green  { background: #28c940; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.08); }
.mac-title {
    flex: 1; text-align: center;
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
}

/* ====== Dock ====== */
.mac-dock {
    position: fixed;
    bottom: 20px; left: 50%;
    transform: translateX(-50%);
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 16px;
    background: var(--bg-surface);
    backdrop-filter: saturate(180%) blur(28px);
    -webkit-backdrop-filter: saturate(180%) blur(28px);
    border: 0.5px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: none;
    z-index: 100;
}
.mac-dock-item {
    width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--r-md);
    background: var(--bg-elevated);
    cursor: pointer;
    font-size: 24px;
    transition: transform 180ms var(--ease-spring);
    position: relative;
    border: 0.5px solid var(--border);
}
.mac-dock-item:hover { transform: translateY(-8px) scale(1.12); }
.mac-dock-item::after {
    content: attr(data-label);
    position: absolute; bottom: calc(100% + 8px); left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    background: rgba(0,0,0,0.82);
    color: #fff;
    font-size: 11px; font-weight: 500;
    white-space: nowrap;
    border-radius: var(--r-xs);
    opacity: 0; pointer-events: none;
    transition: opacity 120ms var(--ease);
}
.mac-dock-item:hover::after { opacity: 1; }

/* ====== Sidebar ====== */
.mac-sidebar {
    width: 240px; flex-shrink: 0;
    background: var(--bg-surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 0.5px solid var(--divider);
    padding: 20px 12px;
    overflow-y: auto;
}
.mac-sidebar-section { margin-bottom: 24px; }
.mac-sidebar-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    color: var(--text-tertiary); padding: 0 14px 8px;
    letter-spacing: 0.04em;
}
.mac-sidebar-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-radius: var(--r-sm);
    color: var(--text-primary);
    cursor: pointer; font-size: 13.5px;
    transition: background 100ms var(--ease);
}
.mac-sidebar-item:hover { background: var(--bg-hover); }
.mac-sidebar-item.active { background: var(--accent); color: #fff; }
.mac-sidebar-item.active i, .mac-sidebar-item.active .icon { color: #fff; }
.mac-sidebar-item i, .mac-sidebar-item .icon {
    width: 20px; text-align: center; font-size: 14px;
    color: var(--text-secondary);
}

/* ====== Badge / Pill ====== */
.mac-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-size: 11px; font-weight: 600;
    background: var(--bg-hover);
    color: var(--text-secondary);
}
.mac-badge.blue   { background: var(--blue);   color: #fff; }
.mac-badge.green  { background: var(--green);  color: #fff; }
.mac-badge.red    { background: var(--red);    color: #fff; }
.mac-badge.yellow { background: var(--yellow); color: #1d1d1f; }
.mac-badge.purple { background: var(--purple); color: #fff; }
.mac-badge.orange { background: var(--orange); color: #fff; }

/* ====== Divisor ====== */
.mac-divider { height: 0.5px; background: var(--divider); margin: 20px 0; border: 0; }

/* ====== Fade-in on mount ====== */
.mac-fade-in { animation: macFadeIn 260ms var(--ease) both; }
@keyframes macFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ====== Spinner ====== */
.mac-spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: macSpin 0.7s linear infinite;
    display: inline-block;
}
@keyframes macSpin { to { transform: rotate(360deg); } }

/* ====== Toast ====== */
.mac-toast {
    position: fixed; top: 24px; right: 24px;
    padding: 14px 18px;
    background: var(--bg-elevated);
    border: 0.5px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: none;
    font-size: 13px; font-weight: 500;
    z-index: 10000;
    animation: macFadeIn 200ms var(--ease) both;
    min-width: 220px; max-width: 360px;
}
.mac-toast.success { border-left: 3px solid var(--green); }
.mac-toast.error   { border-left: 3px solid var(--red); }
.mac-toast.info    { border-left: 3px solid var(--accent); }
.mac-toast.warning { border-left: 3px solid var(--orange); }

/* =========================================================
   Responsividade — encolhe tokens em telas menores.
   Tudo que usa .mac-* herda automaticamente.
   ========================================================= */
@media (max-width: 900px) {
    :root {
        --container-pad: 20px;
        --font-h1: 28px;
        --font-h2: 22px;
    }
    .mac-card { padding: 18px; border-radius: var(--r-md); }
}

@media (max-width: 640px) {
    :root {
        --font-base: 14px;
        --font-h1: 24px;
        --font-h2: 20px;
        --font-h3: 17px;
        --container-pad: 16px;
        --btn-h: 44px;        /* alvo ≥44px em mobile (Apple HIG) */
        --btn-h-sm: 36px;
        --btn-h-lg: 52px;
        --input-h: 48px;
    }
    body { letter-spacing: 0; }
    .mac-card { padding: 16px; border-radius: var(--r-md); }
    .mac-btn { font-size: 14px; padding: 10px 16px; }
    .mac-input, .mac-textarea, .mac-select {
        font-size: 16px;     /* evita zoom automático no iOS */
        padding: 12px 14px;
    }
    /* Toast ocupa quase a tela inteira pra dar destaque */
    .mac-toast {
        top: auto; bottom: 16px; right: 16px; left: 16px;
        max-width: none; min-width: 0;
        animation: macFadeInUp 220ms var(--ease) both;
    }
    @keyframes macFadeInUp {
        from { opacity: 0; transform: translateY(12px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    /* Sidebar Mac vira full-width quando precisa */
    .mac-sidebar { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 0.5px solid var(--divider); }
}

@media (max-width: 420px) {
    :root {
        --container-pad: 14px;
        --font-h1: 22px;
        --font-h2: 18px;
    }
    .mac-card { padding: 14px; }
    h1 { line-height: 1.25; }
}
/* ============ App.notify — barra superior de status ============ */
.app-notify-bar {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 10001;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 10px 18px;
    font-size: 13px; font-weight: 500;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-bottom: 0.5px solid var(--border);
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
    transform: translateY(-100%);
    transition: transform 220ms cubic-bezier(.16,1,.3,1), background 200ms;
    pointer-events: none;
}
.app-notify-bar.show { transform: translateY(0); }
.app-notify-bar .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); flex-shrink: 0;
}
.app-notify-bar.info    { background: var(--bg-elevated); color: var(--text-primary); }
.app-notify-bar.info .dot    { background: var(--accent); }
.app-notify-bar.success { background: #30d158; color: #fff; border-bottom-color: rgba(0,0,0,0.10); box-shadow: 0 4px 14px rgba(48,209,88,0.35); }
.app-notify-bar.success .dot { background: #fff; }
.app-notify-bar.error   { background: #ff3b30; color: #fff; border-bottom-color: rgba(0,0,0,0.10); box-shadow: 0 4px 14px rgba(255,59,48,0.35); }
.app-notify-bar.error .dot   { background: #fff; }
.app-notify-bar.warning { background: #ff9500; color: #fff; border-bottom-color: rgba(0,0,0,0.10); box-shadow: 0 4px 14px rgba(255,149,0,0.35); }
.app-notify-bar.warning .dot { background: #fff; }
.app-notify-bar.saving  { background: var(--bg-elevated); color: var(--text-primary); border-bottom-color: rgba(99,91,255,0.30); }
.app-notify-bar.saving .dot {
    background: var(--accent); position: relative;
    animation: notify-pulse 1.2s ease-in-out infinite;
}
@keyframes notify-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.5; }
}

/* ============ Campo de senha com toggle "olho" (global) ============ */
.pw-field { position: relative; }
.pw-field .mac-input { padding-right: 44px; }
.pw-field .pw-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    transition: background 120ms var(--ease), color 120ms var(--ease);
}
.pw-field .pw-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.pw-field .pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ============ Defensive — SVGs sem width/height intrínseco ============ */
/* Previne SVGs inline (sem width/height) de inflarem em containers flex/grid wide */
svg:not([width]):not([height]) { width: 1em; height: 1em; }
