/* ==========================================================================
   Information Security Exam Notes - Master Stylesheet (styles.css)
   Designed for A+ Grade Preparation
   ========================================================================== */

/* --- 1. CSS Variables & Theming --- */
:root {
    /* Color Palette - Light Mode (Default) */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --accent-primary: #2563eb;    /* Deep Blue for links and highlights */
    --accent-hover: #1d4ed8;
    --accent-secondary: #0ea5e9;  /* Light blue for secondary highlights */
    
    /* Status Colors */
    --success-bg: #dcfce7;
    --success-text: #166534;
    --success-border: #22c55e;
    
    --warning-bg: #fef9c3;
    --warning-text: #854d0e;
    --warning-border: #eab308;
    
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --danger-border: #ef4444;
    
    --info-bg: #e0f2fe;
    --info-text: #075985;
    --info-border: #0ea5e9;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Fira Code', 'Consolas', 'Monaco', monospace;
    
    /* Layout & Spacing */
    --sidebar-width: 320px;
    --content-max-width: 1000px;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Shadows & Borders */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 8px;
    --border-color: #e2e8f0;
}

/* Dark Mode Support (Optional toggle via class 'dark-mode' on body) */
body.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border-color: #475569;
    
    --info-bg: #082f49;
    --info-text: #bae6fd;
    --success-bg: #064e3b;
    --success-text: #dcfce7;
    --warning-bg: #713f12;
    --warning-text: #fef08a;
    --danger-bg: #7f1d1d;
    --danger-text: #fecaca;
}

/* --- 2. CSS Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
}

/* --- 3. Base Layout Structure --- */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.sidebar h2 {
    font-size: 1.25rem;
    color: var(--accent-primary);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--border-color);
}

.sidebar ul {
    list-style: none;
}

.sidebar li {
    margin-bottom: 0.5rem;
}

.sidebar a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    display: block;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sidebar a:hover, .sidebar a.active {
    background-color: var(--bg-tertiary);
    color: var(--accent-primary);
    padding-left: 0.8rem; /* Smooth indent effect */
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--spacing-xl);
    max-width: calc(var(--content-max-width) + var(--sidebar-width));
}

.content-container {
    background-color: var(--bg-secondary);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    max-width: var(--content-max-width);
    margin: 0 auto;
}

/* --- 4. Typography --- */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    border-bottom: 3px solid var(--accent-primary);
    padding-bottom: 0.5rem;
    margin-top: 0;
}

h2 {
    font-size: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    color: var(--accent-primary);
}

h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; color: var(--text-secondary); }

p {
    margin-bottom: 1.2rem;
    color: var(--text-secondary);
}

strong {
    color: var(--text-primary);
    font-weight: 700;
}

em {
    color: var(--accent-primary);
    font-style: italic;
}

/* --- 5. Lists --- */
ul, ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
    color: var(--text-secondary);
}

li {
    margin-bottom: 0.5rem;
}

li > ul, li > ol {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

/* --- 6. Comparison Tables (Crucial for A+ exams) --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

th, td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: var(--bg-tertiary);
}

/* --- 7. Callout Boxes / Information Panels --- */
.callout {
    padding: 1.25rem;
    margin: 1.5rem 0;
    border-radius: var(--border-radius);
    border-left: 5px solid;
}

.callout h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.callout p:last-child, .callout ul:last-child {
    margin-bottom: 0;
}

/* Key Terms / Info */
.callout.info {
    background-color: var(--info-bg);
    border-left-color: var(--info-border);
    color: var(--info-text);
}
.callout.info h4 { color: var(--info-text); }

/* Important Concepts / Success */
.callout.success {
    background-color: var(--success-bg);
    border-left-color: var(--success-border);
    color: var(--success-text);
}
.callout.success h4 { color: var(--success-text); }

/* Exam Warnings / Common Mistakes */
.callout.warning {
    background-color: var(--warning-bg);
    border-left-color: var(--warning-border);
    color: var(--warning-text);
}
.callout.warning h4 { color: var(--warning-text); }

/* Attack Vectors / Threats */
.callout.danger {
    background-color: var(--danger-bg);
    border-left-color: var(--danger-border);
    color: var(--danger-text);
}
.callout.danger h4 { color: var(--danger-text); }

/* --- 8. Code Snippets & Terminal Commands --- */
code {
    font-family: var(--font-mono);
    background-color: var(--bg-tertiary);
    color: #db2777; /* Distinct pinkish color for inline code */
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
}

pre {
    background-color: #1e293b; /* Always dark for block code */
    color: #f8fafc;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 1.5rem 0;
    box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.2);
}

pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
    font-size: 0.9rem;
}

/* --- 9. Images & Diagrams --- */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

figure {
    margin: 2rem 0;
    text-align: center;
}

figcaption {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* --- 10. Flashcards / Concept Cards (For quick revision) --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.concept-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.concept-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.concept-card h4 {
    margin-top: 0;
    color: var(--accent-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* --- 11. Responsive Design --- */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
    }
}

@media (max-width: 768px) {
    .layout-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }

    .sidebar ul {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .sidebar li {
        margin: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    .content-container {
        padding: 1.5rem;
    }
}

/* --- 12. Print Media (Crucial for generating PDFs/Physical Notes) --- */
@media print {
    body {
        background-color: white;
        color: black;
        font-size: 12pt;
    }

    .sidebar {
        display: none; /* Hide navigation on print */
    }

    .main-content {
        margin-left: 0;
        padding: 0;
        max-width: 100%;
    }

    .content-container {
        box-shadow: none;
        padding: 0;
        border: none;
    }

    /* Page Breaks for clean printing */
    h1 { page-break-before: always; margin-top: 0; }
    h2, h3, h4 { page-break-after: avoid; }
    table, figure, .callout, .concept-card { page-break-inside: avoid; }
    
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #666;
    }
    
    /* Hide internal links for print */
    a[href^="#"]::after {
        content: "";
    }
}

/* --- 13. Specific Components (OWASP, Firewalls, etc.) --- */
/* Numbered Steps for Protocols (e.g., TLS Handshake) */
.protocol-steps {
    counter-reset: step-counter;
    list-style: none;
    padding-left: 0;
}

.protocol-steps > li {
    position: relative;
    padding-left: 3rem;
    margin-bottom: 1.5rem;
}

.protocol-steps > li::before {
    counter-increment: step-counter;
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background-color: var(--accent-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1rem;
}