/* ========== LAYOUT ========== */
body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
}

.archive-container {
    display: flex;
    height: 100vh;
}

/* ========== SIDEBAR (isti stil kao index.html) ========== */
.archive-sidebar {
    width: 280px;
    background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.sidebar-header {
    padding: 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.5em;
    font-weight: 600;
}

/* Navigation items */
.sidebar-nav {
    padding: 20px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: rgba(52, 152, 219, 0.3);
    color: white;
    border-left: 4px solid #3498db;
}

.nav-item .icon {
    margin-right: 12px;
    font-size: 1.2em;
}

/* Sidebar sections */
.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-section h3 {
    margin: 0 0 15px 0;
    font-size: 0.9em;
    font-weight: 600;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-btn {
    width: 100%;
    padding: 12px 15px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sidebar-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
    transform: translateX(5px);
}

.sidebar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sidebar-btn .btn-icon {
    font-size: 1.2em;
}

.sidebar-btn .btn-text {
    flex: 1;
    text-align: left;
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* ========== MAIN CONTENT ========== */
.archive-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px; /* Smanjio padding za više prostora */
    height: 100vh;
}

.archive-header {
    flex-shrink: 0; /* 🔴 DODANO: Header ne smije shrink-ovati */
    position: relative; /* 🔴 PROMJENA: umjesto sticky */
    background: #f5f5f5;
    z-index: 100;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-top h1 {
    margin: 0;
    color: #2c3e50;
}

.btn-close-archive {
    width: 40px;
    height: 40px;
    border: none;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-close-archive:hover {
    background: #c0392b;
    transform: rotate(90deg);
}

/* Stats cards */
.header-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    flex: 1;
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 13px;
    color: #7f8c8d;
}

.stat-value {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 15px;
    font-size: 16px;
    color: #7f8c8d;
}

#archiveSearch {
    width: 100%;
    padding: 12px 45px 12px 45px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

#archiveSearch:focus {
    outline: none;
    border-color: #3498db;
}

.btn-clear-search {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    font-size: 18px;
    padding: 5px;
}

/* Filter chips */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-chip:hover {
    border-color: #3498db;
    color: #3498db;
}

.filter-chip.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* ========== TABLE ========== */
.archive-table-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-height: 0; /* KLJUČNO za flex scroll! */
}

.archive-table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow-y: scroll; /* Uvijek prikaži scrollbar */
    height: 100%; /* Zauzmi sav prostor */
}

/* Customiziran scrollbar za tabelu */
.archive-table::-webkit-scrollbar {
    width: 8px;
}

.archive-table::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.archive-table::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.archive-table::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.archive-table thead,
.archive-table tbody {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.archive-table thead {
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.archive-table thead th {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 10;
}

.archive-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.archive-table th:hover {
    background: rgba(255,255,255,0.1);
}

.archive-table tbody tr {
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
    cursor: pointer;
}

.archive-table tbody tr:hover {
    background: #f8f9fa;
}

.archive-table tbody tr.selected {
    background: #e3f2fd;
}

.archive-table td {
    padding: 15px;
    font-size: 14px;
}

/* ========== GOODS TOOLTIP ========== */
.goods-tooltip {
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    padding: 0;
    min-width: 350px;
    max-width: 500px;
    z-index: 9999;
    animation: tooltipFadeIn 0.2s ease;
    border: 2px solid #667eea;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tooltip-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 10px 10px 0 0;
    font-weight: 600;
    font-size: 14px;
}

.tooltip-content {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.tooltip-item {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.tooltip-item:last-child {
    border-bottom: none;
}

.item-title {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    font-size: 14px;
}

.item-tariff {
    color: #7f8c8d;
    font-size: 13px;
}

/* Scrollbar styling */
.tooltip-content::-webkit-scrollbar {
    width: 6px;
}

.tooltip-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.tooltip-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

.btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn.ghost {
    background: transparent;
    border: 2px solid #ddd;
    color: #f0e9e9;
}

.btn.ghost:hover {
    border-color: #667eea;
    color: #667eea;
}

.btn.full-width {
    width: 100%;
}

/* ========== PROGRESS BAR ========== */
.progress-bar-container {
    padding: 20px;
    border-top: 1px solid #eee;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
    color: #7f8c8d;
}

.progress-bar {
    height: 8px;
    background: #ecf0f1;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #7f8c8d;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
}

/* ========== LOADING ========== */
.loading-spinner {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ecf0f1;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== PRINT MODAL ========== */
.print-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.print-option-card {
    background: white;
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}

.print-option-card:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2);
}

.print-option-card .print-icon {
    font-size: 48px;
}

.print-option-card .print-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.print-option-card strong {
    font-size: 16px;
    color: #2c3e50;
}

.print-option-card small {
    font-size: 13px;
    color: #7f8c8d;
}

/* ========== MODAL ANIMATIONS ========== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.slide-in-right {
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 25px 30px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #2c3e50;
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #7f8c8d;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.3s;
}

.btn-close:hover {
    background: #e74c3c;
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.filter-count {
  background: rgba(255, 255, 255, 0.3);
}

/* Vrlo suptilan 3D flip */
.stat-value {
  display: inline-block;
  transform-style: preserve-3d;
  perspective: 1000px;
}

.stat-value.updating {
  animation: subtleFlip 0.5s ease;
}

@keyframes subtleFlip {
  0% {
    transform: rotateX(0deg);
  }
  30% {
    transform: rotateX(-20deg);
    color: #007bff;
  }
  60% {
    transform: rotateX(20deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

.stat-label {
  transition: all 0.3s ease;
}

/* ========== GOODS TOOLTIP ========== */
.goods-tooltip {
    position: absolute;
    background: white;
    border: 2px solid #003399;
    border-radius: 8px;
    padding: 0;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    pointer-events: none;
}

.tooltip-header {
    background: #003399;
    color: white;
    padding: 10px 15px;
    border-radius: 6px 6px 0 0;
    font-size: 14px;
}

.tooltip-body {
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.tooltip-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.tooltip-item:last-child {
    border-bottom: none;
}

.item-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.item-tariff {
    font-size: 12px;
    color: #666;
}

/* ========== CONTEXT MENU ========== */
.context-menu {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    z-index: 10000;
    padding: 8px 0;
}

.context-menu-header {
    padding: 12px 16px;
    font-weight: 700;
    color: #003399;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: #f5f5f5;
}

.context-menu-item.danger:hover {
    background: #fee;
    color: #d32f2f;
}

.context-menu-icon {
    font-size: 16px;
}

.context-menu-divider {
    height: 1px;
    background: #eee;
    margin: 4px 0;
}

/* ========== TABLE ACTION BUTTON ========== */
.btn-table-action {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    transition: transform 0.2s;
}

.btn-table-action:hover {
    transform: scale(1.2);
}