/* ADIMS Custom Styles */

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Card hover effects */
.item-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.item-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Thumbnail styles */
.thumbnail-container {
    position: relative;
    padding-top: 100%;
    background-color: #f8f9fa;
    overflow: hidden;
}

.thumbnail-container img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumbnail-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 3rem;
}

/* Image gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    padding-top: 100%;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
}

.gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item.is-thumbnail {
    border: 3px solid #0d6efd;
}

.gallery-item .thumbnail-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: #0d6efd;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.gallery-item .image-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.gallery-item:hover .image-actions {
    opacity: 1;
}

/* Stats cards */
.stat-card {
    border-left: 4px solid;
}

.stat-card.items {
    border-left-color: #0d6efd;
}

.stat-card.stock {
    border-left-color: #198754;
}

.stat-card.value {
    border-left-color: #ffc107;
}

.stat-card.categories {
    border-left-color: #6f42c1;
}

/* Category badges */
.category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: #e9ecef;
    border-radius: 1rem;
    font-size: 0.875rem;
}

/* Stock indicator */
.stock-low {
    color: #dc3545;
}

.stock-medium {
    color: #ffc107;
}

.stock-good {
    color: #198754;
}

/* Form improvements */
.form-label.required::after {
    content: " *";
    color: #dc3545;
}

/* Price formatting */
.price {
    font-weight: 600;
    color: #198754;
}

/* Image upload dropzone */
.upload-dropzone {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: #0d6efd;
    background-color: #f8f9fa;
}

.upload-dropzone i {
    font-size: 2rem;
    color: #adb5bd;
    display: block;
    margin-bottom: 0.5rem;
}

/* Modal image preview */
.modal-image-preview {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
}

/* Table improvements */
.table-hover tbody tr {
    cursor: pointer;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.empty-state > i {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.empty-state .btn i {
    font-size: inherit;
    margin-bottom: 0;
}

/* Loading spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Autocomplete styles */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    display: none;
}

.autocomplete-results.show {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.15s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background-color: #f8f9fa;
}

.autocomplete-item.text-muted,
.autocomplete-item.text-danger {
    cursor: default;
}

.autocomplete-item.text-muted:hover,
.autocomplete-item.text-danger:hover {
    background-color: transparent;
}

.autocomplete-clear-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    background: #f8f9fa;
    color: #6c757d;
    cursor: pointer;
    z-index: 10;
    font-size: 1rem;
    line-height: 1;
}

.autocomplete-clear-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.autocomplete-wrapper .form-control {
    padding-right: 2.5rem;
}

/* Print styles */
@media print {
    /* Hide elements that shouldn't print */
    .no-print,
    nav.navbar,
    .breadcrumb,
    .btn,
    button,
    .alert,
    footer {
        display: none !important;
    }

    /* Remove body padding/margins and set base font size */
    body {
        padding: 0 !important;
        margin: 0 !important;
        font-size: 10pt !important;
        line-height: 1.3 !important;
    }

    main.container {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    /* Remove all default spacing */
    * {
        margin: 0 !important;
    }

    /* Re-add minimal necessary spacing */
    .card {
        margin-bottom: 0.5rem !important;
    }

    .card-header {
        padding: 0.25rem 0.5rem !important;
    }

    .card-body {
        padding: 0.5rem !important;
    }

    table, th, td {
        padding: 0.25rem 0.5rem !important;
    }

    h1 {
        margin-bottom: 0.25rem !important;
    }

    body::before {
        margin-bottom: 0.5rem !important;
        padding-bottom: 0.25rem !important;
    }

    /* Compact heading sizes */
    h1 {
        font-size: 16pt !important;
    }

    h2, h3, h4, h5, h6 {
        font-size: 11pt !important;
    }

    .fs-5 {
        font-size: 11pt !important;
    }

    /* Ensure proper page breaks */
    .card {
        page-break-inside: avoid;
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
    }

    /* Card header styling */
    .card-header {
        background-color: #f8f9fa !important;
        border-bottom: 1px solid #dee2e6 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Ensure table borders print with compact spacing */
    table {
        border-collapse: collapse !important;
        font-size: 9pt !important;
    }

    table, th, td {
        border: 1px solid #dee2e6 !important;
    }

    thead th {
        background-color: #f8f9fa !important;
        font-weight: bold !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    tfoot td {
        font-weight: bold !important;
    }

    dt {
        font-weight: bold !important;
        font-size: 9pt !important;
    }

    dd {
        font-size: 9pt !important;
    }

    /* Make links print as text */
    a {
        color: #000 !important;
        text-decoration: none !important;
    }

    a[href]:after {
        content: none !important;
    }

    /* Adjust layout for print */
    .row {
        display: block !important;
    }

    .col-lg-8, .col-lg-4 {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Ensure colors print */
    .text-danger, .text-success, .text-muted {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .text-muted {
        color: #666 !important;
    }

    /* Add header for print */
    body::before {
        content: "Artisan District Inventory Management System";
        display: block;
        font-size: 14pt !important;
        font-weight: bold;
        text-align: center;
        margin-bottom: 0.5rem !important;
        padding-bottom: 0.25rem !important;
        border-bottom: 2px solid #000;
    }

    /* Optimize text for print */
    h1, h2, h3, h4, h5, h6 {
        color: #000 !important;
    }

    /* Compact thumbnail images */
    img {
        max-width: 30px !important;
        max-height: 30px !important;
        page-break-inside: avoid;
    }

    /* Smaller badges and icons */
    .badge {
        font-size: 8pt !important;
        padding: 0.1rem 0.3rem !important;
    }

    .bi {
        font-size: 10pt !important;
    }

    /* Compact small text */
    small, .small {
        font-size: 8pt !important;
    }
}
