:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    transition: var(--transition);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Specific scroll areas */
nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin-right: -10px;
    /* Hide scrollbar visually but keep functionality or adjust padding */
    padding-right: 10px;
}

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    height: 100vh;
}

/* Mobile responsive layout */
@media (max-width: 1200px) {
    .app-container {
        grid-template-columns: 240px 1fr;
    }

    .ad-sidebar {
        display: none;
    }
}

@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
        /* We'd normally use a hamburger menu here */
    }
}

/* Sidebar Styling */
.sidebar {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    height: 100vh;
    overflow: hidden;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-item:hover {
    background: var(--glass-bg);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* Main Content area */
.main-content {
    padding: 2rem;
    overflow-y: auto;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent);
}

.module-header {
    margin-bottom: 2rem;
}

.module-title {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.module-description {
    color: var(--text-muted);
}

.module-container {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 2rem;
    min-height: 400px;
    box-shadow: var(--shadow);
}

/* Ad Sidebars */
.ad-sidebar {
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100vh;
    overflow: hidden;
}

.ad-placeholder {
    display: flex;
    justify-content: center;
    background: transparent;
    border-radius: 12px;
    overflow: hidden;
    /* Optional: Min-height can be kept if you want to reserve space, but usually auto is better for responsiveness unless using fixed units */
    min-height: 250px;
}

/* Buttons and Inputs */
button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
}

input,
textarea,
select {
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    padding: 0.75rem;
    font-family: inherit;
    transition: var(--transition);
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Module Specific Styles */

/* Calculator */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 0 auto;
}

.calc-display {
    grid-column: span 4;
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    font-size: 2rem;
    text-align: right;
    border-radius: 12px;
    margin-bottom: 10px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.calc-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    font-size: 1.25rem;
    border-radius: 12px;
    color: white;
    transition: var(--transition);
}

.calc-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.calc-btn:active,
.calc-btn.pressed {
    background: var(--primary);
    transform: scale(0.95);
    box-shadow: 0 0 10px var(--primary);
}

.calc-btn.op {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

.calc-btn.eq {
    background: var(--primary);
    grid-column: span 2;
}

/* Notepad */
.notepad-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#notepad-area {
    width: 100%;
    flex-grow: 1;
    min-height: 400px;
    padding: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.6;
    resize: none;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.2);
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

@media (max-width: 900px) {

    /* Collapse calc grid to stack history below */
    .calc-grid+.result-card {
        max-height: 300px !important;
    }
}

/* Subnet Calc */
.subnet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .subnet-grid {
        grid-template-columns: 1fr;
    }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.result-row:last-child {
    border-bottom: none;
}

.result-label {
    color: var(--text-muted);
}

.result-value {
    font-family: monospace;
    color: var(--primary);
    font-weight: 600;
}