/**
 * App Styles
 * Custom CSS for shopping list application
 */

/* Global Styles */
body {
    min-height: 100vh;
    background-color: var(--bs-body-bg);
}

/* Purchased Items Styling (T040) */
.item-purchased .item-name {
    text-decoration: line-through;
    color: #6c757d;
}

.item-purchased {
    opacity: 0.7;
    background-color: var(--bs-secondary-bg);
}

/* Hidden Items Styling */
.item-hidden {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
}

/* Item Row */
.item-row {
    padding: 12px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.item-row:hover {
    background-color: var(--bs-secondary-bg);
}

.item-row.dragging {
    opacity: 0.5;
    background-color: var(--bs-tertiary-bg);
}

/* Drag Handle */
.drag-handle {
    cursor: grab;
    color: #6c757d;
    font-size: 1.2em;
    user-select: none;
    touch-action: none;
}

.drag-handle:active {
    cursor: grabbing;
}

.item-row.dragging .drag-handle {
    cursor: grabbing;
}

/* Item Name */
.item-name {
    cursor: text;
    padding: 2px 4px;
    min-width: 200px;
}

/* Shop Section */
.shop-section {
    border: 1px solid #dee2e6;
}

.shop-section .card-header {
    background-color: var(--bs-secondary-bg);
    border-bottom: 2px solid var(--bs-border-color);
}

.shop-section .list-group-item {
    padding: 0.75rem 1rem;
    transition: background-color 0.2s;
}

.shop-section .list-group-item:hover {
    background-color: var(--bs-secondary-bg);
}

/* Shop Cards */
.shop-card {
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.shop-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Loading Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Offline Indicator */
.offline-badge {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 9999;
}

/* Photo Thumbnail (T058) */
.item-thumbnail {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 2px solid #dee2e6;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.item-thumbnail:hover {
    border-color: #007bff;
    transform: scale(1.05);
}

/* Camera Preview */
.camera-preview {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.camera-preview video {
    width: 100%;
    height: auto;
    border-radius: 8px;
    background-color: #000;
}

/* Photo Modal */
.modal-lg .modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Ensure modals are properly centered */
.modal-dialog {
    margin: 1.75rem auto !important;
}

.modal-dialog-centered {
    display: flex !important;
    align-items: center !important;
    min-height: calc(100% - 3.5rem) !important;
}

/* Responsive */
@media (max-width: 576px) {
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .shop-card {
        margin-bottom: 12px;
    }
    
    .item-thumbnail {
        width: 40px;
        height: 40px;
    }
}

/* Loading Spinner (T094) */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.spinner-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.3rem;
}

.loading-inline {
    display: inline-block;
    margin-left: 8px;
}

/* Offline Indicator (T098) */
#offline-indicator {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ffc107;
    color: #000;
    padding: 8px 20px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 9998;
    font-weight: 500;
    display: none;
}

#offline-indicator.show {
    display: block;
}

/* Storage Warning (T095) */
.storage-warning {
    position: fixed;
    bottom: 20px;
    left: 20px;
    max-width: 300px;
    z-index: 9000;
}

/* Responsive Mobile Breakpoints (T096) */
@media (max-width: 768px) {
    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
}

@media (max-width: 480px) {
    h1, h2 {
        font-size: 1.5rem;
    }
    
    .card-title {
        font-size: 1.1rem;
    }
    
    .shop-card {
        padding: 12px;
    }
    
    .item-row {
        padding: 8px;
        font-size: 0.9rem;
    }
}

@media (max-width: 320px) {
    body {
        font-size: 0.875rem;
    }
    
    .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .item-thumbnail {
        width: 30px;
        height: 30px;
    }
}

/* Accessibility improvements */
.btn:focus, .form-control:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Bottom Menu */
.bottom-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bs-card-bg);
    border-top: 2px solid var(--bs-border-color);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.bottom-menu .btn-link {
    color: #007bff;
    text-decoration: none;
    padding: 0.5rem;
}

.bottom-menu .btn-link:hover {
    color: #0056b3;
}

.bottom-menu #refresh-status-bottom {
    font-size: 0.85rem;
}

/* Offcanvas bottom drawer */
.offcanvas-bottom {
    height: auto;
    max-height: 50vh;
}

/* Print styles */
@media print {
    .btn, .drag-handle, .modal, .nav, #offline-indicator {
        display: none !important;
    }
    
    .item-row {
        break-inside: avoid;
    }
}
