/**
 * Mainframe Dictionary - Mobile-First Responsive Styles
 * COBOL, JCL, VSAM, CICS Reference Guide
 */

/* ===== Root Variables ===== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;

    --cobol-color: #2196F3;
    --jcl-color: #4CAF50;
    --vsam-color: #FF9800;
    --cics-color: #9C27B0;

    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;

    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Consolas', 'Monaco', monospace;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --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);

    --radius: 0.5rem;
    --radius-lg: 0.75rem;
}

/* ===== Base Styles ===== */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans Telugu', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
}

/* Telugu Text Optimization */
h1, h2, h3, h4, h5, h6, p, li, td, th, label, span, a {
    font-family: 'Noto Sans Telugu', 'Inter', sans-serif;
}

code, pre, .code-block, .keyword-name {
    font-family: var(--font-mono);
}

/* ===== Navigation ===== */
.navbar {
    box-shadow: var(--shadow);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

.brand-text {
    font-family: var(--font-mono);
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

.nav-link.active {
    color: var(--primary-color) !important;
}

.search-form {
    width: 100%;
    max-width: 300px;
}

.search-form .form-control {
    border-radius: var(--radius) 0 0 var(--radius);
}

/* ===== Hero Section ===== */
.hero-section {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 3rem 0;
    margin-bottom: 2rem;
    text-align: center;
}

.hero-section h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.hero-search {
    max-width: 600px;
    margin: 2rem auto 0;
}

.hero-search .form-control {
    padding: 1rem 1.25rem;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius) 0 0 var(--radius);
}

.hero-search .btn {
    padding: 1rem 1.5rem;
    border-radius: 0 var(--radius) var(--radius) 0;
}

/* ===== Stats Section ===== */
.stats-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin: -3rem auto 2rem;
    max-width: 900px;
    position: relative;
    z-index: 10;
    padding: 0 1rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.stat-card .number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    display: block;
}

.stat-card .label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    display: block;
}

/* ===== Category Cards ===== */
.category-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}

.category-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
    border-left: 4px solid #ccc;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    color: inherit;
    text-decoration: none;
}

.category-card.cobol { border-left-color: var(--cobol-color); }
.category-card.jcl { border-left-color: var(--jcl-color); }
.category-card.vsam { border-left-color: var(--vsam-color); }
.category-card.cics { border-left-color: var(--cics-color); }

.category-card .icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    margin-bottom: 1rem;
    background: var(--secondary-color);
}

.category-card.cobol .icon { background: var(--cobol-color); }
.category-card.jcl .icon { background: var(--jcl-color); }
.category-card.vsam .icon { background: var(--vsam-color); }
.category-card.cics .icon { background: var(--cics-color); }

.category-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.category-card .full-name {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.category-card .stats {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

/* ===== Keyword Cards ===== */
.keyword-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.keyword-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
    border: 1px solid var(--border-color);
}

.keyword-card:hover {
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
}

.keyword-card .keyword-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.keyword-card .keyword-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== Keyword Detail Page ===== */
.keyword-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.keyword-header .keyword-title {
    font-family: var(--font-mono);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.keyword-header .category-badge {
    display: inline-block;
    padding: 0.35rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    background: rgba(255,255,255,0.2);
}

.content-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.content-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.content-section h3 i {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

/* ===== Code Blocks ===== */
.code-block {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    position: relative;
}

.code-block .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.code-block .copy-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== TOC - Table of Contents ===== */
.toc {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    position: sticky;
    top: 1rem;
}

.toc h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

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

.toc a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    display: block;
    padding: 0.25rem 0;
    transition: color 0.2s;
}

.toc a:hover {
    color: var(--primary-color);
}

/* ===== Search Page ===== */
.search-results {
    margin-top: 1.5rem;
}

.search-result-item {
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.search-result-item h4 {
    font-family: var(--font-mono);
    margin-bottom: 0.5rem;
}

.search-result-item h4 a {
    color: var(--primary-color);
    text-decoration: none;
}

.search-result-item h4 a:hover {
    text-decoration: underline;
}

.search-result-item p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* ===== Error Codes Page ===== */
.error-code-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--danger-color);
    box-shadow: var(--shadow-sm);
}

.error-code-card .error-code {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--danger-color);
    font-size: 1.1rem;
}

.error-code-card .error-title {
    font-weight: 600;
    margin: 0.5rem 0;
}

.error-code-card .error-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Alphabet Index ===== */
.alphabet-index {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.alphabet-index a {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    color: var(--text-color);
    transition: all 0.2s;
}

.alphabet-index a:hover,
.alphabet-index a.active {
    background: var(--primary-color);
    color: white;
}

.alphabet-index a.disabled {
    color: var(--text-muted);
    pointer-events: none;
    opacity: 0.5;
}

/* ===== Footer ===== */
.footer {
    background: #1e293b;
    color: #94a3b8;
    padding: 3rem 0 1.5rem;
    margin-top: 4rem;
}

.footer a {
    color: #94a3b8;
    text-decoration: none;
    transition: color 0.2s;
}

.footer a:hover {
    color: white;
}

.footer h5 {
    color: white;
    font-weight: 600;
    margin-bottom: 1rem;
}

.footer-bottom {
    border-top: 1px solid #334155;
    padding-top: 1.5rem;
    margin-top: 2rem;
}

/* ===== Breadcrumb ===== */
.breadcrumb-wrapper {
    background: var(--card-bg);
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.breadcrumb {
    margin: 0;
    font-size: 0.875rem;
}

.breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
}

/* ===== Cards ===== */
.card {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

/* ===== Buttons ===== */
.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 991px) {
    .hero-section h1 {
        font-size: 2rem;
    }

    .stats-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-top: -2rem;
    }

    .stat-card .number {
        font-size: 2rem;
    }

    .category-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575px) {
    .hero-section {
        padding: 2rem 0;
    }

    .hero-section h1 {
        font-size: 1.5rem;
    }

    .hero-search .form-control {
        padding: 0.75rem 1rem;
    }

    .hero-search .btn {
        padding: 0.75rem 1rem;
    }

    .stats-section {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-top: -1.5rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .number {
        font-size: 1.5rem;
    }

    .stat-card .label {
        font-size: 0.8rem;
    }

    .category-card {
        padding: 1rem;
    }

    .content-section {
        padding: 1.25rem;
    }

    .keyword-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Print Styles ===== */
@media print {
    .navbar, .footer, .toc, .hero-search {
        display: none !important;
    }

    body {
        font-size: 12pt;
    }

    .code-block {
        background: #f5f5f5 !important;
        color: #333 !important;
        border: 1px solid #ccc;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* ===== List Group Improvements ===== */
.list-group-item {
    border-left: none;
    border-right: none;
}

.list-group-item:first-child {
    border-top: none;
}

/* ===== Badge Colors ===== */
.badge.cobol { background-color: var(--cobol-color); }
.badge.jcl { background-color: var(--jcl-color); }
.badge.vsam { background-color: var(--vsam-color); }
.badge.cics { background-color: var(--cics-color); }

/* ===== Improved Keyword Detail Page ===== */
.keyword-detail {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.keyword-detail .keyword-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    color: white;
    padding: 2rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.keyword-detail .keyword-header.cobol { background: linear-gradient(135deg, #1565C0 0%, #1976D2 100%); }
.keyword-detail .keyword-header.jcl { background: linear-gradient(135deg, #2E7D32 0%, #388E3C 100%); }
.keyword-detail .keyword-header.vsam { background: linear-gradient(135deg, #E65100 0%, #F57C00 100%); }
.keyword-detail .keyword-header.cics { background: linear-gradient(135deg, #6A1B9A 0%, #7B1FA2 100%); }

.keyword-detail .keyword-name {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.keyword-detail .category-badge {
    display: inline-block;
    padding: 0.35rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(5px);
}

.keyword-body {
    padding: 2rem;
}

/* Table of Contents */
.keyword-body .toc {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.keyword-body .toc h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
}

.keyword-body .toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}

.keyword-body .toc li a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.keyword-body .toc li a:hover {
    background: white;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Content Sections */
.keyword-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.keyword-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.keyword-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.keyword-section h2 i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.keyword-section .content {
    color: var(--text-color);
    line-height: 1.8;
    font-size: 1rem;
}

/* Syntax Box */
.syntax-box {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow-x: auto;
    position: relative;
    border-left: 4px solid var(--primary-color);
}

.syntax-box code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
    display: block;
    line-height: 1.6;
}

/* Info Boxes for How/When/Where/Why */
.keyword-section .content.info-box {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-left: 4px solid #0ea5e9;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

/* Sidebar Improvements */
.keyword-sidebar .card {
    border: none;
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
}

.keyword-sidebar .card-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 2px solid var(--primary-color);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.keyword-sidebar .list-group-item {
    border: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
}

.keyword-sidebar .list-group-item:last-child {
    border-bottom: none;
}

.keyword-sidebar .list-group-item a {
    color: var(--text-color);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: color 0.2s;
}

.keyword-sidebar .list-group-item a:hover {
    color: var(--primary-color);
}

/* Quick Navigation */
.quick-nav {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.quick-nav h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quick-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.quick-nav li {
    margin-bottom: 0.5rem;
}

.quick-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.quick-nav a:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

/* Mobile Responsive */
@media (max-width: 991px) {
    .keyword-detail .keyword-header {
        padding: 1.5rem;
    }
    
    .keyword-detail .keyword-name {
        font-size: 1.5rem;
    }
    
    .keyword-body {
        padding: 1.5rem;
    }
    
    .keyword-body .toc ul {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575px) {
    .keyword-detail .keyword-header {
        padding: 1.25rem;
    }
    
    .keyword-detail .keyword-name {
        font-size: 1.25rem;
    }
    
    .keyword-body {
        padding: 1rem;
    }
    
    .syntax-box {
        padding: 1rem;
    }
    
    .syntax-box code {
        font-size: 0.8rem;
    }
}
