/* Premium Design System - TechTales */
:root {
    /* Core Colors - HSL for easy manipulation */
    --hue-primary: 250;
    /* Deep Purple/Blue */
    --hue-secondary: 180;
    /* Teal/Cyan */
    --hue-accent: 320;
    /* Pink/Magenta */

    /* Light Theme (Default, but we'll focus on Dark for premium feel) */
    --color-bg-body: hsl(var(--hue-primary), 15%, 98%);
    --color-bg-surface: hsl(var(--hue-primary), 20%, 100%);
    --color-bg-surface-2: hsl(var(--hue-primary), 20%, 95%);

    --color-text-main: hsl(var(--hue-primary), 50%, 10%);
    --color-text-muted: hsl(var(--hue-primary), 20%, 40%);

    --color-primary: hsl(var(--hue-primary), 80%, 60%);
    --color-primary-glow: hsl(var(--hue-primary), 80%, 60%, 0.5);

    --color-secondary: hsl(var(--hue-secondary), 80%, 45%);
    --color-accent: hsl(var(--hue-accent), 80%, 55%);

    /* Premium Dark Theme Overrides */
    --bg-dark-base: 220;
    --color-dark-bg: hsl(var(--bg-dark-base), 30%, 8%);
    --color-dark-surface: hsl(var(--bg-dark-base), 25%, 12%);
    --color-dark-surface-glass: hsla(var(--bg-dark-base), 25%, 12%, 0.7);
    --color-dark-text: hsl(var(--bg-dark-base), 10%, 95%);
    --color-dark-text-muted: hsl(var(--bg-dark-base), 10%, 65%);
    --color-dark-border: hsl(var(--bg-dark-base), 20%, 20%);

    /* Spacing & Layout */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-pill: 50px;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px var(--color-primary-glow);

    --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    /* Default theme colors (light) */
    --color-bg-body: hsl(var(--hue-primary), 15%, 98%);
    --color-bg-surface: hsl(var(--hue-primary), 20%, 100%);
    --color-bg-surface-2: hsl(var(--hue-primary), 20%, 95%);
    --color-bg-hover: hsl(var(--hue-primary), 20%, 92%);

    --color-text-main: hsl(var(--hue-primary), 50%, 10%);
    --color-text-muted: hsl(var(--hue-primary), 20%, 40%);

    --color-border: hsl(var(--hue-primary), 20%, 85%);

    /* New Semantic Variables */
    --color-glass-panel: rgba(255, 255, 255, 0.7);
    --color-heading-gradient-start: var(--color-text-main);
}

/* Force Dark Mode for that Premium Tech look (or rely on system pref) */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg-body: var(--color-dark-bg);
        --color-bg-surface: var(--color-dark-surface);
        --color-bg-surface-2: hsl(var(--bg-dark-base), 25%, 16%);
        --color-text-main: var(--color-dark-text);
        --color-text-muted: var(--color-dark-text-muted);
        --color-border: var(--color-dark-border);

        --color-glass-panel: var(--color-dark-surface-glass);
        --color-heading-gradient-start: #fff;
    }
}

/* Global Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    font-family: var(--font-body);
    background-color: var(--color-bg-body);
    color: var(--color-text-main);
    line-height: 1.6;
    height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.page {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--color-heading-gradient-start) 0%, var(--color-primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    /* Note: Text fill color needed for gradient text */
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-accent);
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--color-glass-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    padding: 2rem;
    margin-bottom: 1rem;
}

/* Buttons */
.btn-primary {
    display: inline-block;
    text-align: center;
    background: linear-gradient(135deg, var(--color-primary) 0%, #6e45e2 100%);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 15px var(--color-primary-glow);
    text-decoration: none;
    /* For links */
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--color-primary-glow);
}

/* Utilities */
.w-100 {
    width: 100%;
}

.text-center {
    text-align: center;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

/* Forms & Inputs */
.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-text-main);
    background-color: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.form-control:focus {
    border-color: var(--color-primary);
    outline: 0;
    box-shadow: 0 0 0 0.2rem var(--color-primary-glow);
}

/* Grid & Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: -1rem;
}

.col-12 {
    width: 100%;
    padding: 1rem;
}

.col-md-6 {
    width: 50%;
    padding: 1rem;
}

/* Sidebar Customization (overriding Blazor defaults later) */
.sidebar {
    background: var(--color-bg-surface);
    border-right: 1px solid var(--color-border);
}

/* Loading & Errors */
.loading-progress-text {
    position: relative;
    text-align: center;
    font-weight: bold;
    top: 50%;
}

.blazor-error-boundary {
    background: #ff525215;
    border-left: 4px solid #ff5252;
    padding: 1rem;
    margin: 1rem;
    color: #ff5252;
    border-radius: var(--radius-sm);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    color: var(--color-text-main);
}

.table th,
.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.table th {
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.table tbody tr:hover {
    background-color: var(--color-bg-surface-2);
}

/* Light Theme (Default) */
:root[data-theme='light'] {
    --color-bg-body: hsl(var(--hue-primary), 15%, 98%);
    --color-bg-surface: hsl(var(--hue-primary), 20%, 100%);
    --color-bg-surface-2: hsl(var(--hue-primary), 20%, 95%);
    --color-bg-hover: hsl(var(--hue-primary), 20%, 92%);

    --color-text-main: hsl(var(--hue-primary), 50%, 10%);
    --color-text-muted: hsl(var(--hue-primary), 20%, 40%);

    --color-border: hsl(var(--hue-primary), 20%, 85%);

    --color-glass-panel: rgba(255, 255, 255, 0.7);
    --color-heading-gradient-start: var(--color-text-main);
}

/* Dark Theme */
:root[data-theme='dark'] {
    --color-bg-body: var(--color-dark-bg);
    --color-bg-surface: var(--color-dark-surface);
    --color-bg-surface-2: hsl(var(--bg-dark-base), 25%, 16%);
    --color-bg-hover: hsl(var(--bg-dark-base), 25%, 18%);

    --color-text-main: var(--color-dark-text);
    --color-text-muted: var(--color-dark-text-muted);

    --color-border: var(--color-dark-border);

    --color-glass-panel: var(--color-dark-surface-glass);
    --color-heading-gradient-start: #fff;
}

.page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--color-bg-body);
}

/* Header Styles */
.top-header {
    background-color: var(--color-bg-surface);
    border-bottom: 1px solid var(--color-border);
    backdrop-filter: blur(10px);
    z-index: 100;
    transition: all 0.3s ease;
}

.top-header.sticky {
    position: sticky;
    top: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.brand {
    flex-shrink: 0;
}

.brand a {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    transition: transform 0.2s;
    display: inline-block;
}

.brand a:hover {
    transform: scale(1.05);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.main-content article {
    padding: 2rem;
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Footer Styles */
.site-footer {
    background: linear-gradient(135deg, var(--color-bg-surface) 0%, var(--color-bg-body) 100%);
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--color-text-main);
}

.footer-section h4 {
    font-family: var(--font-heading);
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--color-text-main);
}

.footer-section p {
    color: var(--color-text-muted);
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-section ul li a:hover {
    color: var(--color-primary);
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.social-links a:hover {
    color: var(--color-primary);
}

.footer-bottom {
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 2rem;
    text-align: center;
}

.footer-bottom p {
    color: var(--color-text-muted);
    margin: 0;
    font-size: 0.9rem;
}

/* Desktop Defaults (Base Styles) */
.mobile-menu-toggle {
    display: none;
}

.horizontal-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
/* Responsive Header & Nav */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
        align-items: center;
    }

    /* Brand stays first */
    .brand {
        order: 1;
        margin-right: auto;
        /* Pushes everything else to the right */
    }

    .brand a {
        font-size: 1.25rem;
    }

    /* Actions (Login/Theme) come second */
    .header-actions {
        order: 2;
        gap: 0.5rem;
    }

    /* Mobile Toggle comes third */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 30px;
        height: 25px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 101;
        order: 3;
        margin-left: 0.5rem;
    }

    .mobile-menu-toggle span {
        width: 100%;
        height: 3px;
        background: var(--color-text-main);
        border-radius: 10px;
        transition: all 0.3s linear;
        position: relative;
        transform-origin: 1px;
    }

    /* Toggle Animation */
    .mobile-menu-toggle.active span:first-child {
        transform: rotate(45deg);
    }

    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
        transform: translateX(20px);
    }

    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg);
    }

    /* Navigation - Hidden by default on mobile, shown when active */
    .horizontal-nav {
        display: none !important;
        width: 100%;
        flex-direction: column;
        background: var(--color-bg-surface);
        padding: 1rem 0;
        border-top: 1px solid var(--color-border);
        margin-top: 0.5rem;
        animation: slideDown 0.3s ease-out;
        order: 4;
        /* Force to new row */
        flex-basis: 100%;
    }

    .horizontal-nav.mobile-open {
        display: flex !important;
    }

    .horizontal-nav .nav-link {
        padding: 0.75rem 1rem;
        display: block;
        width: 100%;
        border-radius: var(--radius-sm);
    }

    .horizontal-nav .nav-link:hover {
        background: var(--color-bg-surface-2);
    }

    /* Content adjustments */
    .footer-content {
        grid-template-columns: 1fr;
        padding: 2rem 1rem;
        text-align: center;
    }

    .social-links {
        justify-content: center;
    }

    .main-content article {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .post-hero {
        height: 250px;
    }

    .post-title {
        font-size: 2rem;
    }
}

/* Error UI */
#blazor-error-ui {
    background: var(--color-accent);
    color: white;
    bottom: 0;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 1rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    text-align: center;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 1rem;
}

/* EasyMDE Dark Mode Overrides */
[data-theme='dark'] .editor-toolbar,
[data-theme='dark'] .editor-toolbar a,
[data-theme='dark'] .editor-toolbar a.active,
[data-theme='dark'] .editor-toolbar a:hover,
[data-theme='dark'] .CodeMirror,
[data-theme='dark'] .editor-preview {
    background-color: var(--color-bg-surface) !important;
    color: var(--color-text-main) !important;
    border-color: var(--color-border) !important;
}

[data-theme='dark'] .editor-toolbar a {
    color: var(--color-text-muted) !important;
}

[data-theme='dark'] .editor-toolbar a:hover {
    background-color: var(--color-bg-surface-2) !important;
    color: var(--color-text-main) !important;
}

[data-theme='dark'] .CodeMirror-cursor {
    border-left: 2px solid var(--color-primary) !important;
}

[data-theme='dark'] .editor-statusbar {
    color: var(--color-text-muted) !important;
}

[data-theme='dark'] .editor-preview-side {
    border-left: 1px solid var(--color-border) !important;
}

/* Glass-morphism polish for the editor */
.CodeMirror {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.editor-toolbar {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    opacity: 0.9;
}