/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #0d6efd, #0b5ed7);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: rgba(255,255,255,0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-right: 0.75rem;
}

.sidebar-title {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Sidebar scrolling + sticky footer */
.sidebar-header,
.sidebar-footer {
    flex: 0 0 auto;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.sidebar-nav::-webkit-scrollbar {
    width: 8px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
    border-radius: 999px;
}

.sidebar-nav a {
    display: block;
    padding: 0.6rem 0.9rem;
    border-radius: 0.75rem;
    margin-bottom: 0.3rem;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.95rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.18);
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.8rem;
}

/* Firmenlogo im Menü */
.sidebar-company-logo {
    background: rgba(255,255,255,0.95);
    border-radius: 0.85rem;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.6rem;
    text-align: center;
}

.company-logo {
    display: block;
    width: 100%;
    height: auto;
    max-width: 160px;
    margin: 0 auto;
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    height: 70px;
    background: #ffffff;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-center {
    justify-self: center;  /* im Grid wirklich in die Mitte */
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}


.top-logo-circle {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #0d6efd;
    margin-bottom: 2px;
}

.top-logo-text {
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #444;
}

/* Login Card */
.login-card {
    max-width: 400px;
    width: 100%;
    border-radius: 1.5rem;
}

.logo-circle {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    background: #0d6efd22;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Content */
.content {
    background: #f5f6fa;
}

/* Mobile: Sidebar is off-canvas (opened via toggle button). */

/* Dashboard & Produkte Erweiterungen */
.low-stock-row {
    padding: 0.35rem 0;
    border-bottom: 1px dashed rgba(0,0,0,0.06);
}
.low-stock-row:last-child {
    border-bottom: none;
}

.movement-list {
    max-height: 420px;
    overflow-y: auto;
}

.movement-row {
    padding: 0.25rem 0.15rem;
}

.scanner-frame {
    width: 100%;
    min-height: 220px;
    border-radius: 0.75rem;
    border: 1px dashed rgba(13, 110, 253, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

/* Extra compact tables/buttons for "viele Spalten" Ansichten */
.table-compact {
    font-size: 0.78rem;
}

/* Extra wide tables (so it looks good on desktop, scrolls on mobile) */
.table-wide {
    min-width: 1400px;
}
.table-compact th,
.table-compact td {
    padding: 0.35rem 0.45rem;
    vertical-align: middle;
    white-space: nowrap;
}

.btn-xs {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.2;
}


/* Products table: fit to screen (no horizontal scroll), wrap content */
.table-products-wrapper {
    overflow-x: hidden;
}

/* Card grids (2 columns on desktop, 1 on mobile) */
.card-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 992px) {
    .card-grid-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Product cards */
.card-modern {
    border-radius: 1.4rem;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 .35rem 1rem rgba(0,0,0,0.06);
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.card-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 .9rem 2.2rem rgba(0,0,0,0.10) !important;
}

.card-modern .card-body {
    padding: 1.15rem 1.25rem;
}

/* Make image buttons behave like block elements so huge intrinsic image sizes
   can never force the layout wider than the card. */
button.js-show-image-card {
    display: block;
    width: 100%;
}

.product-image-wrap {
    width: 100%;
    /* Bigger, "full-bleed" preview inside cards */
    height: clamp(220px, 26vw, 360px);
    max-height: none;
    aspect-ratio: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 1rem;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.06);
}

/* Full-bleed effect (image touches the card edges) */
.card-modern .product-image-wrap {
    margin: -1.15rem -1.25rem 1rem -1.25rem;
    border-radius: 1rem 1rem 0 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
}

.product-image-wrap img {
    /* Show the complete product image without cropping it. */
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain;
    object-position: center;
    display: block;
    padding: 0.75rem;
    background: #fff;
}

/* Some product images might be SVGs; make sure they can't overflow either. */
.product-image-wrap svg {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Image modal: never allow huge images to blow up the page */
#imageModal .modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem;
    overflow: auto;
}

#imageModal .modal-dialog {
    max-width: 980px;
}

#imageModalImg {
    /* Fit into viewport height; always stay contained */
    max-width: 100%;
    max-height: 75vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

.spec-dl {
    margin: 0;
}

.spec-dl dt {
    color: #6c757d;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-size: 0.72rem;
}

.spec-dl dd {
    margin-bottom: 0.45rem;
    font-weight: 600;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.table-products {
    width: 100%;
    table-layout: fixed;
}

.table-products.table-compact th,
.table-products.table-compact td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table-products td .btn,
.table-products td .btn-xs {
    white-space: nowrap;
}

/* On small screens: turn rows into stacked cards */
@media (max-width: 991.98px) {
    .table-products thead {
        display: none;
    }

    .table-products,
    .table-products tbody,
    .table-products tr,
    .table-products td {
        display: block;
        width: 100%;
    }

    .table-products tr {
        background: #fff;
        border: 1px solid rgba(0,0,0,0.06);
        border-radius: 0.9rem;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.75rem;
    }

    .table-products td {
        padding: 0.35rem 0;
        border: none;
        border-bottom: 1px dashed rgba(0,0,0,0.06);
        display: flex;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .table-products td:last-child {
        border-bottom: none;
    }

    .table-products td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        flex: 0 0 48%;
        padding-right: 0.5rem;
        text-align: left;
    }

    .table-products td > * {
        flex: 1 1 auto;
        text-align: right;
    }

    .table-products td[data-label='Aktionen'] {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
    .table-products td[data-label='Aktionen']::before {
        margin-bottom: 0.25rem;
    }
    .table-products td[data-label='Aktionen'] > * {
        text-align: center;
    }
    .table-products td[data-label='Aktionen'] form {
        display: block;
    }
}


/* Sidebar toggle button */
.sidebar-toggle {
    border-color: rgba(255,255,255,0.7);
}

/* Backdrop for sidebar on mobile */
.sidebar-backdrop {
    display: none;
}

/* Responsive layout for tablets & phones */
@media (max-width: 991.98px) {
    /* Prevent background scrolling when the off-canvas menu is open (important on iOS). */
    body.sidebar-open {
        overflow: hidden;
        touch-action: none;
    }

    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        display: flex;
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1030;
        transform: translateX(-100%);
        transition: transform 0.25s ease-in-out;
        max-width: 80%;
        width: 260px;
        height: 100dvh;
        padding-top: calc(1.5rem + env(safe-area-inset-top));
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 1020;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    /* Prevent background scrolling when the menu is open (important on iOS). */
    body.sidebar-open {
        overflow: hidden;
        touch-action: none;
    }

    .topbar {
        padding: 0 1rem;
        grid-template-columns: auto 1fr auto;
    }

    .topbar-center {
        align-items: flex-start;
    }

    .content.container,
    .content.container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Make the toggle button clearly visible on phones */
@media (max-width: 991.98px) {
  .topbar .sidebar-toggle {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
  }
}

@media (max-width: 576px) {
  h1, h2, h3 {
    font-size: 1.1rem;
  }
  .btn {
    width: 100%;
  }
  /* Handy-Ansicht: blauen Punkt in der Topbar ausblenden */
  .top-logo-circle {
    display: none;
  }
}


/* Logo */
.app-logo {
  max-width: 220px;
  width: 70%;
  opacity: 0.9;
}

/* Dashboard fix */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(250px,1fr));
  gap: 1rem;
}

/* Mobile menu button */
.navbar-toggler {
  background-color: #0b5ed7 !important;
  border-color: #0a58ca;
}


/* (legacy menu-toggle removed – we use .sidebar-toggle + body.sidebar-open) */


/* Scanner width fix (match products.php) */
.scanner-card {
  max-width: 420px;
}

.scanner-frame {
  max-width: 100%;
}


/* Transfer layout = products.php width */
.transfer-wrapper {
  max-width: 640px;
}

.transfer-wrapper .form-control,
.transfer-wrapper .form-select,
.transfer-wrapper button {
  width: 100%;
}

.scanner-card {
  margin-left: auto;
  margin-right: auto;
}


/* Scanner page - match products layout */
#reader.scanner-frame {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
