@font-face {
    font-family: 'Inter';
    src: url("../fonts/Inter-400.a32ace5dba84.ttf") format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url("../fonts/Inter-600.84cf795ee940.ttf") format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url("../fonts/Inter-700.c59d7314123c.ttf") format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url("../fonts/Inter-800.ef9e4fbd408c.ttf") format('truetype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

:root {
    /* Colors strictly from cyber-sec.it */
    --bg-main: #0f172a;
    --bg-panel: #283346;
    --bg-panel-hover: #334155;
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    
    --accent-primary: #5f62e7; /* Original Navbar Blue/Purple */
    --accent-hover: #0d6efd; /* Original Button Hover */
    --accent-glow: rgba(95, 98, 231, 0.4);
    
    --accent-green: #10B981;
    --accent-red: #EF4444;
    --accent-orange: #F59E0B;
    --accent-cyan: #06B6D4;
    --accent-blue: #3B82F6;
}

/* Per-framework accent theming: override --accent-primary based on the active
   standard set via data-framework on <html>. Adding a standard only needs a
   new entry here (or a CSS variable set inline from the framework model). */
html[data-framework="ISO27001"] { --accent-primary: #5f62e7; }
html[data-framework="ISO42001"] { --accent-primary: #d97706; } /* amber — AI */
html[data-framework="ISO9001"]  { --accent-primary: #059669; } /* emerald — quality */

/* IMS mode: one stable accent across all adopted standards (violet, matching
   the sidebar IMS badge). Must come after the framework rules above — equal
   specificity, source order decides — so switching the active standard no
   longer repaints the whole UI while IMS is on. */
html[data-ims="1"] {
    --accent-primary: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-glow: rgba(139, 92, 246, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Smooth, theme-matched scrollbars (Windows default bars feel jarring
   on the dark UI — this applies globally and to the sidebar nav) ── */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(148, 163, 184, 0.55);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* Layout Setup */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 260px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh; /* avoids the mobile URL-bar jump */
    z-index: 100;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: 1px;
}

.logo span {
    color: var(--accent-primary);
}

.sidebar-nav {
    flex-grow: 1;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    /* no scroll-behavior: smooth here — it would animate the programmatic
       scroll-position restore on every navigation (visible slide-down) */
    overscroll-behavior-y: contain; /* no scroll chaining into the page */
}

.nav-item {
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    display: block;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background-color: var(--bg-panel-hover);
    border-left: 3px solid var(--accent-primary);
}

.sidebar-section-header {
    padding: 0 1.5rem;
    margin: 1.75rem 0 0.5rem;
    font-size: 0.725rem;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-section-header::after {
    content: "";
    flex-grow: 1;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.08);
    margin-left: 0.5rem;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    color: var(--accent-red);
    background-color: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 1.5rem;
    width: 100%;
}

.btn-logout:hover {
    background-color: var(--accent-red);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
    border-color: var(--accent-red);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Main Content Styles */
.main-content {
    margin-left: 260px;
    flex-grow: 1;
    min-height: 100vh;
    background-color: var(--bg-main);
}

/* Soften full page reloads: the content fades in instead of popping.
   Sidebar stays fixed and scroll-restored, so navigation feels stable. */
.main-content > .container {
    animation: pageFade 0.18s ease;
}

@keyframes pageFade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .main-content > .container {
        animation: none;
    }
}

.container {
    max-width: 1000px; /* Constrained for better readability */
    margin: 0 auto;
    padding: 3rem 2rem;
}

/* Typography & Explanations */
h1 { font-size: 2.25rem; margin-bottom: 0.5rem; font-weight: 700; color: var(--text-primary); }
h2 { font-size: 1.75rem; margin-bottom: 1rem; color: var(--text-primary); }
h3 { font-size: 1.25rem; margin-bottom: 0.75rem; color: var(--text-primary); }
p.explainer { color: var(--text-secondary); font-size: 1.05rem; margin-bottom: 1.5rem; line-height: 1.7; }

/* Cards */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2), 0 0 10px var(--accent-glow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Steps / Wizard */
.step-item {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.step-number {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.25rem;
    box-shadow: 0 0 10px var(--accent-glow);
}
.step-content h3 { margin-bottom: 0.25rem; }
.step-content p { color: var(--text-secondary); margin-bottom: 1rem; font-size: 0.95rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    white-space: nowrap;
}

.btn:hover {
    background: var(--bg-panel-hover);
    border-color: var(--text-secondary);
}

.btn-primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    box-shadow: 0 0 15px var(--accent-glow);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

/* Premium Edit action buttons outline blue styles across registers */
.btn-edit, .btn-edit-audit, .btn-edit-incident, .btn-edit-supplier, .btn-edit-training, .btn-edit-capa, .btn-edit-review {
    background: rgba(59, 130, 246, 0.1) !important;
    color: var(--accent-primary) !important;
    border: 1px solid rgba(59, 130, 246, 0.25) !important;
}

.btn-edit:hover, .btn-edit-audit:hover, .btn-edit-incident:hover, .btn-edit-supplier:hover, .btn-edit-training:hover, .btn-edit-capa:hover, .btn-edit-review:hover {
    background: rgba(59, 130, 246, 0.2) !important;
    border-color: var(--accent-primary) !important;
}

/* Premium Delete action buttons outline red styles across registers */
.btn-delete {
    background: rgba(239, 68, 68, 0.1) !important;
    color: var(--accent-red) !important;
    border: 1px solid rgba(239, 68, 68, 0.25) !important;
    transition: all 0.2s ease !important;
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: var(--accent-red) !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.2) !important;
}

/* Premium styling for policy gap checklist Draft actions (class-based, framework-agnostic) */
.checklist-action {
    background: rgba(59, 130, 246, 0.1) !important;
    color: var(--accent-primary) !important;
    border: 1px solid var(--accent-primary) !important;
    font-weight: bold;
    border-radius: 6px;
    padding: 3px 10px !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
    transition: all 0.2s ease;
}

.checklist-action:hover {
    background: rgba(59, 130, 246, 0.2) !important;
    box-shadow: 0 0 10px var(--accent-glow);
}

/* Grid & Metrics */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.metric {
    text-align: center;
    padding: 2rem;
}

.metric .value {
    font-size: 3rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 0.5rem;
    letter-spacing: -1px;
}

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-secondary); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background-color: rgba(255,255,255,0.02); }

/* Badges */
.badge {
    display: inline-block;
    white-space: nowrap;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge.implemented { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid rgba(16,185,129,0.3); }
.badge.partial { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.3); }
.badge.planned { background: rgba(255, 255, 255, 0.05); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* Forms */
form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
label { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
input, textarea, select {
    width: 100%;
    padding: 0.875rem;
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
select option {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Beautiful Document Viewer */
.document-viewer {
    background: #e2e8f0; /* Crisp paper-like background */
    color: #0f172a; /* High contrast ink */
    border-radius: 8px;
    padding: 3.5rem 4.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255,255,255,0.5);
    margin-bottom: 2.5rem;
    position: relative;
    overflow: hidden;
}

.document-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 8rem;
    font-weight: 900;
    color: rgba(0, 0, 0, 0.03);
    pointer-events: none;
    white-space: nowrap;
    z-index: 0;
    user-select: none;
}

.document-header {
    border-bottom: 2px solid #cbd5e1;
    padding-bottom: 1.5rem;
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 1;
}

.document-title {
    color: #0f172a;
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.document-meta {
    display: flex;
    gap: 2rem;
    color: #475569;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    flex-wrap: wrap;
    align-items: center;
}

/* Buttons inside the paper document viewer use explicit light-mode style */
.document-viewer .btn {
    background: #1e293b;
    color: #f8fafc;
    border-color: #334155;
    font-size: 0.8rem;
    padding: 0.35rem 0.8rem;
}

.document-viewer .btn:hover {
    background: #334155;
    color: #f8fafc;
}

.document-body {
    position: relative;
    z-index: 1;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 1.15rem;
    line-height: 1.8;
    color: #1e293b;
    white-space: pre-wrap;
}

/* Ensure the document container breaks out of the grid if placed nearby */
.document-container {
    width: 100%;
    max-width: 1000px;
}

/* Layout Safety: Prevent text breakout and overflow from long strings */
p, li, h1, h2, h3, h4, h5, h6, span, td, th, div.card, .document-body, .justification-text {
    overflow-wrap: break-word;
    word-wrap: break-word;
}
