/* Sistema de Design Visual do APPCC ISO 22000 */

@import url('../vendor/fonts/fonts.css');

:root {
    /* Tema Claro Exclusivo */
    --bg-main: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border-color: #cbd5e1;
    --border-focus: #3b82f6;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    /* Cores do Sistema */
    --primary: #3b82f6;
    --primary-grad: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --accent: #d97706;
    --danger: #dc2626;
    --success: #16a34a;
    --info: #2563eb;
    --purple: #7c3aed;
    --teal: #0d9488;
    
    /* Sombras e Bordas Limpas */
    --glass-blur: none;
    --glass-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    
    --font-sans: 'Outfit', sans-serif;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset e Estilos Gerais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    min-height: 100vh;
}

/* Scrollbar Customizada */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Painel Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: width var(--transition-normal);
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-grad);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 20px;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.logo-text {
    font-weight: 600;
    font-size: 22px;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.menu-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.menu-item a:hover, .menu-item.active a {
    color: var(--text-primary);
    background: var(--bg-card-hover);
    border-left: 3px solid var(--primary);
    padding-left: 13px;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* Área Principal */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-sidebar);
    backdrop-filter: var(--glass-blur);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Botões */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    border: none;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-grad);
    color: #ffffff;
    font-weight: 600;
}
.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover {
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-success {
    background: #16a34a;
    color: #ffffff;
    font-weight: 600;
}
.btn-success:hover {
    background: #15803d;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
    transform: translateY(-1px);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--glass-shadow);
    transition: var(--transition-normal);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: #cbd5e1;
}

/* Grid de Conteúdo */
.content-wrapper {
    padding: 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

/* Login */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    position: relative;
    padding: 20px;
}

.login-screen::before {
    display: none;
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

/* Formulários */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    padding: 12px 16px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: var(--transition-fast);
    width: 100%;
}

.form-control::placeholder {
    color: #94a3b8;
    opacity: 1;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
}

select.form-control option {
    background-color: #ffffff;
    color: var(--text-primary);
}

/* Tabelas */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.table th {
    background: #f1f5f9;
    padding: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.table tbody tr:hover {
    background: #f8fafc;
}

.actions-cell {
    text-align: right !important;
    white-space: nowrap !important;
}

.actions-cell .btn {
    padding: 6px 12px !important;
    font-size: 13px !important;
    height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 0 0 6px !important;
}

.actions-cell .btn:first-child {
    margin-left: 0 !important;
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--accent); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); }

/* Modais */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform var(--transition-fast);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

/* Construtor de Fluxograma */
.flowchart-container {
    flex: 1;
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: auto;
    min-height: 500px;
    height: 60vh;
}

.flowchart-node {
    position: absolute;
    width: 190px;
    min-height: 80px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: move;
    z-index: 5;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.flowchart-node:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.flowchart-node.step { border-left: 5px solid var(--info); }
.flowchart-node.input { border-left: 5px solid var(--danger); }
.flowchart-node.equipment { border-left: 5px solid var(--text-muted); }
.flowchart-node.packaging { border-left: 5px solid var(--accent); }
.flowchart-node.aid { border-left: 5px solid var(--purple); }

.node-header {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-body {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.node-port {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.node-port-in { left: -6px; top: calc(50% - 5px); }
.node-port-out { right: -6px; top: calc(50% - 5px); }

.flowchart-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 2500px;
    height: 2000px;
    pointer-events: none;
    z-index: 2;
}

.flowchart-connection {
    fill: none;
    stroke: var(--text-secondary);
    stroke-width: 2;
    marker-end: url(#arrow);
}

.flowchart-connection:hover {
    stroke: var(--primary);
    stroke-width: 3;
    cursor: pointer;
}

.pcc-flag {
    position: absolute;
    top: -12px;
    right: 5px;
    background: var(--danger);
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    box-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
}

/* Matriz de Risco */
.matrix-container {
    display: grid;
    grid-template-columns: 80px repeat(3, 1fr);
    grid-template-rows: repeat(4, 60px);
    gap: 8px;
    max-width: 500px;
    margin: 20px auto;
}

.matrix-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

.matrix-cell {
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: var(--transition-fast);
    border: 2px solid transparent;
}

.matrix-cell:hover {
    transform: scale(1.03);
}

.matrix-cell.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

.cell-menor { background-color: rgba(16, 185, 129, 0.3); color: #2ecc71; }
.cell-medio { background-color: rgba(59, 130, 246, 0.3); color: #3498db; }
.cell-maior { background-color: rgba(245, 158, 11, 0.3); color: #e67e22; }
.cell-critico { background-color: rgba(239, 68, 68, 0.3); color: #e74c3c; }

/* Abas */
.tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition-fast);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Árvore Decisória */
.decision-node {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

/* Imagens Auxiliares da ISO 22000 */
.reference-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(59, 130, 246, 0.05);
    border-left: 4px solid var(--primary);
}

/* Estilos de Impressão */
@media print {
    body {
        background-color: white !important;
        color: black !important;
    }
    
    .sidebar, .header, .btn, .no-print {
        display: none !important;
    }

    .main-content {
        height: auto !important;
        overflow: visible !important;
    }
    
    .content-wrapper {
        padding: 0 !important;
        gap: 0 !important;
    }
    
    .card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
    
    .table-responsive {
        border: 1px solid #ddd !important;
    }
    
    .table th {
        background: #f5f5f5 !important;
        color: black !important;
        border-bottom: 2px solid #ddd !important;
    }
    
    .table td {
        border-bottom: 1px solid #ddd !important;
        color: black !important;
    }

    .page-break {
        page-break-before: always;
        padding-top: 2cm;
    }
}

/* TUTORIALS STYLE */
.tutorial-index-link {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}
.tutorial-index-link:hover {
    background: #f1f5f9;
    color: var(--primary);
    border-left-color: var(--primary);
    padding-left: 18px;
}
.tutorial-index-link.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
}
.tutorial-card {
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}
.tutorial-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Spinner Loader animation */
.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin-loader 0.8s linear infinite;
}

@keyframes spin-loader {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   ESTILOS RESPONSIVOS E TABELAS ELEGANTES PARA O BLOG (.prose)
   ========================================================================== */

.prose {
    width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Ajuste e Rolagem Responsiva de Tabelas em Celulares */
.prose table {
    width: 100% !important;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.04);
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    .prose table {
        display: table;
        white-space: normal;
    }
}

.prose table thead {
    background-color: #f1f5f6;
}

.prose table th {
    color: #002045;
    font-weight: 700;
    padding: 0.85rem 1.1rem;
    text-align: left;
    border-bottom: 2px solid #cbd5e1;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.prose table td {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
    font-size: 0.875rem;
    line-height: 1.6;
}

.prose table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

.prose table tbody tr:hover {
    background-color: #f1f5f9;
}

.prose table tbody tr:last-child td {
    border-bottom: none;
}

/* Elementos de Mídia no Blog (Imagens e Vídeos) */
.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
    margin: 1.25rem auto;
}

.prose iframe {
    max-width: 100%;
    border-radius: 0.75rem;
    margin: 1.25rem auto;
}

.prose blockquote {
    border-left: 4px solid #006d40;
    background-color: #f0fdf4;
    padding: 1rem 1.25rem;
    border-top-right-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #166534;
}

