/**
 * Digitalni Cjenik HR - Frontend Styles
 * Author: Nexus Logic
 * Clean, Accessible (WCAG 2.1 AA), Fully Responsive
 */

:root,
.dc-frontend-wrap {
    --dc-primary: #0f172a;
    --dc-primary-hover: #1e293b;
    --dc-accent: #0284c7;
    --dc-accent-light: rgba(2, 132, 199, 0.12);
    --dc-sale: #b91c1c;
    --dc-sale-bg: #fef2f2;
    --dc-sale-border: #fecaca;
    --dc-warning: #b45309;
    --dc-text: #1e293b;
    --dc-text-muted: #64748b;
    --dc-text-subtle: #94a3b8;
    --dc-bg-card: #ffffff;
    --dc-bg-alt: #f8fafc;
    --dc-border: #e2e8f0;
    --dc-border-subtle: #f1f5f9;
    --dc-border-focus: #cbd5e1;
    --dc-radius: 12px;
    --dc-radius-sm: 8px;
    --dc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.dc-frontend-wrap {
    width: 100%;
    margin: 30px auto;
    font-family: var(--dc-font);
    color: var(--dc-text);
    line-height: 1.6;
    box-sizing: border-box;
}

.dc-frontend-wrap *,
.dc-frontend-wrap *::before,
.dc-frontend-wrap *::after {
    box-sizing: border-box;
}

/* Accessibility: Screen Reader Only */
.dc-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border-width: 0 !important;
}

/* Header / Poslovni subjekt */
.dc-frontend-header {
    border-bottom: 2px solid var(--dc-border);
    padding-bottom: 20px;
    margin-bottom: 24px;
}

.dc-company-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--dc-primary);
    line-height: 1.3;
}

.dc-object-category {
    font-size: 15px;
    font-weight: 600;
    color: var(--dc-accent);
    margin: -2px 0 6px 0;
}

.dc-company-meta {
    font-size: 14px;
    color: var(--dc-text-muted);
    margin: 0;
}

/* Controls: Search and Category Tabs */
.dc-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.dc-search-box {
    position: relative;
    flex: 1;
    min-width: 240px;
    max-width: 400px;
}

.dc-search-input {
    width: 100%;
    padding: 11px 40px 11px 16px;
    border: 1px solid var(--dc-border-focus);
    border-radius: var(--dc-radius-sm);
    font-size: 16px; /* 16px prevents iOS Safari from auto-zooming on focus */
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--dc-bg-card);
    color: var(--dc-text);
}

.dc-search-input:focus {
    border-color: var(--dc-accent);
    box-shadow: 0 0 0 3px var(--dc-accent-light);
}

/* Clear Search Button (X) */
.dc-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: var(--dc-border);
    color: var(--dc-text-muted);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s ease;
}

.dc-search-clear:hover {
    background: var(--dc-border-focus);
    color: var(--dc-primary);
}

.dc-search-clear:focus-visible {
    outline: 2px solid var(--dc-accent);
    outline-offset: 2px;
}

/* Category Tabs Wrapper & Tabs (Buttons for full keyboard & screen reader accessibility) */
.dc-tabs-wrapper {
    position: relative;
    max-width: 100%;
    min-width: 0;
}

.dc-category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dc-cat-tab {
    appearance: none;
    -webkit-appearance: none;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid var(--dc-border);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    line-height: 1.4;
}

.dc-cat-tab:hover {
    background: #e2e8f0;
    color: var(--dc-primary);
}

.dc-cat-tab:focus-visible {
    outline: 2px solid var(--dc-accent);
    outline-offset: 2px;
}

.dc-cat-tab.active {
    background: var(--dc-primary);
    color: #ffffff;
    border-color: var(--dc-primary);
}

/* Minimalist Table */
.dc-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--dc-border);
    border-radius: var(--dc-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    background: var(--dc-bg-card);
    margin-bottom: 24px;
}

.dc-public-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.dc-public-table th {
    background: var(--dc-bg-alt);
    color: #475569;
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid var(--dc-border);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.dc-public-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--dc-border-subtle);
    vertical-align: middle;
}

.dc-public-table tr:last-child td {
    border-bottom: none;
}

.dc-public-table tr:hover td {
    background: #fafbfc;
}

.dc-item-title {
    font-weight: 600;
    color: var(--dc-primary);
    display: block;
    margin-bottom: 2px;
}

.dc-item-desc {
    font-size: 12px;
    color: var(--dc-text-muted);
    line-height: 1.4;
    display: block;
}

.dc-cell-unit {
    color: var(--dc-text-muted);
}

.dc-cell-price-current {
    font-size: 15px;
    font-weight: 700;
    color: var(--dc-primary);
    white-space: nowrap;
}

.dc-cell-price-current.dc-is-sale {
    color: var(--dc-sale);
}

.dc-price-strikethrough {
    font-size: 11px;
    text-decoration: line-through;
    color: var(--dc-text-subtle);
    margin-top: 2px;
}

.dc-cell-price-anchor {
    font-size: 13px;
    color: var(--dc-text-muted);
    white-space: nowrap;
}

.dc-public-table th.dc-th-price,
.dc-public-table td.dc-col-price,
.dc-public-table th.dc-th-anchor,
.dc-public-table td.dc-col-anchor {
    text-align: right;
}

.dc-anchor-badge {
    display: inline-block;
    background: #f1f5f9;
    color: #475569;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 3px;
}

.dc-sale-badge {
    background: var(--dc-sale-bg);
    color: var(--dc-sale);
    border: 1px solid var(--dc-sale-border);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 4px;
}

.dc-30d-price {
    font-size: 11px;
    color: var(--dc-warning);
    display: block;
    margin-top: 3px;
    font-weight: 500;
}

/* Category header row */
.dc-cat-header-row th.dc-cat-header-cell {
    background: var(--dc-bg-alt);
    font-weight: 700;
    color: #1e3a8a;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 18px;
    border-top: 1px solid var(--dc-border);
    border-bottom: 1px solid var(--dc-border);
    text-align: left;
}

/* Empty State row */
.dc-search-empty-row {
    display: none;
}

.dc-search-empty-row.is-active {
    display: table-row;
}

.dc-search-empty-cell {
    text-align: center;
    padding: 36px 20px !important;
    color: var(--dc-text-muted);
    font-size: 14px;
}

.dc-empty-icon {
    display: block;
    font-size: 26px;
    margin-bottom: 8px;
}

.dc-empty-query-text {
    font-weight: 500;
    color: #475569;
}

/* Notice when table is hidden */
.dc-table-hidden-notice {
    background: var(--dc-bg-alt);
    border: 1px solid var(--dc-border);
    border-radius: var(--dc-radius-sm);
    padding: 18px 20px;
    margin: 20px 0;
    color: var(--dc-text);
    line-height: 1.6;
}

/* Special notes box (Posebne napomene / Uvjeti) */
.dc-special-notes-box {
    background: var(--dc-bg-alt);
    border: 1px solid var(--dc-border);
    border-radius: 10px;
    padding: 18px 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.dc-special-notes-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--dc-primary);
    font-size: 14px;
    font-weight: 700;
}

.dc-special-notes-icon {
    font-size: 16px;
    line-height: 1;
}

.dc-special-notes-content {
    font-size: 13px;
    line-height: 1.6;
    color: #334155;
}

.dc-special-notes-content p {
    margin: 0 0 8px 0;
}

.dc-special-notes-content p:last-child {
    margin-bottom: 0;
}

.dc-special-notes-content ul,
.dc-special-notes-content ol {
    margin: 6px 0 8px 20px;
    padding: 0;
}

.dc-special-notes-content li {
    margin-bottom: 4px;
}

.dc-legal-tax-note {
    line-height: 1.6;
}

.dc-tax-note-content {
    display: inline;
}

.dc-tax-note-content p {
    display: inline;
    margin: 0;
}

.dc-tax-note-content p + p {
    display: block;
    margin-top: 4px;
}

/* Footer note & downloads */
.dc-footer-meta {
    background: var(--dc-bg-alt);
    border: 1px solid var(--dc-border);
    border-radius: 10px;
    padding: 18px 24px;
    font-size: 13px;
    color: #475569;
    line-height: 1.6;
}

.dc-footer-downloads {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--dc-border);
}

.dc-download-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    color: #334155;
    text-decoration: none !important;
    font-family: inherit;
    font-weight: 500;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    box-sizing: border-box;
    transition: all 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.dc-download-link:hover {
    background: var(--dc-primary);
    color: #ffffff !important;
    border-color: var(--dc-primary);
}

.dc-download-link:hover .dc-icon {
    stroke: #ffffff;
}

.dc-download-link:focus-visible {
    outline: 2px solid var(--dc-accent);
    outline-offset: 2px;
}

/* Vector SVG icons inside buttons & headers */
.dc-icon {
    display: inline-block;
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    min-height: 15px !important;
    max-width: 15px !important;
    max-height: 15px !important;
    flex-shrink: 0 !important;
    vertical-align: middle;
    transition: stroke 0.2s ease;
}

/* Bulletproof Twemoji & Theme Image Isolation:
   Prevents theme CSS or WordPress Twemoji from blowing up emojis to 100px */
.dc-frontend-wrap img.emoji,
.dc-frontend-wrap img.wp-smiley,
.dc-download-link img,
.dc-download-link img.emoji,
.dc-special-notes-header img.emoji,
.dc-footer-downloads img {
    display: inline-block !important;
    width: 1.1em !important;
    height: 1.1em !important;
    max-width: 16px !important;
    max-height: 16px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 4px 0 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    vertical-align: -0.15em !important;
    flex-shrink: 0 !important;
    object-fit: contain !important;
}

/* Responsive: Tablet & Mobile controls */
@media (max-width: 768px) {
    .dc-public-table th, 
    .dc-public-table td {
        padding: 10px 12px;
        font-size: 13px;
    }
    .dc-controls {
        flex-direction: column;
        align-items: stretch;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
    .dc-search-box {
        max-width: 100%;
        width: 100%;
    }

    /* Scrollable category tabs with edge fade mask */
    .dc-tabs-wrapper {
        position: relative;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    .dc-category-tabs {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior-x: contain;
        padding: 4px 6px 8px 6px !important;
        margin: 0 !important;
        scrollbar-width: none !important; /* Firefox */
        gap: 8px;
    }

    .dc-category-tabs::-webkit-scrollbar {
        display: none !important; /* Chrome, Safari, Edge */
    }

    .dc-cat-tab {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
    }

    /* Edge Fade Indicators */
    .dc-tabs-wrapper.can-scroll-right {
        -webkit-mask-image: linear-gradient(to right, black calc(100% - 36px), transparent 100%);
        mask-image: linear-gradient(to right, black calc(100% - 36px), transparent 100%);
    }

    .dc-tabs-wrapper.can-scroll-left {
        -webkit-mask-image: linear-gradient(to left, black calc(100% - 36px), transparent 100%);
        mask-image: linear-gradient(to left, black calc(100% - 36px), transparent 100%);
    }

    .dc-tabs-wrapper.can-scroll-left.can-scroll-right {
        -webkit-mask-image: linear-gradient(to right, transparent 0%, black 36px, black calc(100% - 36px), transparent 100%);
        mask-image: linear-gradient(to right, transparent 0%, black 36px, black calc(100% - 36px), transparent 100%);
    }
}

/* Responsive: Mobile Card Layout (No horizontal scroll needed!) */
@media (max-width: 640px) {

    /* Transform table into clean modern cards */
    .dc-table-wrap {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
    }

    .dc-public-table thead {
        display: none; /* Tabular header replaced by card labels */
    }

    .dc-public-table, 
    .dc-public-table tbody {
        display: block;
        width: 100%;
    }

    .dc-cat-header-row {
        display: block;
        margin: 20px 0 10px 0;
    }

    .dc-cat-header-cell {
        display: block;
        width: 100%;
        border-radius: var(--dc-radius-sm);
        font-size: 13px;
        padding: 10px 14px !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
    }

    .dc-item-row {
        display: flex;
        flex-direction: column;
        background: var(--dc-bg-card);
        border: 1px solid var(--dc-border);
        border-radius: var(--dc-radius);
        padding: 14px 16px;
        margin-bottom: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    }

    .dc-item-row td {
        display: block;
        padding: 0 !important;
        border: none !important;
        width: 100% !important;
    }

    .dc-col-title {
        margin-bottom: 8px;
    }

    .dc-item-title {
        font-size: 15px;
        font-weight: 600;
        color: var(--dc-primary);
    }

    .dc-item-desc {
        font-size: 13px;
        margin-top: 4px;
    }

    .dc-col-unit {
        display: inline-block !important;
        align-self: flex-start;
        background: var(--dc-bg-alt);
        color: var(--dc-text-muted);
        padding: 2px 8px;
        border-radius: 4px;
        font-size: 11px;
        font-weight: 500;
        margin-bottom: 12px;
    }

    .dc-col-price, 
    .dc-col-anchor {
        display: flex !important;
        flex-direction: row;
        align-items: baseline;
        justify-content: space-between;
        padding-top: 8px !important;
        margin-top: 6px;
        border-top: 1px dashed var(--dc-border) !important;
    }

    .dc-col-price::before,
    .dc-col-anchor::before {
        content: attr(data-label);
        font-size: 12px;
        font-weight: 600;
        color: var(--dc-text-muted);
    }

    .dc-col-price > div,
    .dc-col-price > span,
    .dc-col-anchor > div,
    .dc-col-anchor > span {
        text-align: right;
    }

    .dc-public-table tr:hover td {
        background: transparent;
    }

    /* Centered Empty State on mobile */
    .dc-search-empty-row {
        display: none !important;
    }

    .dc-search-empty-row.is-active {
        display: block !important;
        width: 100% !important;
        margin: 20px 0 !important;
    }

    .dc-search-empty-cell {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 40px 16px !important;
        margin: 0 auto !important;
    }

    .dc-empty-icon {
        display: block !important;
        font-size: 32px !important;
        margin: 0 auto 10px auto !important;
        text-align: center !important;
    }

    .dc-empty-query-text {
        display: block !important;
        text-align: center !important;
        font-size: 14px !important;
        margin: 0 auto !important;
    }

    /* Mobile footer download buttons stack neatly */
    .dc-footer-downloads {
        flex-direction: column;
        align-items: stretch;
    }

    .dc-download-link {
        justify-content: center;
        padding: 10px 16px;
    }

    .dc-footer-downloads .dc-print-trigger-btn {
        margin-left: 0 !important;
    }

    .dc-special-notes-box {
        padding: 14px 16px;
        margin-bottom: 14px;
    }

    /* Archive Table Mobile Scroll & Cell Display */
    .dc-archive-table-wrap {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .dc-archive-table {
        display: table !important;
        width: 100% !important;
        min-width: 620px;
    }

    .dc-archive-table thead {
        display: table-header-group !important;
    }

    .dc-archive-table tbody {
        display: table-row-group !important;
    }

    .dc-archive-table tr {
        display: table-row !important;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }

    .dc-archive-table td,
    .dc-archive-table th {
        display: table-cell !important;
        padding: 10px 12px !important;
        border-bottom: 1px solid var(--dc-border-subtle) !important;
    }
}

