/* ============================================
   MODERN KNJIGOVODSTVENI SISTEM - CSS
   Profesionalni izgled za finansijske aplikacije
   ============================================ */

/* ----- ROOT VARIJABLE (tema) ----- */
:root {
    --primary: #1a56db;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    
    --bg-body: #f1f5f9;
    --bg-white: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-white: #f8fafc;
    
    --border-color: #e2e8f0;
    --border-radius: 8px;
    --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);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ----- RESET & BASE ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ----- TOPBAR / HEADER ----- */
.topbar {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.topbar-brand .muted {
    color: var(--text-muted);
    font-weight: 400;
}

.topbar-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.topbar-nav a {
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.topbar-nav a:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.topbar-nav a.active {
    background: var(--primary);
    color: white;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.topbar-user span {
    font-weight: 500;
    color: var(--text-primary);
}

.topbar-user a {
    color: var(--danger);
    text-decoration: none;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.topbar-user a:hover {
    background: #fee2e2;
}

/* ----- CONTAINER ----- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    flex: 1;
    width: 100%;
}

/* ----- CARDS GRID (Dashboard) ----- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
    display: block;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.card-broj {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.card-naziv {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ----- HEADINGS ----- */
h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

h1::after {
    content: '';
    flex: 1;
    height: 2px;
    background: linear-gradient(to right, var(--border-color), transparent);
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

/* ----- FIELDSETS / BLOKOVI ----- */
.blok {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.blok:hover {
    box-shadow: var(--shadow);
}

.blok legend {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    padding: 0 0.75rem;
    border: none;
    background: var(--bg-white);
    border-radius: var(--border-radius);
}

/* ----- GRID LAYOUTS ----- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.25rem;
}

.grid-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1.25rem;
}

/* ----- FORM ELEMENTS ----- */
label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-white);
    transition: var(--transition);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input[type="file"] {
    padding: 0.4rem;
    border: 1.5px dashed var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-body);
    width: 100%;
}

input[type="file"]:hover {
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

select {
    appearance: auto;
    cursor: pointer;
}

/* ----- BUTTONS ----- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    font-family: var(--font);
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-sec {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
}

.btn-sec:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.875rem;
    transition: var(--transition);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.btn-success:hover {
    background: #047857;
}

/* ----- TABLES ----- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

table thead th {
    background: var(--bg-body);
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table tbody td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table tbody tr:hover {
    background: var(--primary-light);
}

table tbody td input,
table tbody td select,
table tbody td textarea {
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    transition: var(--transition);
    width: 100%;
}

table tbody td input:focus,
table tbody td select:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

table tbody td .poljeUkupno {
    font-weight: 600;
    color: var(--primary);
    text-align: right;
    padding-right: 0.75rem;
}

/* ----- ALERTS ----- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border-left: 4px solid;
}

.alert-error {
    background: #fef2f2;
    border-color: var(--danger);
    color: #991b1b;
}

.alert-success {
    background: #ecfdf5;
    border-color: var(--success);
    color: #065f46;
}

.alert-warning {
    background: #fffbeb;
    border-color: var(--warning);
    color: #92400e;
}

/* ----- MODAL ----- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    max-width: 500px;
    width: 92%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal-card h3 {
    margin-top: 0;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 0.75rem;
}

.modal-card label {
    margin-top: 0.75rem;
}

.modal-card input {
    width: 100%;
}

/* ----- AUTOCOMPLETE ----- */
.autocomplete-lista {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 1.5px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    display: none;
}

.autocomplete-stavka {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.autocomplete-stavka:hover {
    background: var(--primary-light);
}

.autocomplete-stavka .muted {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.oznaka-artikla {
    font-size: 0.7rem;
    color: var(--success);
    margin-top: 2px;
}

/* ----- QUICK ACTIONS ----- */
.quick-actions {
    display: flex;
    gap: 0.75rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}

/* ----- MISC ----- */
.muted {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-2 {
    margin-top: 1.5rem;
}

.mb-2 {
    margin-bottom: 1.5rem;
}

.gap-2 {
    gap: 0.75rem;
}

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ----- ANIMATIONS ----- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* ----- RESPONSIVE ----- */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .topbar {
        padding: 0 1rem;
        height: auto;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .topbar-nav {
        flex-wrap: wrap;
        width: 100%;
        order: 3;
    }
    
    .topbar-nav a {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .topbar-user {
        margin-left: auto;
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .cards-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .modal-card {
        padding: 1.25rem;
        width: 95%;
        margin: 1rem;
    }
}

@media (max-width: 480px) {
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar-brand {
        font-size: 1rem;
    }
    
    h1 {
        font-size: 1.25rem;
    }
}