/* ============================================
   SHARED CHEATSHEET STYLES - BASE TEMPLATE
   ============================================ */

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

/* ============================================
   SCROLLBAR STYLES
   ============================================ */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--section-bg, rgba(0, 0, 0, 0.05));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--header-color, #888);
    border-radius: 10px;
    border: 2px solid var(--card-bg, #fff);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--subheader-color, #555);
}

/* Firefox */
@supports (scrollbar-width: thin) {
* {
    scrollbar-width: thin;
    scrollbar-color: var(--header-color, #888) var(--section-bg, rgba(0, 0, 0, 0.05));
}
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s ease;
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1 {
    color: var(--section-text);
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.4em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    flex: 1 1 100%;
}

.subtitle {
    text-align: center;
    color: var(--section-text);
    margin-bottom: 10px;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* ============================================
   COMPONENTS - Search
   ============================================ */
.search-container {
    flex: 1 1 300px;
    position: relative;
}

.search-box {
    width: 100%;
    padding: 12px 45px 12px 45px;
    border: none;
    border-radius: 25px;
    background: var(--search-bg);
    color: var(--search-text);
    font-size: 16px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.search-box::placeholder {
    color: var(--search-placeholder);
}

.search-box:focus {
    outline: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--search-placeholder);
    font-size: 18px;
}

.clear-search {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--search-placeholder);
    font-size: 20px;
    cursor: pointer;
    display: none;
    padding: 5px;
}

.clear-search:hover {
    color: var(--search-text);
}

.search-results-count {
    text-align: center;
    color: var(--section-text);
    margin-bottom: 15px;
    font-size: 0.9em;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.search-results-count.visible {
    opacity: 1;
}

/* ============================================
   COMPONENTS - Theme Toggle
   ============================================ */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--search-bg);
    padding: 10px 20px;
    border-radius: 25px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.theme-icon {
    font-size: 20px;
}

/* ============================================
   COMPONENTS - Home Link
   ============================================ */
.home-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--search-bg);
    color: var(--header-color);
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    font-size: 16px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

.home-link:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.home-icon {
    font-size: 16px;
}

/* ============================================
   COMPONENTS - Sidebar Navigation
   ============================================ */
.sidebar-nav {
    position: sticky;
    top: 10px;
    width: 250px;
    background: var(--card-bg);
    border-radius: 10px;
    padding: 24px 18px;  /* Balanced padding */
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.sidebar-nav h3 {
    color: var(--header-color);
    font-size: 1.25em;
    margin: 0 0 20px 0;
    padding: 0 8px 12px 8px;  /* Padding on sides and bottom */
    border-bottom: 2px solid var(--section-bg);
}

.sidebar-nav nav {
    display: flex;
    flex-direction: column;
    gap: 4px;  /* Space between links */
}

.sidebar-link {
    display: block;
    padding: 11px 14px;  /* Comfortable padding */
    color: var(--card-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.25s ease;
    font-size: 0.95em;
}

.sidebar-link:hover {
    background: var(--section-bg);
    color: var(--header-color);
    transform: translateX(6px);
    padding-left: 18px;  /* Subtle indent on hover */
}

/* Smooth scrollbar styling */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--section-bg);
    border-radius: 3px;
}

/* ============================================
   COMPONENTS - Sections
   ============================================ */
.section {
    margin-bottom: 20px;
}

.section-title {
    color: var(--section-text);
    font-size: 1.0em;
    font-weight: bold;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--section-bg);
    border-radius: 8px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-controls {
    text-align: center;
    margin-top: 10px;
}

/* ============================================
   COMPONENTS - Cards
   ============================================ */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 4px;
}

.toggle-all-btn {
    background: var(--badge-bg);
    color: var(--badge-text);
    border: none;
    padding: 4px 8px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.toggle-all-btn:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-title {
    font-size: 0.8em;
    font-weight: 600;
    color: var(--header-color);
}

.card-icon {
    font-size: 1.0em;
    transition: transform 0.3s ease;
}

/* Card Icon Image - for image-based card icons */
.card-icon-img {
    vertical-align: middle;
    margin-right: 10px;
    width: 40px;
    height: 40px;
}

.card.expanded .card-icon {
    transform: rotate(180deg);
}

/* Card Content */
.card-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    color: var(--card-text);
    line-height: 1.2;
    font-size: 0.75em;
}

.card.expanded .card-content {
    max-height: 500px;
    overflow-y: auto;
}

/* Card Content Scrollbar */
.card-content::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.card-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.card-content::-webkit-scrollbar-thumb {
    background: var(--header-color);
    border-radius: 4px;
}

.card-content::-webkit-scrollbar-thumb:hover {
    background: var(--header-color);
}

.card-content::-webkit-scrollbar-horizontal {
    height: 4px;
}

/* Card Content Typography */
.card-content h4 {
    color: var(--subheader-color);
    margin-top: 10px;
    margin-bottom: 8px;
}

.card-content ul {
    margin-left: none;
    margin-bottom: 10px;
    list-style: none;
}

.card-content li {
    margin-bottom: 5px;
}

.card-content li {
    padding-left: 20px;
    position: relative;
}

.card-content li::before {
    content: "•";
    position: absolute;
    left: 8px;
}

/* Card Content Code Blocks */
.card-content code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.8em;
}

.card-content pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
    font-size: inherit;
}

.card-content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 10px 0;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 1.0em;
}

body.light-mode .card-content pre {
    border: 1px solid #e0e0e0;
}

/* ============================================
   COMPONENTS - Badges & Tags
   ============================================ */
.badge {
    display: inline-block;
    background: transparent;
    color: var(--badge-text);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    margin-top: 8px;
}

.tag {
    display: inline-block;
    color: var(--badge-bg);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.85em;
    margin: 4px 4px 4px 0;
}

/* ============================================
   COMPONENTS - Footer
   ============================================ */
.footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: var(--section-text);
    opacity: 0.8;
    font-size: 0.9em;
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

.highlight {
    background-color: #ffeb3b;
    color: #000;
    padding: 2px 4px;
    border-radius: 3px;
}

body.light-mode .highlight {
    background-color: #fff176;
}

/* ============================================
   COMPONENTS - Tooltips
   ============================================ */
.tooltip-container {
    position: relative;
    cursor: help;
    display: inline-block;
}

.tooltip-text {
    visibility: hidden;
    width: 280px;
    background-color: var(--card-bg);
    color: var(--subheader-color);
    text-align: left;
    border-radius: 8px;
    padding: 12px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 0;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    font-size: 0.9rem;
    font-weight: normal;
    line-height: 1.3;
    pointer-events: none;
    border: 1px solid rgba(0,0,0,0.1);
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateY(-5px);
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
/* Focus styles */
.search-box:focus,
.home-link:focus,
.theme-toggle:focus,
.toggle-all-btn:focus,
.card:focus {
    outline: 2px solid var(--header-color);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--header-color);
    outline-offset: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
/* Tablet breakpoint for sidebar layout */
@media (max-width: 968px) {
    .page-layout {
        flex-direction: column;
    }

    .sidebar-nav {
        position: relative;
        width: 100%;
        max-height: none;
        top: 0;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1rem;
    }

    .section-title {
        font-size: 1.1em;
    }

    .cards-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        padding: 12px;
    }

    .search-box {
        font-size: 14px;
    }

    .header-controls {
        gap: 8px;
        flex-wrap: wrap;
        justify-content: center;
    }

    .home-link {
        padding: 10px 12px;
        font-size: 14px;
        flex-shrink: 0;
    }

    .search-container {
        flex: 1 1 200px;
        min-width: 150px;
    }

    .theme-toggle {
        flex-shrink: 0;
    }

    /* Sidebar collapses to full width on mobile */
    .sidebar-nav {
        position: relative;
        width: 100%;
        max-height: none;
        top: 0;
        margin-bottom: 20px;
    }

    .sidebar-nav nav {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .sidebar-link {
        flex: 0 0 auto;
        padding: 8px 12px;
    }

    .sidebar-link:hover {
        transform: none;
        padding-left: 12px;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 480px) {
    h1 {
        font-size: 1.5em;
    }

    .header-controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .home-link {
        order: 1;
    }

    .search-container {
        order: 2;
        flex: 1 1 100%;
        width: 100%;
    }

    .theme-toggle {
        order: 3;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1000;
        background: var(--card-bg);
        border-radius: 50%;
        width: 50px;
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .header-controls,
    .search-container,
    .theme-toggle,
    .toggle-all-btn,
    .search-results-count {
        display: none !important;
    }

    .card {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
        margin-bottom: 10px;
    }

    .card-content {
        max-height: none !important;
        overflow: visible !important;
    }

    .card.expanded .card-content,
    .card-content {
        display: block !important;
    }

    h1 {
        color: #000;
        text-shadow: none;
    }

    .section-title {
        color: #000;
        background: #f0f0f0;
    }
}
