/* =========================================
   1. DEFINE THEMES & VARIABLES
   ========================================= */
:root {
    --bg-color: #1a1d23;
    --sidebar-bg: #24292e;
    --card-bg: #ffffff;
    --text-main: #e8eaed; /* White in Dark Mode */
    --text-dark: #333;
    --accent-blue: #3498db;
    --nav-bg: #2b303b;
    --bg-pattern: url("icons/back.svg"); 
    --sidebar-width: 260px;
}

body.light-mode {
    --bg-color: #f0f2f5;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #1a1d23; /* Black in Light Mode */
    --nav-bg: #ffffff;
    --accent-blue: #2980b9;
}

/* =========================================
   2. BASE STYLES
   ========================================= */
body {
    margin: 0;
    font-family: 'Lucida Console', 'Courier New', monospace;
    background-color: var(--bg-color);
    background-image: var(--bg-pattern);
    background-repeat: repeat;
    background-attachment: fixed;
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

/* Global Text Inheritance */
h1, h2, h3, p, span, a, div, button {
    font-family: 'Lucida Console', 'Courier New', monospace;
    color: inherit;
    text-decoration: none;
}

/* =========================================
   3. WIDE TOPNAV
   ========================================= */
.topnav-layout {
    background: linear-gradient(to bottom, var(--nav-bg), rgba(0,0,0,0.05));
    padding: 15px 30px; 
    border-bottom: 2px solid rgba(0,0,0,0.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s ease;
}

#navbar2 ul {
    display: flex;
    justify-content: space-between;
    list-style: none;
    padding: 0;
    margin: 0;
    align-items: center;
}

.brand-container {
    display: flex;
    align-items: center;
    font-weight: bold;
    font-size: 1.3rem;
}

.nav-right { 
    display: flex; 
    gap: 25px; 
    align-items: center; 
}

.nav-link { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    opacity: 0.8; 
    transition: 0.2s; 
}

.nav-link:hover { 
    opacity: 1; 
}

/* =========================================
   4. THEME TOGGLE BUTTON
   ========================================= */
#theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0;
}

#theme-toggle:hover {
    background: rgba(255,255,255,0.1);
    transform: rotate(15deg) scale(1.1);
}

body.light-mode #theme-toggle { 
    border-color: rgba(0,0,0,0.1); 
}

/* =========================================
   5. SIDEBAR & MAIN LAYOUT
   ========================================= */
.sidebar-layout { 
    display: flex; 
    min-height: calc(100vh - 82px); 
    align-items: stretch;
}

#sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    padding: 10px 0;
    transition: background 0.3s ease;
    border-right: 1px solid rgba(0,0,0,0.15);
    box-shadow: 4px 0 10px rgba(0,0,0,0.05);
}

.menu-list { 
    list-style: none; 
    padding: 0; 
    margin: 0;
}

/* Sidebar Separators */
.menu-list li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

body.light-mode .menu-list li {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.menu-list li a, .dropdown-btn {
    display: flex;
    align-items: center;
    padding: 18px 25px;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    transition: 0.2s;
    box-sizing: border-box;
    text-align: left;
}

/* Contrast adjustment for sidebar text */
.menu-list li a { color: #adb5bd; }
body.light-mode .menu-list li a { color: #555; }

/* The Highlight State */
.menu-list li a:hover, .active { 
    background: var(--accent-blue); 
    color: white !important; 
    border-left: 5px solid rgba(255,255,255,0.3);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.sub-menu {
    list-style: none;
    background: rgba(0,0,0,0.1);
    display: none;
    padding: 0;
}

.sub-menu.show { display: block; }

.sub-menu li a {
    padding: 12px 25px 12px 60px;
    font-size: 0.85rem;
}

#main-content {
    flex: 1;
    padding: 40px;
    background: rgba(26, 29, 35, 0.05);
}

/* =========================================
   6. GRID & CARDS
   ========================================= */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 30px;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    color: #333; /* Dark text for the white cards */
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid rgba(0,0,0,0.05);
}

.card-link:hover .card { 
    transform: translateY(-12px); 
    box-shadow: 0 20px 40px rgba(0,0,0,0.4); 
}

.browser-mockup { background: #e0e0e0; border-bottom: 1px solid #ccc; }
.browser-header { padding: 10px 15px; display: flex; align-items: center; }
.dots { display: flex; gap: 6px; }
.dots span { width: 10px; height: 10px; border-radius: 50%; }
.r { background: #ff5f56; } .y { background: #ffbd2e; } .g { background: #27c93f; }
.url-bar { background: white; flex: 1; margin: 0 15px; border-radius: 6px; padding: 4px 12px; font-size: 0.75rem; color: #888; }
.preview-img-container { height: 180px; display: flex; align-items: center; justify-content: center; background: #fdfdfd; }

.card-body { padding: 25px; flex-grow: 1; background: white; }
.card-body p { line-height: 1.6; }



/* =========================================
   7. ICONS & FILTERS
   ========================================= */
.nav-icon, .nav-icon-sm, #sidebar img, #theme-toggle img { 
    flex-shrink: 0;
    object-fit: contain;
    transition: filter 0.3s ease;
    /* DEFAULT: Icons are inverted to White in Dark Mode */
    filter: invert(1); 
}

.nav-icon { width: 32px; height: 32px; margin-right: 12px; }
.nav-icon-sm { width: 20px; height: 20px; }
#sidebar img { width: 18px; height: 18px; margin-right: 18px; }
#theme-toggle img { width: 22px; height: 22px; }

/* LIGHT MODE: Icons are flipped back to Black */
body.light-mode .nav-icon, 
body.light-mode .nav-icon-sm, 
body.light-mode #sidebar img, 
body.light-mode #theme-toggle img { 
    filter: invert(0); 
}

/* Exceptions: Keep the icons inside the cards looking normal */
.preview-img-container img { 
    width: 100%; 
    height: 100%;
    object-fit: cover;
}

.active img, .menu-list li a:hover img { 
    filter: invert(1) !important; /* Force white icon on blue highlight */
}

/* Arrow styling for Dropdowns */
.arrow {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    margin-left: auto;
}
