:root {
    /* Основни цветове */
    --primary: #1e3c72;
    --primary-light: #2a5298;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #fd7e14;
    --bg-light: #f8f9fa;
    --border: #dee2e6;
    --text-dark: #212529;
    --text-muted: #6c757d;
    --white: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg-light);
}

.app {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    background: var(--white);
    min-height: 100vh;
    padding-bottom: 80px;
}

/* HEADER */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 20px;
    text-align: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* ФИЛТРИ */
.filters {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: var(--white);
}

.search {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 15px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s;
}

.search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.select {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--white);
    font-size: 14px;
    cursor: pointer;
}

.clear {
    width: 100%;
    padding: 12px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.clear:hover {
    background: var(--border);
}

/* КАРТИЧКИ */
.list {
    padding: 20px;
}

.inventory-grid {
    display: grid;
    gap: 16px;
}

.card {
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    padding: 10px;
}

/* Цветове за наличност */
.card.normal {
    border-left: 5px solid var(--success);
}

.card.low {
    border-left: 5px solid var(--warning);
    background: #fff8f0;
}

.card.out {
    border-left: 5px solid var(--danger);
    background: #fff5f5;
}

.card-content {
    padding: 16px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.card-code {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    margin-bottom: 8px;
}

.card-stock {
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 8px;
}

.card-stock span {
    font-weight: 700;
}

/* Цветове за количеството */
.stock-normal {
    color: var(--success);
}

.stock-low {
    color: var(--warning);
}

.stock-out {
    color: var(--danger);
}

/* Празно състояние */
.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

/* FAB BUTTON */
.fab {
    position: fixed;
    bottom: 85px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 24px;
    font-weight: bold;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.fab:active {
    transform: scale(0.94);
}

/* СТИЛОВЕ ЗА СТРАНИЦАТА НИСКА НАЛИЧНОСТ*/

.card.critical {
    border-left: 5px solid #dc3545;
    background: #fff5f5;
}

.card.critical .qty.critical-qty {
    background: #dc3545;
    color: white;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--white);
    border-radius: 20px;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

.empty-text {
    font-size: 1rem;
    margin-bottom: 8px;
    font-weight: 500;
}

.empty-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/*ДОЛНА НАВИГАЦИЯ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    background-color: #ffffff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

.bottom-nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    text-align: center;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.bottom-nav a.active {
    color: var(--primary);
    background-color: #f1f3f4;
    border-top: 3px solid var(--primary);
}

.bottom-nav a:hover:not(.active) {
    background-color: #e9ecef;
    color: var(--primary-light);
}

.bottom-nav a:active {
    transform: scale(0.95);
}
/* СТИЛОВЕ ЗА ФОРМАТА ЗА РЕГИСТРАЦИЯ */

.form-container {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 60, 114, 0.1);
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

hr {
    margin: 20px 0;
    border: none;
    border-top: 1px solid var(--border);
}

.code-section {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.code-section input {
    flex: 2;
    background: var(--bg-light);
    font-family: monospace;
}

.btn-secondary {
    padding: 12px 20px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    color: var(--primary);
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-secondary:active {
    transform: scale(0.98);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
    background: var(--primary-light);
}

.qrcode-section {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 16px;
}

.qrcode-section img {
    max-width: 200px;
    height: auto;
    margin-top: 10px;
}

.qr-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.qr-buttons button {
    padding: 8px 16px;
    font-size: 14px;
}
/* ============================================
   СТИЛОВЕ ЗА ДЕТАЙЛНАТА СТРАНИЦА (article_detail)
   ============================================ */

.detail-container {
    padding: 20px;
}

.detail-card {
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 20px;
}

.detail-name {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.article-number-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 3px 12px;
    border-radius: 20px;
    margin-bottom: 14px;
    opacity: 0.85;
}

.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 16px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.detail-meta span {
    background: var(--bg-light);
    padding: 4px 12px;
    border-radius: 20px;
}

.stock-section {
    text-align: center;
    margin: 30px 0;
}

.stock-count {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
}

.stock-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.movement-date-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 4px;
}

.movement-date-row label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted, #666);
    white-space: nowrap;
}

.movement-date-row input[type="date"] {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.95rem;
    background: var(--bg-light);
    color: inherit;
    cursor: pointer;
}

.stock-form {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    margin: 20px 0;
}

.stock-form input {
    width: 80px;
    padding: 12px;
    text-align: center;
    font-size: 1.2rem;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.btn-add {
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-subtract {
    background: var(--danger);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:active, .btn-subtract:active {
    transform: scale(0.96);
}

.qr-section {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 16px;
}

.qr-section img {
    max-width: 180px;
    height: auto;
    margin-top: 12px;
}

.qr-download {
    margin-top: 14px;
}

.btn-download {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 10px 22px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}

.btn-download:hover {
    opacity: 0.85;
}

.btn-download:active {
    transform: scale(0.96);
}

.messages {
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
}

.messages li {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.messages .success {
    background: #d4edda;
    color: #155724;
}

.messages .error {
    background: #f8d7da;
    color: #721c24;
}

.back-link {
    display: inline-block;
    margin-top: 20px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.back-link:active {
    opacity: 0.7;
}

/* За десктоп – центриране */
@media (min-width: 768px) {
    .bottom-nav {
        max-width: 1400px;
        left: 50%;
        transform: translateX(-50%);
    }
}

/* RESPONSIVE  */

/* ТЕЛЕФОН */
@media (max-width: 767px) {
    .inventory-grid {
        grid-template-columns: 1fr;
    }
}

/* ТАБЛЕТ */
@media (min-width: 768px) and (max-width: 1023px) {
    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* ДЕСКТОП */
@media (min-width: 1024px) {
    .inventory-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
    
    .card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    }
}

/* ── Card layout (content + footer) ─────────────────────────────────────── */

.card-content {
    padding: 16px 16px 8px;
}

.card-footer {
    padding: 8px 16px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

/* ── Edit button on cards ────────────────────────────────────────────────── */

.btn-edit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.btn-edit:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* ── Card as link (low-stock page) ──────────────────────────────────────── */

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* ── Load-more container ────────────────────────────────────────────────── */

.load-more-container {
    text-align: center;
    padding: 16px 20px 80px;
}

/* ── Detail page actions row ────────────────────────────────────────────── */

.detail-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 0 20px;
    flex-wrap: wrap;
}

/* ── Edit/register form actions row ─────────────────────────────────────── */

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.form-actions .btn-primary {
    margin: 0;
}

.form-actions .btn-secondary {
    text-align: center;
    text-decoration: none;
    display: block;
}

/* ── Read-only input ────────────────────────────────────────────────────── */

.input-readonly {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-family: monospace;
    font-size: 14px;
    background: var(--bg-light);
    color: var(--text-muted);
    cursor: default;
}

/* ЕКСПОРТ */
.export-container {
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.export-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    padding: 40px 30px;
    text-align: center;
    max-width: 480px;
    width: 100%;
}

.export-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.export-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 14px;
}

.export-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 28px;
}

.export-btn {
    display: inline-block;
    text-decoration: none;
    padding: 14px 40px;
    font-size: 1.1rem;
    border-radius: 12px;
    width: auto;
}

.export-note {
    font-size: 0.82rem;
    color: var(--text-muted);
}
/* LOGOUT BUTTON IN NAV */
.nav-logout {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--danger);
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    text-align: center;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.nav-logout:hover {
    background-color: #fff5f5;
    color: #a71d2a;
}

.nav-logout:active {
    transform: scale(0.97);
}

.bottom-nav form {
    flex: 1;
    height: 100%;
    display: flex;
}

/* LOGOUT BUTTON IN NAV */
.nav-logout {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--danger);
    font-size: 14px;
    font-weight: 500;
    flex: 1;
    text-align: center;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.nav-logout:hover {
    background-color: #fff5f5;
    color: #a71d2a;
}

.nav-logout:active {
    transform: scale(0.97);
}

.bottom-nav form {
    flex: 1;
    height: 100%;
    display: flex;
}
