* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f0f0;
    color: #333;
    line-height: 1.5;
}

/* ========== HEADER ========== */
header {
    background: #004080;
    color: white;
    padding: 12px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}

header h1 {
    font-size: 1.8rem;
    letter-spacing: 1px;
    white-space: nowrap;
}

header h1 span {
    color: #ff8c00;
}

.header-sub {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* ========== JOIN TOGGLE ========== */
.join-toggle {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    font-size: 0.82rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.toggle-on {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

.toggle-off {
    background: rgba(244, 67, 54, 0.2);
    color: #ef9a9a;
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ef5350;
    border-radius: 26px;
    transition: 0.3s;
}

.slider:before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider {
    background: #4caf50;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* ========== CATEGORY NAV ========== */
.cat-nav {
    background: white;
    border-bottom: 2px solid #ff8c00;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.cat-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 0;
}

.cat-nav-inner > div {
    display: contents;
}

.cat-nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #004080;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.cat-nav-item:hover {
    background: #f0f6ff;
    border-bottom-color: #ff8c00;
}

.cat-nav-item .material-icons {
    font-size: 18px;
    color: #ff8c00;
}

.cat-count {
    background: #e8f0fe;
    color: #004080;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
}

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

.error-box {
    background: #fee;
    border: 1px solid #fcc;
    color: #c00;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

/* ========== MAIN LAYOUT ========== */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

/* ========== SECTIONS ========== */
section {
    background: white;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #eee;
}

.section-header h2 {
    font-size: 1.1rem;
    color: #333;
}

.sql-hint {
    font-size: 0.72rem;
    font-family: 'Courier New', monospace;
    color: #888;
    background: #f5f5f5;
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid #e0e0e0;
}

/* ========== OGLAS KARTICA ========== */
.oglasi-lista {
    padding: 0;
}

.oglas-kartica {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid #eee;
    transition: background 0.15s;
}

.oglas-kartica:last-child {
    border-bottom: none;
}

.oglas-kartica:hover {
    background: #fafbff;
}

.oglas-slika {
    width: 140px;
    min-height: 100px;
    background: #e8f0fe;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.oglas-slika .material-icons {
    font-size: 40px;
    color: #004080;
    opacity: 0.4;
}

.oglas-slika-sm {
    width: 80px;
    min-height: 70px;
}

.oglas-slika-sm .material-icons {
    font-size: 28px;
}

.oglas-rang {
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 800;
    color: #ff8c00;
    flex-shrink: 0;
}

.oglas-info {
    flex: 1;
    padding: 12px 16px;
    min-width: 0;
}

.oglas-naslov {
    font-size: 0.95rem;
    font-weight: 600;
    color: #004080;
    margin-bottom: 4px;
    line-height: 1.3;
}

.oglas-kartica:hover .oglas-naslov {
    color: #ff8c00;
}

.oglas-opis {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 8px;
    line-height: 1.4;
}

.oglas-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.75rem;
    color: #888;
}

.oglas-meta span {
    display: flex;
    align-items: center;
    gap: 2px;
}

.oglas-meta .material-icons {
    font-size: 14px;
    color: #aaa;
}

.oglas-cijena-box {
    width: 140px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    padding: 12px 16px;
    flex-shrink: 0;
    text-align: right;
}

.oglas-cijena {
    font-size: 1.15rem;
    font-weight: 800;
    color: #333;
    white-space: nowrap;
}

.oglas-kategorija {
    font-size: 0.7rem;
    color: #888;
    margin-top: 2px;
}

.nema-oglasa {
    padding: 40px;
    text-align: center;
    color: #aaa;
}

/* Raw ID stilovi (bez joina) */
.raw-id {
    font-family: 'Courier New', monospace;
    color: #e74c3c;
    font-weight: 700;
    font-size: 0.8rem;
}

.raw-id-small {
    font-family: 'Courier New', monospace;
    color: #e74c3c;
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 2px;
}

.oglas-slika-raw {
    background: #fde8e8;
}

.oglas-slika-raw .material-icons {
    color: #e74c3c;
    opacity: 0.5;
}

.oglas-kartica-raw {
    border-left: 3px solid #e74c3c;
}

.sql-hint-nojoins {
    background: #fde8e8;
    border-color: #e74c3c;
    color: #c62828;
}

.sql-hint-nojoins strong {
    color: #e74c3c;
}

.sql-hint strong {
    color: #4caf50;
}

.sql-hint-sm-nojoins {
    background: #fde8e8;
    color: #e74c3c;
}

.stat-row-raw {
    border-left: 3px solid #e74c3c;
}

/* ========== SIDEBAR ========== */
.sidebar-box {
    background: white;
    border-radius: 6px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h3 {
    font-size: 0.95rem;
    color: #333;
}

.sql-hint-sm {
    font-size: 0.65rem;
    font-family: 'Courier New', monospace;
    color: #aaa;
    background: #f8f8f8;
    padding: 2px 6px;
    border-radius: 3px;
}

/* Stat rows */
.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-icon {
    font-size: 20px;
    color: #ff8c00;
}

.stat-naziv {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
}

.stat-avg {
    font-size: 0.72rem;
    color: #888;
}

.stat-broj {
    font-size: 1.3rem;
    font-weight: 800;
    color: #004080;
}

/* ========== SCHEMA TABLES ========== */
.schema-table {
    border-bottom: 1px solid #f0f0f0;
}

.schema-table:last-child {
    border-bottom: none;
}

.schema-name {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    font-weight: 700;
    color: #004080;
    padding: 8px 16px 4px;
    background: #f8fafe;
}

.schema-cols {
    padding: 0 16px 8px;
}

.schema-col {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 0.75rem;
}

.col-name {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #333;
    min-width: 90px;
}

.col-name.pk {
    color: #ff8c00;
}

.col-name.fk {
    color: #e74c3c;
}

.col-type {
    color: #999;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
}

.col-badge {
    font-size: 0.6rem;
    padding: 0 4px;
    border-radius: 3px;
    font-weight: 700;
}

.pk-badge {
    background: #fff3e0;
    color: #ff8c00;
}

.fk-badge {
    background: #fde8e8;
    color: #e74c3c;
}

/* ========== COUNTER BAR ========== */
.counter-bar {
    background: #003366;
    padding: 14px 0 10px;
}

.counter-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.counter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.7);
}

.counter-item .material-icons {
    font-size: 20px;
    opacity: 0.5;
}

.counter-num {
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
}

.counter-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.counter-highlight .counter-num {
    color: #ff8c00;
}

.counter-sql {
    max-width: 1200px;
    margin: 8px auto 0;
    padding: 0 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.65rem;
    color: rgba(255,255,255,0.3);
}

/* ========== SEARCH BAR ========== */
.search-bar {
    background: #004080;
    padding: 12px 0;
}

.search-form {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-icon {
    color: white;
    font-size: 22px;
}

.search-form input[type="text"] {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    outline: none;
}

.search-form button {
    padding: 10px 24px;
    background: #ff8c00;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}

.search-form button:hover {
    background: #e67e00;
}

.search-clear {
    color: white;
    font-size: 0.8rem;
    opacity: 0.8;
    text-decoration: none;
    padding: 10px 12px;
}

.search-clear:hover {
    opacity: 1;
}

.search-sql {
    max-width: 1200px;
    margin: 8px auto 0;
    padding: 0 20px;
}

.search-sql .sql-hint {
    font-size: 0.7rem;
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
}

.search-sql .sql-hint strong {
    color: #ff8c00;
}

.search-sql .sql-hint-nojoins {
    background: rgba(231,76,60,0.2);
    border-color: rgba(231,76,60,0.3);
    color: rgba(255,255,255,0.7);
}

.search-sql .sql-hint-nojoins strong {
    color: #ef9a9a;
}

.search-results {
    margin-bottom: 20px;
}

/* ========== GRAD GRID ========== */
.grad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1px;
    background: #eee;
}

.grad-card {
    background: white;
    padding: 16px;
}

.grad-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.grad-header .material-icons {
    font-size: 28px;
    color: #004080;
}

.grad-naziv {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
}

.grad-zupanija {
    font-size: 0.72rem;
    color: #999;
}

.grad-stats {
    display: flex;
    gap: 16px;
}

.grad-stat {
    text-align: center;
}

.grad-stat-broj {
    font-size: 1.1rem;
    font-weight: 800;
    color: #004080;
}

.grad-stat-label {
    font-size: 0.65rem;
    color: #999;
    text-transform: uppercase;
}

/* ========== DATA TABLES (HAVING, SUBQUERY) ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table thead {
    background: #f5f7fa;
}

.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: #004080;
    border-bottom: 2px solid #e0e0e0;
    font-size: 0.8rem;
}

.data-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #f0f0f0;
}

.data-table tbody tr:hover {
    background: #f8fafe;
}

.data-table .centered {
    text-align: center;
}

.cijena-cell {
    font-weight: 700;
    color: #004080;
    text-align: right;
    white-space: nowrap;
}

.having-info {
    padding: 10px 18px;
    font-size: 0.8rem;
    color: #666;
    background: #f8fafe;
    border-bottom: 1px solid #eee;
}

.having-info strong {
    color: #004080;
}

/* ========== ER DIAGRAM ========== */
.er-diagram {
    position: relative;
    padding: 16px;
    min-height: 340px;
}

.er-table {
    background: white;
    border: 2px solid #004080;
    border-radius: 6px;
    font-size: 0.7rem;
    position: absolute;
    width: 120px;
    overflow: hidden;
    z-index: 2;
}

.er-name {
    background: #004080;
    color: white;
    font-weight: 700;
    padding: 4px 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.72rem;
}

.er-col {
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.62rem;
    color: #555;
}

.er-col:last-child {
    border-bottom: none;
}

.er-col .pk {
    color: #ff8c00;
    font-weight: 700;
}

.er-col .fk {
    color: #e74c3c;
    font-weight: 700;
}

.er-kategorije {
    top: 10px;
    left: 10px;
}

.er-gradovi {
    top: 10px;
    right: 10px;
}

.er-korisnici {
    top: 130px;
    left: 50%;
    transform: translateX(-50%);
}

.er-oglasi {
    top: 240px;
    left: 50%;
    transform: translateX(-50%);
}

.er-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ========== REFRESH BAR ========== */
.refresh-bar {
    text-align: center;
    padding: 12px;
    color: #aaa;
    font-size: 0.75rem;
}

/* ========== FOOTER ========== */
footer {
    text-align: center;
    padding: 20px;
    color: #bbb;
    font-size: 0.75rem;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .cat-nav-inner {
        overflow-x: auto;
    }

    .oglas-slika {
        width: 100px;
    }

    .oglas-cijena-box {
        width: 110px;
        padding: 10px;
    }

    .oglas-cijena {
        font-size: 1rem;
    }
}

@media (max-width: 600px) {
    .oglas-kartica {
        flex-wrap: wrap;
    }

    .oglas-slika {
        width: 80px;
        min-height: 80px;
    }

    .oglas-cijena-box {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        padding: 8px 16px;
        border-top: 1px solid #f0f0f0;
    }

    .header-inner {
        flex-direction: column;
        gap: 4px;
    }
}
