/* ver #1.0 wwwroot/css/style.css - Komplett design med tydlig navigering */

:root {
    --primary: #2c7a7b;       /* Teal */
    --primary-light: #e6fffa; /* Ljus Teal för aktiv bakgrund */
    --primary-dark: #234e52;
    --secondary: #2b6cb0;     /* Blå */
    --accent: #ed8936;        /* Orange */
    --bg-color: #f7fafc;      /* Ljusgrå bakgrund */
    --text-color: #2d3748;    /* Mörkgrå text */
    --text-light: #718096;    /* Ljusgrå text */
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --success: #48bb78;
    --danger: #f56565;
    --shadow: 0 2px 4px rgba(0,0,0,0.06);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Tar bort grå ruta vid klick på mobil */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    padding-bottom: 80px; /* Plats för bottenmenyn */
    padding-top: 60px;    /* Plats för header */
}

/* --- HEADER --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--primary);
    color: white;
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}

#husSelect {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9rem;
}

#husSelect option {
    background: white;
    color: black;
}

/* --- MAIN CONTENT --- */
#main-content {
    padding: 0 15px 15px;
    height: calc(100vh - 140px); /* Justera höjd för scroll inuti main */
    overflow-y: auto;
}

#main-content > :first-child:not(.search-container) {
    margin-top: 15px;
}

/* --- BOTTOM NAVIGATION (UPPDATERAD) --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    height: 65px;
    display: flex;
    justify-content: space-around;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    border-top: 1px solid var(--border-color);
}

.nav-item {
    flex: 1;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #a0aec0; /* Inaktiv färg */
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding-bottom: env(safe-area-inset-bottom); /* För iPhone X+ */
    min-width: 0;
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 2px;
    filter: grayscale(100%);
    opacity: 0.7;
    transition: all 0.2s;
}

/* --- AKTIV FLIK STYLING --- */
.nav-item.active {
    color: var(--primary);
    background-color: var(--primary-light); /* Ljus bakgrundsfärg */
    border-top: 3px solid var(--primary);   /* Tydligt streck i toppen */
}

.nav-item.active .nav-icon {
    filter: none; /* Full färg */
    opacity: 1;
    transform: translateY(-2px); /* Litet hopp uppåt */
}

.store-sub-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 65px;
    height: 58px;
    background: white;
    display: flex;
    justify-content: space-around;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
    z-index: 999;
}

.store-sub-nav__item {
    flex: 1;
    border: none;
    background: transparent;
    color: #a0aec0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    min-width: 0;
}

.store-sub-nav__icon {
    font-size: 1.35rem;
    margin-bottom: 2px;
    opacity: 0.75;
    transition: all 0.2s ease;
}

.store-sub-nav__item.active {
    color: var(--primary);
    background-color: var(--primary-light);
    border-top: 3px solid var(--primary);
}

.store-sub-nav__item.active .store-sub-nav__icon {
    opacity: 1;
    transform: translateY(-2px);
}

.store-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 1200;
}

.store-modal.open {
    display: flex;
}

.store-modal__panel {
    width: min(420px, 100%);
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
    padding: 16px;
    display: grid;
    gap: 12px;
}

.store-modal__close {
    border: none;
    background: #edf2f7;
    color: #2d3748;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

/* --- CARDS & LISTOR --- */
.group-header {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-light);
    margin: 20px 0 8px 5px;
    letter-spacing: 1px;
}

.card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.1s;
}

.card:active {
    transform: scale(0.98);
}

.inventory-card:active {
    transform: none;
}

.item-grid {
    display: flex;
    align-items: center;
    gap: 12px;
}

.inventory-card .item-grid {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 42px;
    align-items: center;
}

.item-img-col {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.item-img-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    background: #edf2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.info-col {
    flex: 1;
    min-width: 0; /* För att text-overflow ska funka */
}

.info-line.primary {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.info-line.secondary {
    font-size: 0.85rem;
    color: var(--text-light);
}

.info-line.tertiary {
    font-size: 0.75rem;
    color: #a0aec0;
    margin-top: 2px;
}

/* Lagerstatus indikatorer */
.card.low-stock {
    border-left: 4px solid var(--accent);
}

.card.ok-stock {
    border-left: 4px solid var(--success);
}

/* --- KNAPPAR --- */
.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:active {
    opacity: 0.8;
}

.btn-secondary {
    background: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.scan-action-btn {
    width: 100%;
    min-height: 50px;
    margin: 8px 0 0;
    padding: 13px 16px;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 700;
}

.scan-start-btn {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.scan-danger-btn {
    color: #c53030;
    border-color: #fed7d7;
    background: #fff5f5;
}

.icon-btn {
    padding: 8px;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 50%;
}

.icon-btn:active {
    background: rgba(0,0,0,0.05);
}

/* --- STOCK CONTROLS (+/-) --- */
.stock-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    background: #f7fafc;
    border-radius: 16px;
    padding: 1px 2px;
    border: 1px solid var(--border-color);
}

.inventory-stock-controls {
    box-sizing: border-box;
    display: grid;
    grid-template-rows: 28px 24px 28px;
    justify-items: center;
    align-items: center;
    width: 40px;
    min-width: 40px;
    min-height: 92px;
    gap: 3px;
    padding: 4px 3px;
    flex: 0 0 40px;
}

.stock-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    font-weight: bold;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
}

.btn-minus { background: #fee2e2; color: #c53030; }
.btn-plus { background: #c6f6d5; color: #2f855a; }

.stock-value {
    font-weight: bold;
    font-size: 0.82rem;
    min-width: 22px;
    text-align: center;
    line-height: 1.1;
}

.catalog-card .item-grid {
    align-items: flex-start;
}

.catalog-info .info-line.primary {
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.catalog-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.catalog-actions .icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 1rem;
}

/* --- SÖKFÄLT & FILTER --- */
.search-container {
    background: white;
    padding: 10px 15px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 10px rgba(45,55,72,0.08);
    margin-bottom: 15px;
    margin-left: -15px;
    margin-right: -15px;
    margin-top: 0;
    position: sticky;
    top: 0;
    z-index: 950;
    border-bottom: 1px solid var(--border-color);
}

input[type="search"], input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
}

.store-config-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.store-config-row select {
    flex: 1 1 auto;
    min-width: 0;
}

.store-config-row .btn {
    flex: 0 0 auto;
}

.item-meta-btn {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

/* --- DIALOGER --- */
dialog {
    border: none;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 400px;
}

dialog::backdrop {
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.preview-img {
    display: block;
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    border: 2px solid #edf2f7;
    border-radius: 8px;
    object-fit: cover;
}

.inventory-repeat-notice {
    margin: 0 0 14px;
    padding: 12px;
    border: 2px solid #f6ad55;
    border-radius: 8px;
    background: #fffaf0;
    color: #9c4221;
    font-weight: 700;
    line-height: 1.4;
}

.inventory-location-notice {
    margin: 0 0 14px;
    padding: 12px;
    border: 1px solid #63b3ed;
    border-radius: 8px;
    background: #ebf8ff;
    color: #2a4365;
    font-weight: 650;
    line-height: 1.4;
    white-space: pre-line;
}

.inventory-location-notice[data-level="warning"] {
    border-color: #f6ad55;
    background: #fffaf0;
    color: #9c4221;
}

/* --- SCANNER VIEW --- */
#scan-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

#scan-view.hidden {
    display: none;
}

.scan-header {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    background: rgba(0,0,0,0.5);
    z-index: 2002;
}

#reader-wrapper {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

#interactive video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-laser {
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 2px;
    background: rgba(255, 0, 0, 0.6);
    box-shadow: 0 0 4px red;
    z-index: 2001;
}

.scan-controls {
    background: rgba(20,20,20,0.9);
    padding: 20px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    color: white;
}

.camera-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
}

.zoom-slider {
    flex: 1;
    min-width: 130px;
    accent-color: var(--primary);
}

.camera-status {
    flex-basis: 100%;
    color: #cbd5e1;
    font-size: 0.78rem;
    line-height: 1.3;
}

.camera-status[data-level="ok"] { color: #86efac; }
.camera-status[data-level="warning"] { color: #fcd34d; }

.refocus-btn {
    min-height: 40px;
    padding: 7px 12px;
    border: 1px solid #67e8f9;
    border-radius: 10px;
    background: #164e63;
    color: white;
    font-weight: 700;
    white-space: nowrap;
}

.refocus-btn:disabled {
    opacity: 0.65;
}

/* Mode buttons i scannern */
.mode-group {
    display: flex;
    background: #333;
    border-radius: 8px;
    padding: 4px;
    margin-top: 10px;
}

.mode-btn {
    flex: 1;
    background: transparent;
    color: #aaa;
    border: none;
    padding: 10px;
    font-size: 0.9rem;
    border-radius: 6px;
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    font-weight: bold;
}

/* --- TOAST --- */
#toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 3000;
    white-space: nowrap;
}

#toast.show {
    opacity: 1;
}

/* --- FAB (Flytande knapp) --- */
#scan-fab {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 1500;
    cursor: pointer;
    user-select: none;
    touch-action: none; /* Viktigt för drag-funktionen */
}

/* Spinner */
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.quickstart-dialog {
    max-width: 560px;
}

.quickstart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.quickstart-kicker {
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.quickstart-head h2 {
    margin: 2px 0 0;
}

.quickstart-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: white;
    color: var(--text-color);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.quickstart-steps {
    display: grid;
    gap: 10px;
}

.quickstart-step {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #f8fafc;
}

.quickstart-step-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    font-size: 1.25rem;
}

.quickstart-step h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.quickstart-step p {
    margin: 0;
    color: var(--text-light);
    line-height: 1.45;
}

.quickstart-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.quickstart-user-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #4a5568;
}

.quickstart-user-toggle input {
    width: 16px;
    height: 16px;
}

.menu-view {
    padding: 15px 0 8px;
}

.menu-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.menu-hero h2 {
    margin: 0;
    font-size: 1.35rem;
}

.menu-hero p {
    margin: 4px 0 0;
    color: var(--text-light);
}

.menu-hero img {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    flex: 0 0 auto;
}

.menu-kicker {
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.menu-tools {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.menu-tool {
    min-height: 108px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    color: inherit;
    text-decoration: none;
    box-shadow: var(--shadow);
    display: grid;
    gap: 5px;
    align-content: start;
}

.menu-tool span {
    font-size: 1.35rem;
}

.menu-tool strong {
    color: var(--primary-dark);
}

.menu-tool small {
    color: var(--text-light);
    line-height: 1.3;
}

.menu-tool--disabled {
    opacity: 0.48;
    pointer-events: none;
}

.menu-panel {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.menu-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.menu-panel h3 {
    margin: 2px 0 4px;
    font-size: 1.05rem;
}

.menu-panel p {
    margin: 0;
    color: var(--text-light);
    line-height: 1.45;
}

.menu-muted {
    margin-top: 10px !important;
    font-size: 0.88rem;
}

.license-pill {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 800;
    background: #fef3c7;
    color: #92400e;
}

.license-pill--ok {
    background: #dcfce7;
    color: #166534;
}

.license-pill--warn {
    background: #fee2e2;
    color: #991b1b;
}

.license-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.license-form label {
    color: var(--text-light);
    font-size: 0.82rem;
    font-weight: 700;
}

.license-form label input,
.license-form label select {
    margin-top: 4px;
    font-weight: 500;
}

.license-form .btn {
    align-self: end;
    min-height: 42px;
}

.license-usage {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.license-usage > div {
    display: grid;
    gap: 3px;
    padding: 11px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.license-usage strong {
    color: #0f172a;
    font-size: 1rem;
}

.license-usage span {
    color: var(--text-light);
    font-size: 0.78rem;
}

.license-table-wrap {
    margin-top: 14px;
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.license-table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    background: white;
    font-size: 0.86rem;
}

.license-table th,
.license-table td {
    padding: 9px 11px;
    border-bottom: 1px solid #edf2f7;
    text-align: center;
}

.license-table th:first-child,
.license-table td:first-child {
    text-align: left;
}

.license-table th {
    color: #475569;
    background: #f8fafc;
}

.license-table .is-current {
    background: #ecfdf5;
    color: #166534;
    font-weight: 750;
}

.license-table tbody tr:last-child td {
    border-bottom: 0;
}

.premium-lock-card {
    display: grid;
    gap: 9px;
    padding: 18px;
    border: 1px solid #fde68a;
    border-radius: 12px;
    background: #fffbeb;
    color: #78350f;
}

.premium-lock-card p {
    margin: 0;
    color: #92400e;
    line-height: 1.5;
}

.license-limit-note {
    margin-top: 8px;
    padding: 9px 11px;
    border-radius: 9px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.84rem;
}

@media (max-width: 520px) {
    .quickstart-actions {
        flex-direction: column;
    }

    .license-usage {
        grid-template-columns: 1fr;
    }
}
