/* ============================================
   MARILLAC ERP 2.0 — Design System
   Cores: Laranja #F97316 | Marrom #78350F
   ============================================ */

:root {
    --color-primary: #F97316;
    --color-primary-dark: #EA580C;
    --color-primary-light: #FB923C;
    --color-secondary: #78350F;
    --color-secondary-dark: #451A03;
    --color-secondary-light: #92400E;
    --color-bg: #FFF7ED;
    --color-surface: #FFFFFF;
    --color-text: #1C1917;
    --color-text-muted: #78716C;
    --color-border: #E7E5E4;
    --color-success: #16A34A;
    --color-warning: #D97706;
    --color-danger: #DC2626;
    --color-info: #2563EB;
    --font-family: 'Segoe UI', Arial, sans-serif;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
}

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--color-secondary-dark) 0%, var(--color-secondary) 100%);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 50;
    transition: transform 0.3s, width 0.3s ease;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 12px; }
.sidebar-header img { height: 36px; border-radius: 6px; }
.sidebar-header h2 { font-size: 1.1rem; font-weight: 700; }
.sidebar-header small { font-size: 0.7rem; opacity: 0.7; }

.sidebar-nav { padding: 12px 0; }
.sidebar-nav a,
.sidebar-nav button {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px; width: 100%;
    color: rgba(255,255,255,0.8); font-size: 0.9rem;
    text-decoration: none; border: none; background: none; cursor: pointer;
    transition: all 0.2s;
}
.sidebar-nav a:hover, .sidebar-nav button:hover { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-nav a.active { background: rgba(249,115,22,0.3); color: #FDE68A; border-left: 3px solid var(--color-primary); }
.sidebar-nav a i, .sidebar-nav button i { width: 20px; text-align: center; }
.sidebar-section { padding: 16px 20px 6px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.5; }

.main-content { flex: 1; margin-left: 260px; transition: margin-left 0.3s ease; }
.main-header {
    background: #fff; border-bottom: 1px solid var(--color-border);
    padding: 16px 24px; display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
}
.main-header h1 { font-size: 1.25rem; color: var(--color-secondary); }
.user-menu { display: flex; align-items: center; gap: 12px; }
.user-menu span { font-size: 0.85rem; color: var(--color-text-muted); }

.page-content { padding: 24px; }

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none; background: none; border: none; color: var(--color-secondary);
    font-size: 1.5rem; cursor: pointer;
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 45;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .page-content { padding: 16px; }
}

/* ===== Desktop Sidebar Collapse ===== */
.sidebar-collapse-btn {
    background: none; border: none; color: rgba(255,255,255,0.7);
    cursor: pointer; font-size: 0.9rem; padding: 4px 8px; border-radius: 4px;
    transition: all 0.2s; margin-left: auto; flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

@media (min-width: 769px) {
    .app-layout.sidebar-collapsed .sidebar { width: 60px; }
    .app-layout.sidebar-collapsed .main-content { margin-left: 60px; }
    .app-layout.sidebar-collapsed .sidebar-header { padding: 14px 0; justify-content: center; flex-direction: column; gap: 6px; }
    .app-layout.sidebar-collapsed .sidebar-logo-text { display: none; }
    .app-layout.sidebar-collapsed .sidebar-collapse-btn { margin: 0; }
    .app-layout.sidebar-collapsed .sidebar-nav a,
    .app-layout.sidebar-collapsed .sidebar-nav button { justify-content: center; padding: 12px 0; gap: 0; }
    .app-layout.sidebar-collapsed .nav-label { display: none; }
    .app-layout.sidebar-collapsed .sidebar-section { display: none; }
    .app-layout.sidebar-collapsed .sidebar-impersonar { display: none; }
    .app-layout.sidebar-collapsed .sidebar-footer { padding-left: 0 !important; padding-right: 0 !important; }
}

@media (max-width: 768px) {
    .sidebar-collapse-btn { display: none; }
}

/* ===== Loading ===== */
.loading-screen {
    display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh;
}
.loading-screen h1 { color: var(--color-secondary); font-size: 1.875rem; margin-bottom: 8px; }
.loading-screen p { color: var(--color-text-muted); }

/* ===== Toasts ===== */
#toastContainer { position: fixed; top: 20px; right: 20px; z-index: 9999; max-width: 400px; }
.toast { display: flex; gap: 12px; align-items: start; padding: 16px; border-radius: 8px; margin-bottom: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.3s ease-out; word-break: break-word; }
@keyframes slideIn { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast.removing { animation: slideOut 0.3s ease-in forwards; }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(400px); opacity: 0; } }
.toast-sucesso { background: #dcfce7; color: #166534; border-left: 4px solid #22c55e; }
.toast-erro { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.toast-info { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }
.toast-alerta { background: #fef3c7; color: #92400e; border-left: 4px solid #f59e0b; }
.toast-aviso { background: #fff7ed; color: #9a3412; border-left: 4px solid #f97316; }
@media (max-width: 768px) { #toastContainer { left: 12px; right: 12px; top: 12px; max-width: none; } }

/* ===== Status Badges ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-ativo, .badge-pago { background: #dcfce7; color: #166534; }
.badge-inativo, .badge-cancelado { background: #fee2e2; color: #991b1b; }
.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-bloqueado { background: #fce4ec; color: #880e4f; }
.badge-info { background: #dbeafe; color: #1e40af; }

/* ===== Skeleton ===== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skLoad 1.5s infinite;
    border-radius: 8px;
}
@keyframes skLoad { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== Tables ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: #f8f8f8; }
.data-table th { padding: 10px 14px; text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--color-text-muted); border-bottom: 2px solid var(--color-border); }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--color-border); font-size: 0.875rem; }
.data-table tbody tr:hover { background: #FFF7ED; }

/* ===== Cards ===== */
.stat-card {
    background: #fff; border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--color-primary);
}
.stat-card .stat-label { font-size: 0.8rem; color: var(--color-text-muted); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; color: var(--color-text); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--color-border);
    border-radius: var(--radius-md); font-size: 0.9rem;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(249,115,22,0.15);
}

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border-radius: var(--radius-md); font-size: 0.875rem;
    font-weight: 600; border: none; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-secondary); color: #fff; }
.btn-secondary:hover { background: var(--color-secondary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: #f5f5f5; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* ===== Modals ===== */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(0,0,0,0.5);
    display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal-box {
    background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 600px; margin: 16px;
    max-height: 90vh; overflow-y: auto; padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 1.125rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #999; }

/* ===== Pagination ===== */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 20px; }
.pagination button {
    padding: 6px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    background: #fff; cursor: pointer; font-size: 0.85rem;
}
.pagination button.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ===== Bottom Nav Mobile ===== */
.bottom-nav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff; border-top: 1px solid #e5e7eb; z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
}
.bottom-nav-inner { display: flex; justify-content: space-around; align-items: center; }
.bottom-nav-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    padding: 8px 4px; border: none; background: none;
    color: #6b7280; font-size: 10px; font-weight: 600; cursor: pointer;
}
.bottom-nav-btn i { font-size: 20px; margin-bottom: 2px; }
.bottom-nav-btn.active { color: var(--color-primary); }
@media (max-width: 639px) {
    .bottom-nav { display: block; }
    body { padding-bottom: 70px; }
}

/* ===== Login Page ===== */
.login-container {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--color-secondary-dark) 0%, var(--color-secondary) 50%, var(--color-primary-dark) 100%);
    padding: 16px;
}
.login-box {
    background: #fff; border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-box h1 { text-align: center; color: var(--color-secondary); margin-bottom: 8px; font-size: 1.5rem; }
.login-box p { text-align: center; color: var(--color-text-muted); margin-bottom: 24px; font-size: 0.9rem; }

/* ============================================
   TOUR GUIADO — Demonstração Prática
   ============================================ */

/* Overlay escuro */
.tour-overlay {
    display: none; position: fixed; inset: 0; z-index: 10000;
    background: rgba(0, 0, 0, 0.55); transition: opacity 0.3s;
    pointer-events: auto;
}
body.tour-ativo { overflow-x: hidden; }

/* Spotlight (elemento destacado) */
.tour-spotlight {
    display: none; position: absolute; z-index: 10001;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55), inset 0 0 30px rgba(255,255,255,0.15), 0 0 20px rgba(249,115,22,0.2);
    pointer-events: none; transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Anel pulsante */
.tour-pulse-ring {
    position: absolute; z-index: 10001;
    border: 2px solid var(--color-primary);
    border-radius: 10px; pointer-events: none;
    animation: tourPulse 1.8s infinite;
}
@keyframes tourPulse {
    0% { opacity: 1; transform: scale(1); }
    70% { opacity: 0; transform: scale(1.08); }
    100% { opacity: 0; transform: scale(1.08); }
}

/* Tooltip */
.tour-tooltip {
    display: none; position: absolute; z-index: 10002;
    background: #fff; border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    width: 360px; max-width: calc(100vw - 24px);
    animation: tourFadeIn 0.3s ease;
    pointer-events: auto;
}
@keyframes tourFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tour-tooltip-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px 0 18px;
}
.tour-step-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px; font-size: 0.7rem;
    font-weight: 700; color: #fff; background: var(--color-primary);
    letter-spacing: 0.02em;
}
.tour-close {
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border: none; background: #f3f4f6; border-radius: 50%; cursor: pointer;
    font-size: 1.1rem; color: #6b7280; transition: all 0.15s;
}
.tour-close:hover { background: #e5e7eb; color: #111; }

.tour-tooltip-title {
    padding: 10px 18px 2px 18px;
    font-size: 1rem; font-weight: 700; color: #1f2937;
}
.tour-tooltip-body {
    padding: 4px 18px 8px 18px;
    font-size: 0.85rem; color: #4b5563; line-height: 1.5;
}
.tour-tooltip-dica {
    margin: 0 18px 10px 18px;
    padding: 8px 12px; border-radius: 8px;
    background: #fffbeb; border: 1px solid #fde68a;
    font-size: 0.78rem; color: #92400e; line-height: 1.4;
}
.tour-tooltip-dica i { color: #f59e0b; margin-right: 4px; }

/* Progress bar */
.tour-tooltip-progress { padding: 0 18px; }
.tour-progress-bar {
    height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden;
}
.tour-progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    border-radius: 2px; transition: width 0.4s ease;
}

/* Nav */
.tour-tooltip-nav {
    display: flex; justify-content: space-between; gap: 8px;
    padding: 12px 18px 16px 18px;
}
.tour-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px; font-size: 0.8rem;
    font-weight: 600; cursor: pointer; border: none; transition: all 0.15s;
}
.tour-btn-primary {
    background: var(--color-primary); color: #fff;
}
.tour-btn-primary:hover { background: var(--color-primary-dark); }
.tour-btn-outline {
    background: #fff; color: #374151; border: 1px solid #d1d5db;
}
.tour-btn-outline:hover { background: #f3f4f6; }

/* Resumo final */
.tour-resumo-titulo {
    padding: 0 18px; font-size: 0.9rem; font-weight: 600;
    color: var(--color-primary-dark); margin-bottom: 8px;
}
.tour-resumo-lista {
    padding: 0 18px 8px 36px; margin: 0;
    font-size: 0.82rem; color: #374151; line-height: 1.8;
}
.tour-resumo-lista li { margin-bottom: 2px; }
.tour-resumo-lista li strong { color: var(--color-primary); }

/* Seletor de tours — grid cards */
.tour-cat-header {
    font-size: 0.8rem; font-weight: 700; color: var(--color-secondary);
    text-transform: uppercase; letter-spacing: 0.04em;
    margin: 16px 0 8px 0; display: flex; align-items: center; gap: 6px;
}
.tour-cat-header:first-child { margin-top: 0; }
.tour-cards-grid {
    display: grid; grid-template-columns: 1fr; gap: 8px;
}
.tour-card {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 14px; border: 2px solid #e5e7eb; border-radius: 12px;
    background: #fff; cursor: pointer; text-align: left;
    transition: all 0.15s; width: 100%;
}
.tour-card:hover { border-color: var(--color-primary); background: #fff7ed; }
.tour-card-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1rem; flex-shrink: 0;
}
.tour-card-body { flex: 1; min-width: 0; }
.tour-card-title { font-size: 0.88rem; font-weight: 700; color: #1f2937; }
.tour-card-desc { font-size: 0.78rem; color: #6b7280; margin-top: 2px; line-height: 1.3; }
.tour-card-meta { font-size: 0.7rem; color: #9ca3af; margin-top: 4px; }
.tour-card-meta i { margin-right: 2px; }

/* Botão flutuante de ajuda */
.tour-fab {
    position: fixed; bottom: 72px; right: 24px; z-index: 10003;
    width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; box-shadow: 0 4px 16px rgba(249, 115, 22, 0.35);
    transition: all 0.2s;
}
.tour-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(249, 115, 22, 0.45); }
@media (max-width: 639px) {
    .tour-fab { bottom: 80px; right: 16px; width: 46px; height: 46px; font-size: 1.1rem; }
    .tour-tooltip { width: calc(100vw - 20px); }
}
