* { margin: 0; padding: 0; box-sizing: border-box; }

/* CSS Variables - LIGHT MODE (default) */
:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f7ff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #888888;
    --accent-primary: #0070f2;
    --accent-secondary: #003d8f;
    --accent-orange: #ff6b35;
    --border-color: #e0e0e0;
    --shadow: 0 4px 15px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.15);
    --footer-bg: #1a1a2e;
    --footer-text: #ffffff;
    --code-bg: #1e1e1e;
    --code-text: #d4d4d4;
}

/* DARK MODE */
[data-theme="dark"] {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-tertiary: #1e2535;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --text-muted: #8a8d91;
    --accent-primary: #4a9eff;
    --accent-secondary: #6db3ff;
    --accent-orange: #ff8a5b;
    --border-color: #2d3548;
    --shadow: 0 4px 15px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 25px rgba(0,0,0,0.5);
    --footer-bg: #050810;
    --footer-text: #e4e6eb;
    --code-bg: #0d1117;
    --code-text: #e4e6eb;
}

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background 0.3s, color 0.3s;
}

/* HEADER */
header {
    background: var(--bg-secondary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background 0.3s;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    max-width: 1200px;
    margin: 0 auto;
}

.logo {
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--accent-primary);
}
.logo span { color: var(--accent-orange); }

/* Logo als Link */
a.logo {
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

a.logo:hover {
    opacity: 0.8;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    transition: 0.3s;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--accent-primary);
}

/* THEME TOGGLE BUTTON */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle:hover {
    border-color: var(--accent-primary);
    transform: rotate(15deg);
}

.hamburger { display: none; font-size: 1.5rem; cursor: pointer; color: var(--text-primary); }

/* HERO */
.hero {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    padding: 6rem 5%;
    text-align: center;
}

.hero h1 { font-size: 2.8rem; margin-bottom: 1rem; }
.hero p { font-size: 1.2rem; margin-bottom: 2rem; }

.btn {
    display: inline-block;
    background: var(--accent-orange);
    color: white;
    padding: 0.8rem 2rem;
    border-radius: 5px;
    text-decoration: none;
    transition: 0.3s;
}
.btn:hover { background: #e55a2b; transform: translateY(-2px); }

/* SECTIONS */
section { padding: 4rem 5%; max-width: 1200px; margin: 0 auto; }
section h2 { text-align: center; margin-bottom: 2rem; font-size: 2rem; color: var(--accent-secondary); }

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.post-card {
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: 0.3s;
}
.post-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }

.post-card img { width: 100%; height: 200px; object-fit: cover; background: var(--bg-tertiary); }
.post-card-content { padding: 1.5rem; }
.post-card h3 { color: var(--accent-secondary); margin-bottom: 0.5rem; }
.post-card .meta { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1rem; display: block; }
.post-card p { color: var(--text-secondary); margin-bottom: 1rem; }
.post-card a { color: var(--accent-primary); text-decoration: none; font-weight: bold; }

.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.cat-card {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: 0.3s;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
}
.cat-card:hover { background: var(--accent-primary); color: white; }

/* PAGE HERO */
.page-hero {
    background: var(--accent-secondary);
    color: white;
    text-align: center;
    padding: 3rem 5%;
}
.page-hero h1 { font-size: 2.5rem; margin-bottom: 1rem; }
#search {
    padding: 0.8rem 1.5rem;
    width: 100%;
    max-width: 500px;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* FOOTER */
footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 3rem 5% 1rem;
    margin-top: 4rem;
}
.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto 2rem;
}
.footer-content h3 { margin-bottom: 1rem; color: var(--accent-orange); }
.footer-content ul { list-style: none; }
.footer-content a { color: #ccc; text-decoration: none; }
.footer-content a:hover { color: white; }
.copyright { text-align: center; padding-top: 2rem; border-top: 1px solid #333; }

/* ARTICLE (post) */
.article {
    max-width: 1100px;
    margin: 3rem auto;
    background: var(--bg-secondary);
    padding: 3rem;
    border-radius: 10px;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}
.article h1 { color: var(--accent-secondary); margin-bottom: 1rem; }
.article .meta { color: var(--text-muted); margin-bottom: 2rem; }
.article h2 { text-align: left; color: var(--accent-primary); margin: 1.5rem 0 1rem; }
.article h3 { color: var(--accent-secondary); margin: 1rem 0 0.5rem; }
.article p { margin-bottom: 1rem; color: var(--text-primary); }
.article a { color: var(--accent-primary); }
.article ul, .article ol { color: var(--text-primary); }

/* CODE - inline */
.article code:not(pre code) {
    background: var(--bg-tertiary);
    color: var(--accent-orange);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Consolas', 'Monaco', monospace;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .nav-links { display: none; }
    .hamburger { display: block; }
    .nav-links.show { 
        display: flex; flex-direction: column;
        position: absolute; top: 60px; right: 0;
        background: var(--bg-secondary); width: 200px; padding: 1rem;
    }
    .hero h1 { font-size: 2rem; }
    .article { padding: 1.5rem; }
}

/* Kategorije kao linkovi */
.cat-card {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* Prism.js custom adjustments */
pre[class*="language-"] {
    border-radius: 8px;
    margin: 1.5rem 0 !important;
    font-size: 0.9rem;
}

.line-numbers .line-numbers-rows {
    border-right-color: #444 !important;
}

div.code-toolbar > .toolbar button {
    background: var(--accent-primary) !important;
    color: white !important;
    border-radius: 4px !important;
    padding: 0.3rem 0.7rem !important;
    font-size: 0.8rem !important;
}

/* ============================================================
   POSTS CONTROLS - Brojač i Sortiranje (modern style)
   ============================================================ */
.posts-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding: 1.2rem 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    gap: 1rem;
}

.posts-count {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.posts-count::before {
    content: "📚";
    font-size: 1.1rem;
}

.sort-wrapper {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.sort-wrapper label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

#sort-select {
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    
    /* Custom arrow */
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230070f2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

#sort-select:hover {
    border-color: var(--accent-primary);
}

#sort-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 112, 242, 0.15);
}


/* ============================================================
   PAGINATION - Moderne, čiste dugmadi
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    margin-top: 4rem;
    flex-wrap: wrap;
}

.pagination button {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
    padding: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* Wider buttons for "« Zurück" and "Weiter »" */
.pagination button[data-page="0"],
.pagination button:first-child,
.pagination button:last-child {
    width: auto;
    padding: 0 1.2rem;
    gap: 0.3rem;
}

.pagination button:hover:not(:disabled):not(.active) {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 112, 242, 0.15);
}

.pagination button.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 112, 242, 0.3);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination button:disabled:hover {
    transform: none;
    box-shadow: none;
}

.pagination .dots {
    color: var(--text-muted);
    padding: 0 0.5rem;
    font-weight: bold;
    user-select: none;
}


/* ============================================================
   RESPONSIVE - mobilni izgled
   ============================================================ */
@media (max-width: 600px) {
    .posts-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sort-wrapper {
        justify-content: space-between;
    }
    
    #sort-select {
        flex: 1;
    }
    
    .pagination button {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }
    
    .pagination button:first-child,
    .pagination button:last-child {
        padding: 0 0.8rem;
        font-size: 0.85rem;
    }
}

/* ============================================================
   FLOATING THEME TOGGLE BUTTON
   ============================================================ */
#theme-toggle-floating {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--accent-primary);
    color: white;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 112, 242, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.3s ease;
}

#theme-toggle-floating:hover {
    transform: translateY(-4px) rotate(15deg);
    box-shadow: 0 8px 25px rgba(0, 112, 242, 0.6);
}

#theme-toggle-floating:active {
    transform: translateY(0) rotate(0deg);
}

@media (max-width: 600px) {
    #theme-toggle-floating {
        bottom: 1.2rem;
        right: 1.2rem;
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }
}

/* ============================================================
   EXTERNAL LINK MODAL
   ============================================================ */
#external-link-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

#external-link-modal.show {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.external-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    cursor: pointer;
}

.external-modal-box {
    position: relative;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 16px;
    padding: 2.5rem 2rem 2rem;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: slideUp 0.3s ease;
}

.external-modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.external-modal-box h3 {
    margin-bottom: 1rem;
    color: var(--accent-secondary);
    font-size: 1.4rem;
}

.external-modal-box p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.external-modal-url {
    background: var(--bg-tertiary);
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    color: var(--accent-primary) !important;
    word-break: break-all;
    margin: 1rem 0 1.5rem !important;
}

.external-modal-buttons {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
    flex-wrap: wrap;
}

.external-modal-buttons button {
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    border: 1.5px solid;
}

.btn-cancel {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-cancel:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.btn-continue {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.btn-continue:hover {
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 112, 242, 0.3);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 600px) {
    .external-modal-box {
        padding: 2rem 1.2rem 1.5rem;
    }
    
    .external-modal-buttons button {
        width: 100%;
    }
}

/* ============================================================
   SCROLL TO TOP BUTTON
   ============================================================ */
#scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 6.5rem;  /* lijevo od theme toggle dugmeta */
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--accent-primary);
    font-size: 1.6rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: 2px solid var(--border-color);
    
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    
    /* Standardno sakriven */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

#scroll-top-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scroll-top-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 112, 242, 0.3);
}

#scroll-top-btn:active {
    transform: translateY(0);
}

@media (max-width: 600px) {
    #scroll-top-btn {
        bottom: 1.2rem;
        right: 5.5rem;  /* lijevo od theme toggle dugmeta */
        width: 42px;
        height: 42px;
        font-size: 1.3rem;
    }
}