/* =============================================================================
   ZOP APP - Glavni CSS
   ============================================================================= */

/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:       #c0392b;
    --primary-dark:  #96281b;
    --primary-light: #e74c3c;
    --secondary:     #2c3e50;
    --success:       #27ae60;
    --warning:       #f39c12;
    --danger:        #c0392b;
    --info:          #2980b9;
    --light:         #f5f6fa;
    --gray:          #7f8c8d;
    --gray-light:    #ecf0f1;
    --white:         #ffffff;
    --border:        #dce1e7;
    --text:          #2c3e50;
    --text-muted:    #7f8c8d;
    --shadow:        0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover:  0 4px 16px rgba(0,0,0,0.12);
    --radius:        6px;
    --radius-lg:     10px;
    --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); color: var(--text); background: var(--light); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ---- Navbar ---- */
.navbar {
    background: var(--secondary);
    padding: 0 24px;
    height: 58px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.navbar-brand a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--white);
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
}
.brand-icon { font-size: 1.4rem; }

.navbar-menu { display: flex; gap: 4px; flex: 1; }
.nav-link {
    color: rgba(255,255,255,0.75);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.92rem;
    transition: all 0.15s;
    text-decoration: none;
}
.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.12);
    color: var(--white);
    text-decoration: none;
}

.navbar-right { margin-left: auto; }

.user-menu { position: relative; }
.user-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    transition: background 0.15s;
}
.user-btn:hover { background: rgba(255,255,255,0.18); }
.user-avatar {
    width: 26px; height: 26px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
}
.chevron { font-size: 0.75rem; opacity: 0.7; }

.user-dropdown {
    display: none;
    position: absolute;
    right: 0; top: calc(100% + 8px);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    min-width: 220px;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 200;
}
.user-dropdown.open { display: block; }
.dropdown-tenant {
    padding: 10px 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--text);
    font-size: 0.9rem;
    transition: background 0.1s;
    text-decoration: none;
}
.dropdown-item:hover { background: var(--light); text-decoration: none; }
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover { background: #fdf2f2; }

/* ---- Main Content ---- */
.main-content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin: 16px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.92rem;
    font-weight: 500;
}
.alert-success { background: #eafaf1; border: 1px solid #a9dfbf; color: #1e8449; }
.alert-danger  { background: #fdf2f2; border: 1px solid #f5b7b1; color: #922b21; }
.alert-warning { background: #fef9e7; border: 1px solid #f9e79f; color: #9a7d0a; }
.alert-close   { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: inherit; opacity: 0.6; padding: 0 4px; line-height: 1; }
.alert-close:hover { opacity: 1; }

/* ---- Page header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--secondary); }
.page-subtitle { font-size: 0.9rem; color: var(--text-muted); margin-top: 2px; }

/* ---- Cards ---- */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: visible;
}
.card > .card-body,
.card > .table-container,
.card > table {
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--secondary); }
.card-body  { padding: 20px; }

/* ---- Stats Cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.stat-icon.red    { background: #fde8e8; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.orange { background: #ffedd5; }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font);
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-lg { padding: 11px 24px; font-size: 1rem; }

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

.btn-secondary { background: var(--secondary); color: var(--white); border-color: var(--secondary); }
.btn-secondary:hover { background: #1a252f; }

.btn-success   { background: var(--success); color: var(--white); border-color: var(--success); }
.btn-success:hover { background: #1e8449; }

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

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

.btn-light     { background: var(--light); color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--gray-light); }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-row   { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-row-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }

label { display: block; margin-bottom: 5px; font-size: 0.88rem; font-weight: 600; color: var(--text); }
label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    font-family: var(--font);
    color: var(--text);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192,57,43,0.12);
}
.form-control:disabled { background: var(--light); color: var(--gray); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.82rem; color: var(--danger); margin-top: 4px; }
.form-control.is-invalid { border-color: var(--danger); }

/* Checkbox i Radio */
.check-group { display: flex; align-items: center; gap: 8px; }
.check-group input[type="checkbox"],
.check-group input[type="radio"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.check-group label { margin: 0; font-weight: 400; cursor: pointer; }

/* Inline checkboxovi za Zadovoljava */
.check-zadovoljava { display: flex; align-items: center; gap: 6px; }
.check-zadovoljava input { accent-color: var(--success); }

/* ---- Tablice ---- */
.table-container { overflow-x: auto; }
table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table th {
    background: var(--light);
    padding: 10px 14px;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }

.table-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-success { background: #eafaf1; color: #1e8449; }
.badge-danger  { background: #fdf2f2; color: #922b21; }
.badge-warning { background: #fef9e7; color: #9a7d0a; }
.badge-info    { background: #dbeafe; color: #1a56a0; }
.badge-secondary { background: var(--gray-light); color: var(--gray); }

/* ---- Type badges za tipove zapisnika ---- */
.type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.type-HMU   { background: #dbeafe; color: #1d4ed8; }
.type-HMV   { background: #e0f2fe; color: #0369a1; }
.type-ODIM  { background: #fef3c7; color: #92400e; }
.type-PPV   { background: #ede9fe; color: #5b21b6; }
.type-PPZ   { background: #fce7f3; color: #831843; }
.type-PPZAV { background: #d1fae5; color: #065f46; }
.type-VDO   { background: #fee2e2; color: #991b1b; }
.type-EST   { background: #ccfbf1; color: #0f766e; }
.type-PANIK { background: #ffedd5; color: #c2410c; }
.type-TP    { background: #ede9fe; color: #5b21b6; }
.type-PD    { background: #e0e7ff; color: #3730a3; }
.type-SPR   { background: #cffafe; color: #0e7490; }

/* ---- Grid layouts ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ---- Login page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--secondary) 0%, #1a252f 100%);
    padding: 20px;
}
.login-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo .brand-icon { font-size: 3rem; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 1.6rem; color: var(--secondary); font-weight: 800; }
.login-logo p { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.login-box .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; margin-top: 4px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 0.85rem; color: var(--text-muted); }

/* ---- Dashboard ---- */
.welcome-banner {
    background: linear-gradient(135deg, var(--secondary) 0%, #34495e 100%);
    color: var(--white);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.welcome-banner::after {
    content: '🔥';
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 4rem;
    opacity: 0.15;
}
.welcome-banner h2 { font-size: 1.4rem; font-weight: 700; }
.welcome-banner p  { font-size: 0.9rem; opacity: 0.75; margin-top: 6px; }

/* ---- Inspection form specifics ---- */
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary);
    padding: 12px 0 10px;
    border-bottom: 2px solid var(--primary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-number {
    background: var(--primary);
    color: var(--white);
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.dynamic-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.dynamic-table th { background: var(--light); padding: 8px 10px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-align: left; border: 1px solid var(--border); }
.dynamic-table td { padding: 6px 8px; border: 1px solid var(--border); vertical-align: middle; }
.dynamic-table td input, .dynamic-table td select { border: none; background: transparent; width: 100%; padding: 4px 2px; font-size: 0.88rem; }
.dynamic-table td input:focus, .dynamic-table td select:focus { outline: 1px solid var(--primary); border-radius: 2px; }
.dynamic-table .col-actions { width: 40px; text-align: center; }
.btn-remove-row { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1.1rem; padding: 2px 6px; border-radius: 3px; }
.btn-remove-row:hover { background: #fdf2f2; }

.voice-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.15s;
    margin-left: 6px;
}
.voice-btn:hover { border-color: var(--primary); color: var(--primary); }
.voice-btn.recording { border-color: var(--danger); color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Zaključak checkboxovi */
.conclusion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}
.conclusion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--light);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    gap: 12px;
}
.conclusion-label { font-size: 0.88rem; font-weight: 500; }
.conclusion-select { padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.88rem; background: var(--white); cursor: pointer; color: var(--text); min-width: 160px; }
.conclusion-select option[value="ZADOVOLJAVA"]   { color: var(--success); }
.conclusion-select option[value="NE ZADOVOLJAVA"] { color: var(--danger); }

/* ---- Pagination ---- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
    flex-wrap: wrap;
}
.page-link {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.88rem;
    background: var(--white);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.1s;
}
.page-link:hover { background: var(--light); text-decoration: none; }
.page-link.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.page-link.disabled { opacity: 0.4; pointer-events: none; }

/* ---- Search/Filter bar ---- */
.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }

/* ---- Footer ---- */
.footer {
    background: var(--secondary);
    color: rgba(255,255,255,0.5);
    padding: 14px 24px;
    font-size: 0.8rem;
    text-align: center;
    margin-top: auto;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; display: block; opacity: 0.4; }
.empty-state h3   { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.empty-state p    { font-size: 0.88rem; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .main-content { padding: 16px; }
    .navbar { padding: 0 16px; }
    .navbar-menu { display: none; }
    .grid-2, .grid-3, .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-box { padding: 28px 20px; }
}
