:root {
    /* ===== WPIS PRIMARY COLOR SYSTEM ===== */
    --wpis-primary-color: #1256c4;
    --wpis-primary-color-hover: #0f4bab;
    --wpis-primary-color-active: #0d3f8f;
    --wpis-primary-color-light: #e8f0fc;
    --wpis-primary-color-rgb: 18, 86, 196;
    
    /* ===== Layout Variables ===== */
    --item-fullscreen-height: 100vh;
    --item-fullscreen-offset-top: 0px;
}

/* 🛡️ SCOPED: Globálne body štýly odstránené - konflikt s WooCommerce checkout */
/* Tieto štýly sú aplikované len na WPIS kontajnery */
#wpis-invoice-dashboard,
#wpis-user-profile,
#wpis-invoice-statistics {
    font-family: Arial, sans-serif;
}
/* 🛡️ SCOPED: .form-container len pre WPIS */
#wpis-invoice-dashboard .form-container,
.wpis-form-container {
    max-width: 1000px;
    margin: 20px auto;
    padding: 20px;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* Špecificky pre fakturačný dashboard – formulár používa plnú šírku panelu */
#wpis-invoice-dashboard .form-container {
    max-width: none;
    margin: 20px 0;
}
.form-header {
    margin-bottom: 20px;
}
.invoice-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
}
.invoice-number-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
.invoice-number-container input {
    width: 140px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-weight: bold;
    font-size: 14px;
    transition: all 0.2s ease;
}
.invoice-number-container input:focus {
    border-color: var(--wpis-primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--wpis-primary-color-rgb), 0.15);
}
/* 🛡️ SCOPED: .form-row len pre WPIS formuláre - predtým konflikt s WooCommerce .form-row */
#wpis-invoice-dashboard .form-row,
.wpis-form-container .form-row {
    display: flex;
    margin-bottom: 15px;
    gap: 20px;
}
/* 🛡️ SCOPED: .form-column len pre WPIS */
#wpis-invoice-dashboard .form-column,
.wpis-form-container .form-column {
    flex: 1;
}
/* 🛡️ SCOPED: .form-group len pre WPIS kontajnery */
#wpis-invoice-dashboard .form-group,
.wpis-form-container .form-group {
    margin-bottom: 15px;
}
#wpis-invoice-dashboard .form-group label,
.wpis-form-container .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 14px;
}
#wpis-invoice-dashboard .form-group input,
#wpis-invoice-dashboard .form-group select,
#wpis-invoice-dashboard .form-group textarea,
.wpis-form-container .form-group input,
.wpis-form-container .form-group select,
.wpis-form-container .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    background-color: #fff;
    transition: all 0.2s ease;
}
#wpis-invoice-dashboard .form-group input:focus,
#wpis-invoice-dashboard .form-group select:focus,
#wpis-invoice-dashboard .form-group textarea:focus,
.wpis-form-container .form-group input:focus,
.wpis-form-container .form-group select:focus,
.wpis-form-container .form-group textarea:focus {
    border-color: var(--wpis-primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--wpis-primary-color-rgb), 0.15);
}

/* Label zmena farby pri focus na input */
#wpis-invoice-dashboard .form-group:focus-within label,
.wpis-form-container .form-group:focus-within label {
    color: var(--wpis-primary-color);
    transition: color 0.2s ease;
}
#wpis-invoice-dashboard .form-group textarea,
.wpis-form-container .form-group textarea {
    resize: vertical;
    min-height: 80px;
}

@media (min-width: 769px) {
    /* Desktop: zjednotí výšku textových, číselných a dátumových polí */
    /* 🛡️ SCOPED: len pre WPIS kontajnery */
    #wpis-invoice-dashboard .form-group input[type="text"],
    #wpis-invoice-dashboard .form-group input[type="number"],
    #wpis-invoice-dashboard .form-group input[type="date"],
    #wpis-invoice-dashboard .form-group select,
    .wpis-form-container .form-group input[type="text"],
    .wpis-form-container .form-group input[type="number"],
    .wpis-form-container .form-group input[type="date"],
    .wpis-form-container .form-group select {
        height: 40px;
    }
    #due_days,
    #due_date {
        height: 40px;
    }
    .add-customer-btn {
        height: 40px;
    }
}
.table-container {
    width: 100%;
    margin: 30px 0;
    overflow-x: auto;
}

.product-table {
    width: 100%;
    border: 1px solid #ddd;
    border-collapse: collapse;
    table-layout: auto;
}

.product-table th,
.product-table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

.product-table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.product-table input {
    width: 100%;
    padding: 6px;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 3px;
}

.product-table .remove-btn {
    background-color: #ff4d4d;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 5px 10px;
    cursor: pointer;
}

.product-table .remove-btn:hover {
    background-color: #e60000;
}

.add-product-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.add-product-btn:hover {
    background-color: #45a049;
}

@media screen and (max-width: 768px) {
    .product-table {
        width: 100%;
        display: block;
    }

    .product-table thead {
        display: none;
    }

    .product-table,
    .product-table tbody,
    .product-table tr,
    .product-table td {
        display: block;
    }

    .product-table tr {
        margin-bottom: 10px;
        border: 1px solid #ddd;
        padding: 10px;
        background: #f9f9f9;
    }

    .product-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px;
        position: relative;
        text-align: left;
    }

    .product-table td::before {
        content: attr(data-label);
        font-weight: bold;
        flex: 1 1 40%;
        padding-right: 10px;
        text-align: left;
        white-space: nowrap;
    }

    .product-table td input {
        flex: 1 1 60%;
        width: auto;
        box-sizing: border-box;
        padding: 6px;
    }

    .order-buttons {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }

    .add-product-btn {
        width: 100%;
        font-size: 16px;
        padding: 10px;
    }
}
.footer-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}
.footer-row {
    display: flex;
    gap: 20px;
}
.footer-column {
    flex: 1;
}
/* Total Section - Modern 2025 */
.total-section {
    margin-top: 20px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}
.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}
.total-row:last-child {
    border-bottom: none;
    margin-top: 8px;
    padding-top: 12px;
}
/* K úhrade - zvýraznený text vo firemných farbách */
.total-row:last-child .total-label,
.total-row:last-child .total-value {
    color: var(--wpis-primary-color);
    font-weight: 700;
    font-size: 16px;
}
.total-label {
    font-weight: 500;
    color: #374151;
    text-align: left;
}
.total-value {
    font-weight: 600;
    text-align: right;
    color: #1e293b;
}
.total-input {
    width: 100px;
    text-align: right;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
}
.total-input:focus {
    border-color: var(--wpis-primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(var(--wpis-primary-color-rgb), 0.15);
}
.order-buttons {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.order-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 10px;
}
.order-btn:hover {
    background-color: #5a6268;
}
.stamp-section {
    margin-top: 30px;
    text-align: center;
}
.stamp-preview {
    width: 150px;
    height: 150px;
    margin: 0 auto;
    border: 1px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
    cursor: pointer;
}
.stamp-preview:hover {
    background-color: #f8f9fa;
}
.stamp-preview img {
    max-width: 100%;
    max-height: 100%;
}
.action-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    gap: 12px;
}
.action-button {
    min-height: 40px;
    padding: 10px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}
.save-button {
    background: linear-gradient(135deg, var(--wpis-primary-color) 0%, var(--wpis-primary-color-hover) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(var(--wpis-primary-color-rgb), 0.25);
}
.save-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--wpis-primary-color-rgb), 0.35);
}
.save-button:active {
    transform: translateY(0);
}
.cancel-button {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}
.cancel-button:hover {
    background-color: #e5e7eb;
    transform: translateY(-1px);
}
.cancel-button:active {
    transform: translateY(0);
}
.customer-selection {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

/* Customer input rovnaká výška ako add-customer-btn */
.customer-autocomplete input {
    height: 40px;
    min-height: 40px;
}

.customer-autocomplete {
    position: relative;
    flex: 1;
}

.customer-autocomplete input {
    width: 100%;
    padding-right: 28px; /* priestor pre X */
}

.customer-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #888;
    padding: 0;
}

.customer-clear-btn:hover {
    color: #555;
}

.customer-autocomplete-results {
    position: absolute;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1002;
    display: none;
}

.customer-autocomplete-results:not(:empty) {
    display: block;
}

.customer-autocomplete-results .customer-suggestion {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
}

.customer-autocomplete-results .customer-suggestion:hover {
    background-color: #f0f5ff;
}

.customer-autocomplete-results .customer-suggestion.empty {
    cursor: default;
    color: #888;
}
.customer-selection select {
	position: absolute;
	opacity: 0;
	pointer-events: none;
	height: 0;
	width: 0;
}
.add-customer-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.add-customer-btn:hover {
    background-color: #3d9142;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.35);
}
.add-customer-btn:active {
    transform: translateY(0);
}
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.modal-content {
    background-color: #fff;
    padding: 20px 25px;
    border-radius: 10px;
    width: 400px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    animation: fadeInUp 0.25s ease;
    pointer-events: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.close-modal {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}
.close-modal:hover {
    color: #777;
}
.modal-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}
.modal-form-column {
    flex: 1;
}

/* customer style */
/* Formuláre */
.contact-form-container {
    background-color: #f9f9f9;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.contact-form-container h2 {
    font-size: 20px;
    margin-bottom: 15px;
}

.contact-form-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.contact-form-container input {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.contact-form-container button {
    background-color: #28a745;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.contact-form-container button:hover {
    background-color: #218838;
}

/* NOVA ITEMS TABULKA */


.item-table select.tax-input {
    width: 80px;
    padding: 4px;
    font-size: 14px;
}

.order-buttons {
    display: flex;
    gap: 4px;
}

.order-buttons button {
    padding: 2px 6px;
    border: 1px solid #aaa;
    background: #fff;
    cursor: pointer;
}

.order-buttons button:hover {
    background: #eee;
}

.mode-read .drag-handle {
    opacity: 0.3;
    cursor: default !important;
}

/* INVOICE LIST - DASHBOARD */
#wpis-invoice-dashboard {
    max-width: 1200px;          /* Rovnaké ako profil */
    margin-left: auto;
    margin-right: auto;
}

.invoice-dashboard {
    display: flex;
    gap: 20px;
    height: 100%;
}
  
.invoice-sidebar {
    position: relative; /* Nutné pre z-index detí */
    z-index: 100;       /* Základná vrstva */
    flex: 0 0 30%;      /* základ 30 % */
    max-width: 340px;   /* nikdy viac než ~340px */
    min-width: 280px;   /* aby sa menu úplne nezosypalo */
    border-right: 1px solid #ddd;
    background: #f8fafc;
    padding: 10px;
    min-height: 520px;
    overflow-y: auto;
    overflow-x: hidden; /* Predvolene skryjeme horizontálny overflow */
    transition: overflow 0.3s ease; /* Plynulý prechod */
    display: flex;
    flex-direction: column;
    border-radius: 10px 0 0 10px; /* Zaoblené ľavé rohy */
}
  
.invoice-content {
    flex: 1;
    min-width: 0;       /* zabraňuje horizontálnemu scrollu pri flexe */
    padding: 20px;
}

@media (max-width: 768px) {
    .invoice-dashboard {
        flex-direction: column;
    }

    .invoice-sidebar,
    .invoice-content {
        width: 100%;
        max-width: 100%;
    }

    .invoice-sidebar {
        display: block;
    }

    .invoice-content {
        display: none;
        padding: 0;
    }

    .invoice-dashboard.show-content .invoice-sidebar,
    .invoice-dashboard.show-menu .invoice-content {
        display: none;
    }

    .invoice-dashboard.show-content .invoice-content,
    .invoice-dashboard.show-menu .invoice-sidebar {
        display: block;
    }

    .invoice-dashboard.show-content,
    .invoice-dashboard.show-menu {
        min-height: 100vh;
    }
}

/* === HLAVIČKA ZOZNAMU FAKTÚR === */
.invoice-list-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1rem;
    position: relative; /* Pre z-index kontext */
    z-index: 101; /* Mierne nad sidebarom, ale pod otvoreným menu */
}

.invoice-list-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

#invoice-list {
    flex: 1 1 auto;
    min-height: 0;
}

#invoice-summary {
    margin-top: auto; /* Odtlačí summary + pagination na spodok wrappera */
}

/* Create Invoice Button - Modern 2025 */
#create-invoice-btn {
    width: 100%;
    min-height: 40px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--wpis-primary-color) 0%, var(--wpis-primary-color-hover) 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(var(--wpis-primary-color-rgb), 0.25);
}

#create-invoice-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--wpis-primary-color-rgb), 0.35);
}

#create-invoice-btn:active {
    transform: translateY(0);
}

.button-primary {
    width: 100%;
    background-color: var(--wpis-primary-color);
    color: #fff;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}
.button-primary:hover { background-color: var(--wpis-primary-color-hover); }

 /* Search wrapper pre SVG ikonu */
 .invoice-search-wrapper {
     position: relative;
     width: 100%;
 }

.invoice-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    z-index: 1;
    width: 16px;
    height: 16px;
}

 .invoice-search-wrapper:focus-within .invoice-search-icon {
     color: var(--wpis-primary-color);
 }
 
 .invoice-search {
     width: 100%;
     padding: 8px 12px 8px 38px; /* left: 38px pre ikonu (12px + 16px + 10px) */
     border: 1px solid #d1d5db;
     border-radius: 8px;
     font-size: 14px;
     background-color: #f9fafb;
     min-height: 35px;
     height: 35px;
     box-sizing: border-box;
     transition: all 0.2s ease;
 }

 /* Vyššia špecificita (rovnako ako v profile pri wpis-customer-search), aby padding nebol prepisovaný témou/pluginmi */
 #wpis-invoice-dashboard .invoice-search-wrapper > #invoice-search.invoice-search {
     padding: 8px 12px 8px 38px;
 }

 .invoice-search:focus {
     border-color: var(--wpis-primary-color);
     background-color: #fff;
     box-shadow: 0 0 0 3px rgba(var(--wpis-primary-color-rgb), 0.15);
     outline: none;
 }

.invoice-search::placeholder {
    color: #9ca3af;
    font-size: 14px;
}

/* === ZJEDNOTENÉ MENU (pre "⋮" aj "Filter") === */
.invoice-menu {
    position: relative; /* Nutné pre absolútne pozicovanie obsahu */
    display: inline-block; /* Alebo block, ak má byť na celú šírku */
}

/* --- Tlačidlo na otvorenie menu (3 bodky) --- */
.invoice-menu-btn {
    background: transparent;
    border: none;
    font-size: 18px; /* Ikonka "⋮" */
    cursor: pointer;
    padding: 4px;
    border-radius: 9999px; /* Malý kruh okolo ikonky */
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af; /* Jemná sivá */
    transition: background 0.15s ease, color 0.15s ease;
}
.invoice-menu-btn:hover {
    background: rgba(15, 23, 42, 0.04); /* veľmi jemný hover */
    color: #4b5563;
}
.invoice-menu.open .invoice-menu-btn {
    background: rgba(var(--wpis-primary-color-rgb), 0.08);
    color: var(--wpis-primary-color);
}

/* Vzhľad pre tlačidlá "Filter", "Zoradiť" atď. */
.invoice-menu-btn.button-like {
    background: #f8f9fa;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: normal;
    transition: background 0.2s ease;
    width: 100%; /* Na celú šírku v .dropdown-group */
    flex: 1; /* Aby sa roztiahli rovnomerne */
}
.invoice-menu-btn.button-like:hover {
    background: var(--wpis-primary-color-light);
    color: var(--wpis-primary-color);
}

/* --- Obsah menu (kontajner) --- */
.invoice-menu-content {
    display: none; /* Skryté defaultne */
    position: absolute;
    top: 100%; /* Otvára sa pod tlačidlom */
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    min-width: 200px; /* Minimálna šírka pre "⋮" menu */
    z-index: 1001; /* Musí byť najvyššie */
    padding: 8px 0; /* Menší padding hore/dole */
    box-sizing: border-box;
    margin-top: 6px; /* Malá medzera od tlačidla */
}

/* Pozícia pre menu "⋮" (vpravo) */
.invoice-item .invoice-menu-content {
    right: 0;
    left: auto; /* Zrušíme left, ak by bolo nastavené */
}
.sort-menu button.active-sort {
    background-color: var(--wpis-primary-color);
    color: white;
    font-weight: 600;
    border-radius: 6px;
  }
  .sort-menu button.active-sort:hover {
    background-color: var(--wpis-primary-color-hover);
    color: white; /* farba textu sa nemení */
  }
/* Keď je v sidebare otvorené menu, dočasne povolíme overflow */
.invoice-sidebar.sidebar-menu-open {
    overflow-y: visible !important; /* Povolíme vertikálny overflow */
    overflow-x: visible !important; /* KĽÚČOVÁ ZMENA: Explicitne povolíme aj horizontálny overflow */
    z-index: 1000;
}
/* Zabezpečíme, aby skupina tlačidiel nebránila overflow */
.invoice-actions-bar .dropdown-group {
    display: flex; /* Alebo grid */
    gap: 8px;
    overflow: visible; /* Dôležité */
}
.invoice-actions-bar {
    overflow: visible; /* Dôležité */
    position: relative; /* Pre z-index kontext */
    z-index: 101; /* Mierne nad sidebarom, ale pod otvoreným menu */
}

/* Pozícia pre menu Filter/Sort/Export (vľavo) */
.invoice-actions-bar .invoice-menu-content {
    left: 0; /* KĽÚČOVÁ ZMENA: Zarovná ľavý okraj menu s ľavým okrajom tlačidla */
    right: auto; /* Zrušíme right */
    min-width: 240px; /* Širšie menu pre filter */
    padding: 12px; /* Vrátime padding pre filter */
}

/* Keď je menu otvorené */
.invoice-menu.open > .invoice-menu-content { /* Použijeme > pre špecificitu */
    display: block; /* Zobrazíme ho */
    z-index: 1001;
}
/* Pre "⋮" menu chceme flex column */
.invoice-item .invoice-menu.open > .invoice-menu-content {
    display: flex;
    flex-direction: column;
    padding: 6px 0; /* Reset paddingu pre "⋮" menu */
}


/* Drop-up varianta (pridá sa dynamicky cez JS) */
.invoice-menu.drop-up > .invoice-menu-content {
    top: auto;
    bottom: 100%; /* Tesne nad tlačidlom */
    margin-top: 0;
    margin-bottom: 4px; /* Malá medzera nad tlačidlom */
}

/* --- Tlačidlá vnútri menu ("Zobraziť", "Upraviť"...) --- */
.invoice-menu-content button {
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 14px;
    margin: 2px 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    width: calc(100% - 12px);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    white-space: nowrap;
    border-radius: 8px;
}

.invoice-menu-content button:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.invoice-menu-content button:hover .menu-icon svg {
    stroke: var(--wpis-primary-color);
}

.invoice-menu-content button.delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

.invoice-menu-content button.delete:hover .menu-icon svg {
    stroke: #dc2626;
}

.invoice-menu-content button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: #9ca3af;
}

.invoice-menu-content button.disabled:hover {
    background: transparent;
}

.invoice-menu-content button.disabled:hover .menu-icon svg {
    stroke: #9ca3af;
}

/* Ikona v menu */
.invoice-menu-content .menu-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.invoice-menu-content .menu-icon svg {
    stroke: #6b7280;
    transition: stroke 0.2s ease;
}

/* Label v menu */
.invoice-menu-content .menu-label {
    flex: 1;
}

/* Oddeľovač v menu */
.invoice-menu-content .menu-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 6px 12px;
}



/* === VNÚTRO FILTRA === */
.invoice-menu-content label { /* Selektor platí len pre filter vďaka paddingu */
    font-weight: 600;
    display: block;
    margin-top: 10px;
    margin-bottom: 4px;
    font-size: 13px;
}
.invoice-menu-content label:first-child { margin-top: 0; } /* Prvý label bez medzery hore */

.invoice-menu-content select,
.invoice-menu-content input { /* Zahrnie všetky inputy */
    width: 100%;
    padding: 8px 10px; /* Trochu väčší padding */
    border: 1px solid #ccc;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 13px;
}

.invoice-menu-content .date-range,
.invoice-menu-content .range-inputs {
    display: flex;
    align-items: center;
    gap: 6px;
}
.invoice-menu-content .date-range span,
.invoice-menu-content .range-inputs span {
     flex-shrink: 0; /* Aby sa pomlčka nezmenšovala */
}


.invoice-menu-content .apply-filter {
    background: var(--wpis-primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 5px 10px; /* užšie tlačidlo */
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.2s ease; /* mení len pozadie */
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    min-width: 80px;
    box-sizing: border-box;
  }
  
  .invoice-menu-content .apply-filter:hover {
    background: var(--wpis-primary-color-hover); /* zmena iba pozadia */
    color: white; /* farba textu sa nemení */
  }

/* 🔹 Štýl pre kontajner akcií */
.filter-actions {
    display: flex;
    justify-content: flex-end; /* tlačidlá zarovnané doprava */
    align-items: center;
    gap: 20px; /* väčší rozostup medzi "Vyčistiť filter" a tlačidlom */
    margin-top: 15px;
  }
  
  /* 🔹 "Vyčistiť filter" – sivý text, hrubší, modrý pri hover */
  .clear-filter {
    color: #666;
    font-size: 14px;
    font-weight: 600; /* hrubší text */
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
    white-space: nowrap; /* zabráni zalomeniu textu na dva riadky */
  }
  
  .clear-filter:hover {
    color: var(--wpis-primary-color-hover); /* modrá pri hover */
    text-decoration: none;
  }

/* === POLOŽKA FAKTÚRY (Tvoj kód, bez zmeny) === */
.invoice-item {
    position: relative;
    background: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: opacity 0.6s ease, transform 0.6s ease;
    margin-bottom: 12px;
    z-index: 1; 
}
/* ... (všetky ostatné tvoje štýly pre .invoice-item, .invoice-row-top atď. zostávajú rovnaké) ... */

.invoice-item.removed {
    opacity: 0;
    transform: translateY(-10px);
}

.invoice-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-1px);
    z-index: 100; /* táto faktúra bude nad ostatnými */
}

.invoice-item.overdue { border-left: 4px solid #d63638; }

.invoice-row-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.invoice-meta {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: #555;
}
.invoice-row-middle {
    font-weight: 600;
    font-size: 14px;
    color: #222;
}
.invoice-row-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Umožní vertikálne zarovnanie, ak sa badge zalomuje */
    gap: 8px; /* Minimálna medzera medzi elementmi */
    font-weight: 600;
    font-size: 15px;
    color: #000;
}

.invoice-status {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Stav úhrady faktúry (badge v zozname) - Modern 2025 */
.payment-status {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    max-width: 100%;
    white-space: normal;
    word-break: keep-all;
    line-height: 1.3;
    text-align: center;
    box-sizing: border-box;
    transition: all 0.15s ease;
}

.wpis-locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.payment-status.wpis-locked {
    background: #f3f4f6;
    color: #9ca3af;
}

/* Uhradená a Neuhradená - jednoslovné, nesmú sa zalamývať */
.payment-status-paid,
.payment-status-unpaid {
    white-space: nowrap;
}

/* Čiastočne uhradené - môže sa zalomiť pri úzkych obrazovkách */
.payment-status-partial {
    max-width: 11ch;
    flex-direction: column;
    gap: 0;
}

/* Pri širokých obrazovkách nechaj aj partial rozšíriť */
@media (min-width: 1200px) {
    .payment-status-partial {
        max-width: fit-content;
        flex-direction: row;
    }
}

/* Suma vždy s € na jednom riadku */
.invoice-row-bottom .invoice-total {
    white-space: nowrap;
    flex-shrink: 0;
}

/* Status farby - Modern 2025 */
.payment-status-paid {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.payment-status-unpaid {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.payment-status-partial {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.status-overdue {
    color: #dc2626;
}

.status-issued {
    color: #64748b;
}

/* MENU */
.invoice-menu {
    position: relative;
    display: inline-block;
}

.invoice-menu-btn {
    background: transparent;
    border: none;
    padding: 4px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    color: #6b7280;
    transition: color 0.2s ease;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.invoice-menu-btn:hover {
    color: #374151;
}

.invoice-menu-btn.button-like {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 6px 8px;
    border-radius: 8px;
    color: #6b7280;
    transition: all 0.2s ease;
    line-height: 1;
}

.invoice-menu-btn.button-like:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.invoice-menu-content.active { 
    display: flex; 
}

/* aktívne menu */
.invoice-menu.open .invoice-menu-content {
    display: flex;
    flex-direction: column;
    z-index: 1001;
}
  
/* drop-up varianta */
.invoice-menu.drop-up .invoice-menu-content {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 6px;
}

/* DROP-UP FIX */
.invoice-menu-content.drop-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 6px;
}

/* SUMMARY - Modern 2025 */
.invoice-summary {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
    font-size: 14px;
    color: #374151;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Každý span zarovnaný - text vľavo, čísla vpravo nie je možné bez zmeny HTML */
/* Keďže text je "Spolu: 0,00 €" ako jeden string, zarovnáme celý riadok */
#invoice-count {
    display: block;
    text-align: left;
    font-weight: 500;
    color: #64748b;
}

#invoice-total {
    display: block;
    text-align: right;
    font-weight: 600;
    color: #1e293b;
}

#invoice-total-net {
    display: block;
    text-align: right;
    font-weight: 500;
    color: #64748b;
    font-size: 13px;
}

.invoice-summary-row {
    display: flex;
    justify-content: space-between;
}

.invoice-pagination {
    margin-top: 16px;
    padding-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.invoice-page-btn {
    min-width: 32px;
    height: 32px;
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: #374151;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.invoice-page-btn:hover:not(:disabled) {
    background: var(--wpis-primary-color-light);
    border-color: var(--wpis-primary-color);
    color: var(--wpis-primary-color);
}

.invoice-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
    background: #f9fafb;
}

.invoice-page-btn.active {
    background: var(--wpis-primary-color);
    color: #fff;
    border-color: var(--wpis-primary-color);
    font-weight: 600;
}

/* Prev/Next buttons */
.invoice-page-btn.prev-btn,
.invoice-page-btn.next-btn {
    padding: 6px 12px;
    font-weight: 600;
}

@media (max-width: 768px) {
    .invoice-pagination {
        justify-content: center;
        gap: 4px;
    }
    
    .invoice-page-btn {
        min-width: 28px;
        height: 28px;
        padding: 4px 8px;
        font-size: 12px;
    }
    .customer-selection,
    .customer-autocomplete {
        width: 100%;
    }
}
.invoice-card {
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 0; /* default */
}

.invoice-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 5; /* aby sa hovernutá dostala nad ostatné */
}

.invoice-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10; /* musí byť vyššie než hovernutá karta */
}

.invoice-actions .dropdown-menu {
    position: absolute;
    right: 0;
    bottom: 100%;
    z-index: 20; /* ešte vyššie, aby menu bolo nad všetkým */
    background: #fff;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    overflow: hidden;
}

/* MODAL */
.modal.success .modal-content {
    border-top: 4px solid #4caf50;
}

.modal.error .modal-content {
    border-top: 4px solid #e53935;
}

.modal.info .modal-content {
    border-top: 4px solid var(--wpis-primary-color);
}

.modal.warning .modal-content {
    border-top: 4px solid #ff9800;
}

.modal-icon {
    font-size: 1.5rem;
    margin-right: 8px;
}

/* Fade-in efekt pre vnútorný obsah */
@keyframes fadeInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- STATUS ICON --- */
.status-icon {
    font-size: 48px;
    text-align: center;
    margin: 10px 0;
}

.modal.show {
    display: flex;
    opacity: 1;
}

/* --- Farebné stavy --- */
.modal.success .status-icon { color: #2ecc71; }  /* zelená */
.modal.error .status-icon { color: #e74c3c; }    /* červená */
.modal.info .status-icon { color: var(--wpis-primary-color); }     /* modrá */
.modal.warning .status-icon { color: #f39c12; }  /* oranžová */

.status-modal .modal-content {
    text-align: center;
    max-width: 400px;
    border-radius: 12px;
}

.status-modal .status-icon {
    font-size: 3rem;
    margin: 10px 0;
}

.status-modal .form-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 15px;
}

.confirm-button {
    background-color: #e53935;
    color: white;
}

.action-button.confirm-button {
    background-color: var(--wpis-primary-color); /* modrá */
    color: white;
}

.action-button.confirm-button:hover {
    background-color: var(--wpis-primary-color-hover);
}

.action-button.cancel-button {
    background-color: #e0e0e0;
    color: #333;
}

.action-button.cancel-button:hover {
    background-color: #d5d5d5;
}

.action-button.danger-button {
    background-color: #e53935; /* červená */
    color: white;
}

.action-button.danger-button:hover {
    background-color: #c62828;
}

/* ===== AKTÍVNA FAKTÚRA ===== */
/* 🚀 DIVI FIX: Optimalizované štýly pre okamžitú odozvu */
.invoice-item.active {
    border-left: 3px solid var(--wpis-primary-color) !important;
    background-color: var(--wpis-primary-color-light) !important;
    box-shadow: inset 0 0 0 1px rgba(var(--wpis-primary-color-rgb), 0.2) !important;
    transform: none !important;
}

.invoice-item.active:hover {
    transform: none !important;
    box-shadow: inset 0 0 0 1px rgba(var(--wpis-primary-color-rgb), 0.3) !important;
}

/* 🚀 DIVI FIX: Nová subtílna animácia (namiesto starej highlightPop) */
@keyframes wpis-highlight-pulse {
    0% { box-shadow: 0 0 0 0 rgba(var(--wpis-primary-color-rgb), 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(var(--wpis-primary-color-rgb), 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(var(--wpis-primary-color-rgb), 0); }
}

/* 🔹 Trieda pre spustenie animácie - nová rýchla verzia */
.highlight-animate {
    animation: wpis-highlight-pulse 0.3s ease-out !important;
}

@media (max-width: 768px) {
    /* Na mobile nechceme highlight animáciu kontajnera */
    .highlight-animate {
        animation: none !important;
    }
}

/* 🧩 Žiadne farebné rozdiely medzi režimami – jednotný čistý dizajn */
.form-container.mode-create,
.form-container.mode-edit,
.form-container.mode-read {
    background-color: #fff;
    border: none;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* === ODDBERATELIA === */
.customer-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
  }
  
  .customer-card {
    background: #f9fbff;
    border: 1px solid #d6e2ff;
    border-radius: 10px;
    padding: 1rem;
    position: relative;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  .customer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
  }
  
  .customer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  }
  
  .customer-card h4 {
    font-size: 1rem;
    margin: 0 0 0.25rem 0;
    color: var(--wpis-primary-color);
    flex: 1 1 auto;
    min-width: 0;
    word-wrap: break-word;
    word-break: break-word;
  }
  
  .customer-card p {
    margin: 0;
    font-size: 0.9rem;
    color: #555;
  }
  
  .customer-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
  }
  
  .customer-actions button {
    border: none;
    background: none;
    cursor: pointer;
    color: #777;
    font-size: 16px;
    transition: color 0.2s ease;
  }
  
  .customer-actions button:hover {
    color: var(--wpis-primary-color);
  }
  
  /* Formulár pre pridanie odberateľa */
  .customer-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
  }
  
  .wpis-divider {
    border: 0;
    height: 1px;
    background: #e0e0e0;
    margin: 1.5rem 0;
  }

  .grid-col-full {
    grid-column: 1 / -1;
  }
  
  .customer-form-grid textarea {
    resize: vertical;
  }
  
  #cancel-edit {
    background: #eee;
    color: #444;
    margin-left: 0.5rem;
  }
  
  #cancel-edit:hover {
    background: #ddd;
  }

  #customer-modal .modal-content.large {
    width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

#customer-modal .modal-body.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

#customer-modal .form-group.full-width {
    grid-column: span 2;
}

@media (max-width: 768px) {
    #customer-modal .form-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    #customer-modal .form-actions .save-button {
        order: 1;
    }

    #customer-modal .form-actions .cancel-button {
        order: 2;
    }
}

/* === FORM VALIDATION STYLES === */
/* Chybné pole */
input.error, select.error, textarea.error {
    border: 1px solid #e74c3c !important;
    background-color: #fff6f6;
  }
  
  /* Text chybovej hlášky */
  .error-message {
    color: #e74c3c;
    font-size: 0.85em;
    margin-top: 4px;
    line-height: 1.2;
  }

button:disabled,
button[disabled],
.add-item-btn:disabled,
.open-customer-modal:disabled {
  background-color: #ccc !important;
  color: #666 !important;
  cursor: not-allowed !important;
  opacity: 0.6;
}

.item-list-container {
    margin: 30px 0;
    width: 100%;
    /* Premenné pre jednoduchšie ladenie */
    --item-border-radius: 8px;
    --item-padding-vertical: 14px;
    --item-padding-horizontal: 10px;
    --item-gap: 10px; /* Medzera medzi "kartami" */
    --input-bg-color: #f7f8f9;
}

/* === 1. HLAVIČKA (NÁZVY STĹPCOV) === */
.item-list-header {
    display: flex;
    width: 100%;
    padding: 0;
    padding-bottom: 8px;
    box-sizing: border-box; 
}

.item-header-col {
    color: #6c757d;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0 5px;
    box-sizing: border-box;
}

/* === 2. ZOZNAM RIADKOV (TELO) === */
.item-list-body {
    display: flex;
    flex-direction: column;
    gap: var(--item-gap); 
}

/* === 3. RIADOK POLOŽKY (KARTA) === */
.item-row {
    display: flex;
    flex-direction: column; /* 1. riadok = údaje, 2. riadok = poznámka */
    background: #ffffff;
    border-radius: var(--item-border-radius);
    border: 1px solid #e9ecef;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.2s ease;
}

.item-row-main {
    display: flex;
    align-items: stretch; /* horizontálny rad pre všetky stĺpce */
}

.item-row:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

/* === 4. STĹPCE V RIADKU === */
.item-row .item-col {
    display: flex;
    align-items: center;
    padding: 0; 
    box-sizing: border-box;
    border-right: 1px solid #f1f3f5;
}
.item-row .item-col:last-child {
    border-right: none;
}

/* === 5. VSTUPNÉ POLIA (INPUTS/SELECT) === */
.item-row input[type="text"],
.item-row input[type="number"],
.item-row select {
    width: 100%;
    height: 100%;
    padding: var(--item-padding-vertical) var(--item-padding-horizontal);
    border: none;
    background: transparent;
    font-size: 14px;
    color: #212529;
    box-sizing: border-box;
    border-radius: 0; 
}
.item-row input[type="text"]:focus,
.item-row input[type="number"]:focus,
.item-row select:focus {
    outline: none;
    background: var(--input-bg-color); 
}

.item-row input[type="number"],
.item-row .total input {
    text-align: right;
}

/* === ZMENA #1: Oprava poľa SPOLU === */
.item-row .total input {
    font-weight: 600;
    color: #000;
    background-color: transparent;
    
    /* Prepíšeme všeobecné pravidlo: 
       ponecháme vertikálny a ľavý padding, ale pravý nastavíme na minimum.
    */
    padding: var(--item-padding-vertical) 2px var(--item-padding-vertical) var(--item-padding-horizontal);
}

/* 5a. Druhý riadok položky – poznámka */
.item-note-row {
    border-top: 1px solid #f1f3f5;
}

.item-note-row input[type="text"] {
    width: 100%;
    padding: var(--item-padding-vertical) var(--item-padding-horizontal);
    border: none;
    background: transparent;
    font-size: 13px;
    color: #555;
}

/* === 6. ŠPECIFICKÉ STĹPCE A ICH ŠÍRKY === */

/* 1. Drag Handle */
.handle {
    flex: 0 0 15px; /* <-- ZMENA: Zúžené (bolo 36px) */
    justify-content: center;
    cursor: grab;
    color: #adb5bd;
    font-size: 18px;
    user-select: none;
    border-radius: var(--item-border-radius) 0 0 var(--item-border-radius);
    background: var(--input-bg-color);
}
.handle:active { cursor: grabbing; }

/* 2. Poradové číslo */
.row-num {
    flex: 0 0 35px;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    background: var(--input-bg-color);
}

/* 3. Názov (najväčší) */
.name {
    flex: 1 1 35%; /* Automaticky získa ušetrené miesto */
}

/* 4. Množstvo */
.quantity {
    flex: 0 1 100px;
}

/* 5. Merná Jednotka (MJ) */
.unit {
    flex: 0 1 80px;
}

/* 6. DPH */
.tax {
    flex: 0 1 95px; /* <-- ZMENA: Mierne rozšírené (bolo 90px) */
}
.item-row .tax select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236c757d%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.8-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right var(--item-padding-horizontal) center;
    background-size: .6em auto;
    padding-right: 28px;
}

/* 7. Cena za jednotku */
.price {
    flex: 0 1 130px;
}

/* 8. Spolu */
.total {
    flex: 0 1 145px;
}

/* 9. Akcie (tlačidlo X) */
.actions {
    flex: 0 0 30px;
    justify-content: center;
    border-radius: 0 var(--item-border-radius) var(--item-border-radius) 0;
}
.remove-btn {
    background: none;
    border: none;
    color: #adb5bd;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    padding: 0;
    margin: 0;
    cursor: pointer;
    border-radius: 50%;
    width: 22px; 
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.remove-btn:hover {
    background-color: #ffe3e3;
    color: #d90429;
}

/* === 7. TLAČIDLO "PRIDAŤ POLOŽKU" === */
.add-item-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background: #4CAF50; 
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.add-item-btn:hover {
    background: #45a049;
}

body.item-fullscreen-open {
    overflow: hidden;
}

body.item-fullscreen-open footer,
body.item-fullscreen-open #footer,
body.item-fullscreen-open #colophon,
body.item-fullscreen-open .footer,
body.item-fullscreen-open .site-footer,
body.item-fullscreen-open .footer-menu,
body.item-fullscreen-open .mobile-footer,
body.item-fullscreen-open .floating-footer {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(100%);
    transition: none;
}

body.modal-open {
    overflow: hidden;
}

body.item-fullscreen-open #wpadminbar,
body.item-fullscreen-open header,
body.item-fullscreen-open .site-header,
body.item-fullscreen-open .site-branding,
body.item-fullscreen-open .admin-bar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: none;
}

@media (max-width: 768px) {
    /* === Mobile: Invoice items (collapsed / expanded) === */
    .item-list-container {
        margin: 20px 0;
    }

    .item-list-header {
        display: none;
    }

    .item-row {
        border-radius: var(--item-border-radius);
        overflow: hidden;
    }

    /* Collapsed = kompaktný súhrnny riadok */
    .item-row.is-collapsed {
        display: flex;
        flex-direction: column;
        padding: 8px 12px;
        gap: 4px;
    }

    .item-row.is-collapsed .item-row-main {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .item-row.is-collapsed .item-col {
        border-right: none;
        border-bottom: none;
        padding: 0;
    }

    .item-row.is-collapsed .handle {
        order: 1;
        flex: 0 0 auto;
        margin-right: 4px;
    }

    .item-row.is-collapsed .row-num {
        order: 2;
        flex: 0 0 auto;
        font-size: 12px;
        font-weight: 600;
        color: #6c757d;
    }

    .item-row.is-collapsed .name {
        order: 3;
        /* nechaj názov využiť celú dostupnú šírku medzi číslom a sumou */
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Poznámka sa v collapsed stave nezobrazuje, iba v expanded */
    .item-row.is-collapsed .item-note-row {
        display: none;
    }

    .item-row.is-expanded .item-note-row {
        display: flex;
        flex-direction: column;
        border-top: none;
        padding-top: 0;
    }

    .item-row.is-collapsed .total {
        order: 4;
        flex: 0 0 auto;
        text-align: right;
        min-width: 80px;
    }

    /* Špeciálne: šírka sumy v riadku položky na mobile */
    .item-row.is-collapsed .total .total-input {
        width: auto;
        min-width: 72px;
        max-width: 110px;
        text-align: right;
    }

    .item-row.is-collapsed .actions {
        order: 5;
        flex: 0 0 auto;
        justify-content: flex-end;
    }

    .item-row.is-collapsed .quantity,
    .item-row.is-collapsed .unit,
    .item-row.is-collapsed .tax,
    .item-row.is-collapsed .price {
        display: none;
    }

    .item-row.is-collapsed .item-col::before {
        display: none;
    }

    .item-row.is-collapsed .name input,
    .item-row.is-collapsed .total input {
        border: none;
        background: transparent;
        padding: 0;
        font-size: 15px;
        pointer-events: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .item-row.is-collapsed .name input {
        width: 100%;
    }

    .item-row.is-collapsed .total input {
        font-weight: 600;
        text-align: right;
    }

    /* Expanded = plne editovateľný formulár */
    .item-row.is-expanded {
        display: flex;
        flex-direction: column;
        padding: 16px 16px 20px;
        gap: 12px;
    }

    /* Vo fullscreen / expanded móde zobraz všetky polia pod sebou */
    .item-row.is-expanded .item-row-main {
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
    }

    .item-row.item-fullscreen {
        position: fixed;
        top: var(--item-fullscreen-offset-top, 0);
        left: 0;
        right: 0;
        bottom: auto;
        width: 100vw;
        height: var(--item-fullscreen-height, 100vh);
        max-height: var(--item-fullscreen-height, 100vh);
        min-height: var(--item-fullscreen-height, 100vh);
        border-radius: 0;
        background: #fff;
        z-index: 999999;
        overflow-y: auto;
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
        padding-bottom: 24px;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }

    .item-row.is-expanded .item-col {
        width: 100%;
        border-right: none;
        border-bottom: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        flex: 0 0 auto; /* 🔁 zruší desktopové flex-basis hodnoty (.name, .price, .total...) */
    }

    /* 🔁 Reset desktopových šírok (flex-basis) pre mobilný fullscreen layout */
    .item-row.is-expanded .item-row-main .name,
    .item-row.is-expanded .item-row-main .quantity,
    .item-row.is-expanded .item-row-main .unit,
    .item-row.is-expanded .item-row-main .tax,
    .item-row.is-expanded .item-row-main .price,
    .item-row.is-expanded .item-row-main .total,
    .item-row.is-expanded .item-row-main .actions {
        flex: 0 0 auto;
        width: 100%;
    }

    .item-row.is-expanded .item-col + .item-col {
        margin-top: 0;
    }

    .item-row.is-expanded .item-col::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        color: #6c757d;
        margin-bottom: 2px;
    }

    /* V expanded/fullscreen móde na mobile nechceme zobrazovať P. Č. */
    .item-row.is-expanded .row-num {
        display: none;
    }

    /* Poznámka ako plnohodnotné pole hneď pod názvom v mobile fullscreen */
    .item-row.is-expanded .item-note-row::before {
        content: "POZNÁMKA";
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        color: #6c757d;
        margin-bottom: 2px;
    }

    .item-row.is-expanded .item-note-row input[type="text"] {
        border: 1px solid #ddd;
        border-radius: 6px;
        background: #fff;
        padding: 10px 12px;
        font-size: 15px;
        height: 48px;
        box-shadow: none;
    }

    /* Bez labelu pre handle / akcie */
    .item-row.is-expanded .handle::before,
    .item-row.is-expanded .actions::before {
        content: none;
    }

    .item-row.is-expanded .item-col input[type="text"],
    .item-row.is-expanded .item-col input[type="number"],
    .item-row.is-expanded .item-col select {
        border: 1px solid #ddd;
        border-radius: 6px;
        background: #fff;
        padding: 10px 12px;
        font-size: 15px;
        height: 48px;
        box-shadow: none;
    }

    .item-row.is-expanded .handle,
    .item-row.is-expanded .actions {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .item-row.is-expanded .row-num {
        align-items: flex-start;
    }

    /* Mobilné tlačidlo Zavrieť */
    .item-mobile-close {
        display: none;
        margin-top: 10px;
        align-self: flex-end;
        padding: 10px 14px;
        font-size: 14px;
        border-radius: 6px;
        border: 1px solid #ccc;
        background: #f1f3f5;
        cursor: pointer;
    }

    .item-row.is-expanded .item-mobile-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .item-row.item-fullscreen .item-mobile-close {
        position: sticky;
        top: 0;
        margin-top: 0;
        margin-bottom: 8px;
        align-self: stretch;
        justify-content: center;
    }

    .item-row.is-expanded.item-fullscreen .remove-btn {
        font-size: 0;
    }

    .item-row.is-expanded.item-fullscreen .remove-btn::before {
        content: "";
        display: block;
        width: 16px;
        height: 16px;
        background-color: currentColor;
        -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A//www.w3.org/2000/svg'%20viewBox%3D'0%200%2024%2024'%3E%3Cg%20fill%3D'none'%20stroke%3D'white'%20stroke-width%3D'2'%20stroke-linecap%3D'round'%20stroke-linejoin%3D'round'%3E%3Cpath%20d%3D'M3%206h18'/%3E%3Cpath%20d%3D'M8%206V4h8v2'/%3E%3Cpath%20d%3D'M19%206v14a2%202%200%200%201-2%202H7a2%202%200%200%201-2-2V6'/%3E%3Cpath%20d%3D'M10%2011v6'/%3E%3Cpath%20d%3D'M14%2011v6'/%3E%3C/g%3E%3C/svg%3E");
        -webkit-mask-repeat: no-repeat;
        -webkit-mask-position: center;
        -webkit-mask-size: contain;
        mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A//www.w3.org/2000/svg'%20viewBox%3D'0%200%2024%2024'%3E%3Cg%20fill%3D'none'%20stroke%3D'white'%20stroke-width%3D'2'%20stroke-linecap%3D'round'%20stroke-linejoin%3D'round'%3E%3Cpath%20d%3D'M3%206h18'/%3E%3Cpath%20d%3D'M8%206V4h8v2'/%3E%3Cpath%20d%3D'M19%206v14a2%202%200%200%201-2%202H7a2%202%200%200%201-2-2V6'/%3E%3Cpath%20d%3D'M10%2011v6'/%3E%3Cpath%20d%3D'M14%2011v6'/%3E%3C/g%3E%3C/svg%3E");
        mask-repeat: no-repeat;
        mask-position: center;
        mask-size: contain;
    }

 }

@media (max-width: 768px) {
    /* === Mobile: Form wrapper === */
    .form-container {
        margin: 0;
        padding: 10px 12px;
        box-shadow: none;
        max-width: 100%;
        border-radius: 0;
    }

    /* Dashboard na mobile: žiadny horizontálny scroll, šírka 100 % */
    #wpis-invoice-dashboard {
        max-width: 100%;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        overflow-x: hidden;
    }

    /* === Mobile: Layout stacking === */
    .form-row,
    .footer-row,
    .customer-selection,
    .modal-form-row {
        flex-direction: column;
        gap: 12px;
    }

    .form-column,
    .footer-column,
    .modal-form-column,
    .customer-selection select {
        width: 100%;
        flex: 1 1 100%;
    }

    /* === Mobile: Form controls === */
    .form-group label {
        font-size: 15px;
        margin-bottom: 6px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 10px 12px;
        min-height: 44px;
    }

    .form-group textarea {
        min-height: 100px;
    }

    .order-buttons {
        flex-direction: row;
        justify-content: flex-start;
    }

    /* === Mobile: Buttons === */
    .action-buttons {
        flex-direction: column;
        gap: 12px;
    }

    /* Na mobile: najprv Uložiť, potom Zrušiť */
    .action-button.save-button {
        order: 1;
    }
    .action-button.cancel-button {
        order: 2;
    }

    /* Sticky mobilná hlavička formulára (Späť + Upraviť) */
    .mobile-header-bar {
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        left: 0;
        z-index: 150;
        display: flex;
        gap: 8px;
        margin-bottom: 8px;
    }

    .mobile-back,
    .mobile-edit {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 12px;
        border-radius: 999px;
        border: 1px solid #ddd;
        background: #f1f3f5;
        color: #333;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }

    .mobile-edit {
        background: var(--wpis-primary-color);
        border-color: var(--wpis-primary-color);
        color: #fff;
    }

    .action-button,
    .add-customer-btn,
    .add-product-btn {
        width: 100%;
        text-align: center;
    }

    .action-button {
        padding: 12px 18px;
        font-size: 16px;
    }

    /* === Mobile: Tables & totals === */
    .total-section .total-row {
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .total-section .total-label {
        flex: 1 1 auto;
        min-width: 0;
        margin-right: 12px;
        text-align: left;
    }

    .total-section .total-value,
    .total-section .total-row > div:last-child {
        flex: 0 0 auto;
        text-align: right;
        white-space: nowrap;
    }

    .total-section .total-input {
        width: 90px;
        text-align: right;
        font-size: 16px;
        padding: 8px;
        box-sizing: border-box;
        margin-right: 4px;
    }

    .total-section .total-row .total-input + span {
        white-space: nowrap;
    }
}
/* ... existing code ... */
/* =========================================================
   📱 MOBILE RESPONSIVE & ADMIN BAR FIX
   Sticky Header (Excel štýl) + Oprava pretekania rodičov
   ========================================================= */

   @media (max-width: 768px) {

    /* 1. DEFINÍCIA OFSETOV PRE WP ADMIN BAR */
    body {
        --wp-bar-offset: 0px;
    }

    body.admin-bar {
        --wp-bar-offset: 32px; 
    }

    @media (max-width: 782px) {
        body.admin-bar {
            --wp-bar-offset: 46px; 
        }
    }

    @media (max-width: 600px) {
        body.admin-bar {
            --wp-bar-offset: 0px; 
        }
    }


    /* 2. OPRAVA PRE RODIČOV (ABY STICKY FUNGOVALO) 
       Sticky nefunguje, ak má rodič overflow: hidden/auto.
       Tento blok sa snaží "oslobodiť" scroll pre bežné WP wrappery.
    */
    html, body, 
    #page, .site, .site-content, .entry-content,
    .invoice-dashboard, .invoice-content, #invoice-content, 
    .wrapper, .main-wrapper {
        overflow-x: clip !important; /* Skryje horizontálne pretekanie (modernejšie ako hidden) */
        overflow-y: visible !important; /* MUSÍ byť visible, aby sticky fungovalo */
    }


    /* 3. STICKY HLAVIČKA (MOBILE HEADER BAR) */
    .mobile-header-bar {
        /* sticky nastavenia nechaj ako doteraz */
        position: -webkit-sticky !important;
        position: sticky !important;
        top: var(--wp-bar-offset) !important;
        left: 0 !important;

        width: 100%;
        height: 60px;

        z-index: 1000 !important;
        background-color: #ffffff;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        border-bottom: 1px solid #eee;

        /* 🔹 nový trojsegmentový layout */
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        padding: 0 15px;
        box-sizing: border-box;

        margin-bottom: 15px;
        margin-top: 0;
    }


    /* 4. OBSAH POD MENU */
    .invoice-dashboard,
    #invoice-content {
        padding-top: 0 !important;
        /* Zabezpečíme, že kontajner je dosť vysoký na scrollovanie */
        min-height: 100vh; 
        display: block !important; /* Flex niekedy robí problémy so sticky v starších prehliadačoch */
    }


    /* 5. ŠTÝLY TLAČIDIEL */
    .mobile-header-bar button {
        height: 40px;
        padding: 0 20px;
        border-radius: 8px;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        border: none;
        transition: transform 0.1s ease;
    }
    
    .mobile-header-bar button:active {
        transform: scale(0.96);
    }

    .mobile-header-bar .mobile-back {
        background-color: #f1f3f5;
        color: #495057;
        grid-column: 1;
        justify-self: start;
    }

    .mobile-header-bar .mobile-edit {
        background-color: var(--wpis-primary-color);
        color: white;
        grid-column: 3;
        justify-self: end;
    }

    .mobile-header-bar .mobile-status {
        background-color: #f1f3f5;
        color: #495057;
        border-radius: 8px;
        border: 1px solid #ddd;
        grid-column: 2;
        justify-self: center;
    }

    .mobile-header-bar .mobile-status.status-unpaid {
        border-color: #dc143c;
        color: #dc143c;
        background-color: rgba(220, 20, 60, 0.08);
    }

    .mobile-header-bar .mobile-status.status-paid {
        border-color: #3cb371;
        color: #3cb371;
        background-color: rgba(60, 179, 113, 0.08);
    }

    .mobile-header-bar .mobile-status.status-partial {
        border-color: #ffb400;
        color: #ffb400;
        background-color: rgba(255, 180, 0, 0.08);
    }

    /* voliteľne ponechaj len z-index + flex zarovnanie, odstráň position */
    .mobile-header-bar .mobile-back,
    .mobile-header-bar .mobile-edit {
        z-index: 1001;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* =============================================================================
   🚀 PERFORMANCE: Form Loading State
   ============================================================================= */

/* Loading overlay pre formulár */
.wpis-form-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 35%;         /* cca horná tretina výšky formulára */
    z-index: 100;
    backdrop-filter: blur(2px);
}

.form-container {
    position: relative;
}

.form-container.is-loading {
    pointer-events: none;
}

.form-container.is-loading .wpis-form-loading {
    display: flex;
}

/* Spinner */
.wpis-form-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--wpis-primary-color);
    border-radius: 50%;
    animation: wpis-form-spin 0.7s linear infinite;
}

@keyframes wpis-form-spin {
    to { transform: rotate(360deg); }
}

/* =============================================================================
   🚀 PERFORMANCE: Optimalizované invoice-item aktívny stav
   ============================================================================= */

/* Okamžitá vizuálna odozva pri kliknutí */
.invoice-item {
    transition: background-color 0.1s ease, border-color 0.1s ease;
    will-change: background-color;
    cursor: pointer;
}

.invoice-item.active {
    background-color: var(--wpis-primary-color-light) !important;
    border-left: 3px solid var(--wpis-primary-color) !important;
    box-shadow: inset 0 0 0 1px rgba(var(--wpis-primary-color-rgb), 0.2);
}

/* Hover efekt (len na desktope) */
@media (hover: hover) {
    .invoice-item:not(.active):hover {
        background-color: #f8fafc;
    }
}

/* Animácia highlight pre form-container */
.form-container.highlight-animate {
    animation: wpis-highlight-pulse 0.3s ease-out;
}

@keyframes wpis-highlight-pulse {
    0% { box-shadow: 0 0 0 0 rgba(var(--wpis-primary-color-rgb), 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(var(--wpis-primary-color-rgb), 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(var(--wpis-primary-color-rgb), 0); }
}