/* ==========================================================================
   1. VARIJABLE I SVIJETLA/TAMNA TEMA
   ========================================================================== */
:root {
    --primary-color: #3b82f6;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    --topbar-bg: #ffffff;
}

body.dark-theme {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f8fafc;
    --border-color: #334155;
    --sidebar-bg: #020617;
    --sidebar-hover: #0f172a;
    --topbar-bg: #1e293b;
}

/* ==========================================================================
   2. OSNOVNI RESTART ISTRANICE
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* ==========================================================================
   3. FIKSNA GORNJA TRAKA (TOP NAVBAR)
   ========================================================================== */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: var(--topbar-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
}

.left-section, .right-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
}

.toggle-nav-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-color);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
}

.toggle-nav-btn:hover {
    background-color: var(--border-color);
}

.user-badge {
    font-size: 0.85rem;
    background-color: var(--border-color);
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: 600;
}

.theme-toggle-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

/* ==========================================================================
   4. LAYOUT STRANICE SA SIDEBAR-OM
   ========================================================================== */
.dashboard-layout {
    display: flex;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
}

/* Fiksni i zalijepljeni Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    transition: all 0.3s ease;
    z-index: 999;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.sidebar.collapsed {
    left: -260px;
}

.sidebar-menu {
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sidebar-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin: 15px 0 5px 10px;
    font-weight: 700;
}

.sidebar-link {
    display: block;
    padding: 10px 15px;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
}

.sidebar-divider {
    border: 0;
    border-top: 1px solid #334155;
    margin: 15px 0;
}

.logout-link:hover {
    background-color: #ef4444;
    color: white;
}

/* Glavni sadržaj desno */
.main-content-area {
    flex: 1;
    margin-left: 260px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar.collapsed + .main-content-area {
    margin-left: 0;
}

.page-inner-container {
    padding: 30px;
}

.main-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: gray;
    text-align: center;
}

/* ==========================================================================
   5. KARTICE, FORME I DUGMAD
   ========================================================================== */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 25px;
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.form-group {
    margin-bottom: 15px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 0.95rem;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    transition: opacity 0.2s;
}

.btn-submit:hover {
    opacity: 0.9;
}

/* ==========================================================================
   6. TABELE I PODACI
   ========================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.data-table th, .data-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: rgba(0,0,0,0.02);
    font-weight: 600;
}

body.dark-theme .data-table th {
    background-color: rgba(255,255,255,0.02);
}

/* Akciona dugmad u tabelama */
.action-btn {
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: bold;
    margin-right: 5px;
    display: inline-block;
    cursor: pointer;
    border: none;
}

.edit-btn { background-color: #ffc107; color: #212529; }
.delete-btn { background-color: #dc3545; color: white; }

/* Bedževi za uloge i statuse */
.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.role-admin { background-color: #d4edda; color: #155724; }
.role-reseller { background-color: #cce5ff; color: #004085; }
.role-user { background-color: #e2e3e5; color: #383d41; }

/* Obavještenja (Alerts) */
.alert {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}
.alert-danger { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }

/* ==========================================================================
   7. DRAG AND DROP STILOVU (SORTIRANJE)
   ========================================================================== */
.sortable-list {
    list-style: none;
    margin-top: 15px;
}

.sortable-item {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 15px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.sortable-item:active {
    cursor: grabbing;
}

/* ==========================================================================
   8. SPECIFIČNO ZA LOGIN STRANICU (KADA NEMA MENIJA)
   ========================================================================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

/* ==========================================================================
   9. ODZIVNOST (RESPONSIVE)
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar {
        left: -260px;
    }
    .sidebar.collapsed {
        left: 0;
    }
    .main-content-area {
        margin-left: 0 !important;
    }
    .page-inner-container {
        padding: 15px;
    }
}
