/* InventoX - Custom Styles */

/* Smooth transitions */
* {
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Scanner video styling */
#scannerVideo {
    object-fit: cover;
    max-height: 400px;
}

/* Form inputs focus */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    ring: 2px;
}

/* Loading spinner */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Card hover effects */
.bg-white:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Desktop tab navigation — sem scroll horizontal */
@media (min-width: 769px) {
    .desktop-tab-navigation .tab-navigation {
        overflow-x: hidden;
        flex-wrap: wrap;
    }

    .desktop-tab-navigation .tab-btn {
        flex: 0 1 auto;
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .tab-btn {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
    
    /* Toast notifications for mobile */
    .toast {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        transform: translateY(-100%) !important;
    }
    
    .toast.show {
        transform: translateY(0) !important;
    }
    
    /* Larger touch targets for mobile */
    button, input, select, textarea {
        min-height: 44px;
    }
    
    /* Scanner video full width on mobile */
    #scannerVideo {
        width: 100% !important;
        height: auto !important;
        max-height: 300px;
        object-fit: cover;
    }
    
    /* Mobile-specific scanner placeholder */
    #scannerPlaceholder {
        min-height: 200px;
    }
    
    /* Prevent zoom on input focus (Android) */
    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    select,
    textarea {
        font-size: 16px;
    }
    /* Mobile pagination */
    .mobile-pagination {
        max-width: 100%;
        overflow: hidden;
    }

    .mobile-pagination button {
        touch-action: manipulation;
    }
}

@media (max-width: 768px) {
    #keyboardHints {
        display: none !important;
    }
}

/* Mobile bottom navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.25rem 0.5rem calc(0.25rem + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    align-items: stretch;
}

@media (max-width: 768px) {
    .mobile-bottom-nav:not(.hidden) {
        display: flex;
    }
}

.mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    min-height: 56px;
    min-width: 0;
    padding: 0.375rem 0.25rem;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 0.65rem;
    font-weight: 500;
    border-radius: 0.5rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Price lookup tab */
.price-lookup-card {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.price-scanner-video-wrapper {
    min-height: 12rem;
}

.price-result-card {
    animation: priceResultIn 0.25s ease-out;
}

.price-result-description-hidden {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

@keyframes priceResultIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .mobile-prices-tab {
        padding-bottom: 5rem;
    }

    .price-result-price {
        font-size: 2rem;
    }
}

.mobile-nav-btn.active {
    color: #2563eb;
    background: #eff6ff;
}

.mobile-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.mobile-nav-label {
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.mobile-more-menu {
    position: fixed;
    inset: 0;
    z-index: 9500;
}

.mobile-more-menu.hidden {
    display: none;
}

.mobile-more-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.mobile-more-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 1rem 1rem 0 0;
    padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
    max-height: 70vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.mobile-more-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.mobile-more-close {
    min-width: 44px;
    min-height: 44px;
    border: none;
    background: #f3f4f6;
    border-radius: 9999px;
    font-size: 1.125rem;
    color: #374151;
}

.mobile-more-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-more-item {
    width: 100%;
    text-align: left;
    padding: 0.875rem 1rem;
    min-height: 48px;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #f9fafb;
    color: #1f2937;
    font-size: 1rem;
    font-weight: 500;
    touch-action: manipulation;
}

.mobile-more-item:active {
    background: #eff6ff;
    border-color: #93c5fd;
}

/* ===================================
   Fase 3 — Scanner mobile optimizado
   =================================== */

.mobile-session-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    color: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.mobile-session-banner-text {
    flex: 1;
    min-width: 0;
    font-size: 0.875rem;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-session-label {
    opacity: 0.85;
    font-weight: 500;
}

.mobile-session-sep {
    margin: 0 0.25rem;
    opacity: 0.7;
}

.mobile-session-change {
    flex-shrink: 0;
    min-height: 44px;
    min-width: 44px;
    padding: 0.375rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    touch-action: manipulation;
}

.mobile-session-banner--empty {
    background: linear-gradient(135deg, #92400e 0%, #d97706 100%);
}

.scanner-mobile-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.scanner-video-wrapper {
    position: relative;
}

.scanner-torch-overlay {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.scanner-torch-overlay.scanner-torch-active {
    background: rgba(251, 191, 36, 0.95);
    border-color: #fff;
    color: #1f2937;
}

.scanner-torch-bar.scanner-torch-active {
    background: #d97706 !important;
}

@media (min-width: 769px) {
    .scanner-torch-bar:not(.hidden) {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    .mobile-session-banner:not(.hidden) {
        display: flex;
    }

    .mobile-scanner-tab .scanner-main-card {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .mobile-scanner-tab .scanner-desktop-title {
        display: none;
    }

    .mobile-scanner-tab .scanner-settings-panel {
        display: none;
    }

    .mobile-scanner-tab .scanner-main-inner {
        display: flex;
        flex-direction: column;
    }

    .mobile-scanner-tab .scanner-manual-input {
        order: 1;
    }

    .mobile-scanner-tab .scanner-video-container {
        order: 2;
    }

    .mobile-scanner-tab .scanner-action-bar {
        order: 3;
        position: sticky;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        z-index: 40;
        background: #fff;
        padding: 0.5rem 0;
        margin-bottom: 0 !important;
        border-top: 1px solid #e5e7eb;
    }

    body.scanner-item-modal-open .mobile-scanner-tab .scanner-action-bar {
        display: none !important;
    }

    #itemInfoCard:not(.hidden) {
        z-index: 9600 !important;
    }

    #itemInfoCard .flex.justify-end.space-x-2 {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    #itemInfoCard .flex.justify-end.space-x-2 > button,
    #itemInfoCard #editItemFromScanner {
        width: 100%;
        min-height: 48px;
        margin-top: 0 !important;
    }

    .mobile-scanner-tab #itemPreview,
    .mobile-scanner-tab #scannerPlaceholder,
    .mobile-scanner-tab #scannerStatus {
        order: 4;
    }

    .mobile-scanner-tab .scanner-session-picker,
    .mobile-scanner-tab .scanner-session-clear {
        display: none;
    }

    .mobile-scanner-tab .scanner-mobile-btn,
    .mobile-scanner-tab #processManualBtn {
        min-height: 48px;
        font-size: 0.9375rem;
    }

    .mobile-scanner-tab .scanner-action-bar .scanner-mobile-btn {
        flex: 1 1 calc(50% - 0.25rem);
    }

    .mobile-scanner-tab #manualBarcode {
        font-size: 16px;
        min-height: 48px;
    }

    .mobile-scanner-tab .scanner-video-wrapper {
        min-height: 55vh;
        max-height: 70vh;
        display: flex;
        align-items: center;
        background: #111827;
        border-radius: 0.75rem;
        overflow: hidden;
    }

    .mobile-scanner-tab #scannerVideo {
        width: 100% !important;
        max-width: none !important;
        height: 70vh;
        max-height: 70vh;
        object-fit: cover;
        border: none;
        border-radius: 0;
        margin: 0;
    }

    .mobile-scanner-tab .scanner-torch-bar {
        display: none !important;
    }

    .mobile-scanner-tab #scanOverlay .w-48 {
        width: min(75vw, 280px);
        height: min(45vw, 160px);
    }

    .mobile-scanner-tab #scannerPlaceholder {
        padding: 1.5rem 1rem;
        order: 2;
    }

    .mobile-scanner-tab .scanner-secondary-panel {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .mobile-scanner-tab .scanner-secondary-panel h3 {
        font-size: 1rem;
    }

    .mobile-scanner-tab #scanHistory {
        max-height: 8rem;
    }

    .mobile-scanner-tab #itemPreview .flex {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .mobile-scanner-tab #itemPreview button {
        min-height: 48px;
        flex: 1;
    }
}

/* ===================================
   Fase 4 — Cards de artigos mobile
   =================================== */

.item-card {
    transition: box-shadow 0.15s ease;
}

.item-card-title {
    line-height: 1.25;
    word-break: break-word;
}

.item-card-barcode {
    word-break: break-all;
}

.item-card-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    .mobile-items-tab > .bg-white {
        padding: 0.75rem;
    }

    .mobile-items-tab .items-tab-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .mobile-items-tab .items-tab-actions {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    .mobile-items-tab .items-tab-btn {
        width: 100%;
        min-height: 48px;
        font-size: 0.9375rem;
    }

    .mobile-items-tab .items-search-input {
        font-size: 16px;
        min-height: 48px;
    }

    .mobile-items-tab .items-list {
        gap: 0.625rem;
    }

    .mobile-items-tab .item-card {
        padding: 0.875rem;
    }

    .mobile-items-tab .item-card-header {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.375rem;
    }

    .mobile-items-tab .item-card-meta {
        flex-direction: column;
        gap: 0.25rem;
    }

    .mobile-items-tab .item-card-actions {
        flex-direction: row;
        gap: 0.5rem;
        margin-top: 0.75rem;
        padding-top: 0.75rem;
        border-top: 1px solid rgba(0, 0, 0, 0.06);
    }

    .mobile-items-tab .item-card--low .item-card-actions {
        border-top-color: rgba(239, 68, 68, 0.2);
    }

    .mobile-items-tab .item-card-btn {
        flex: 1;
        min-height: 48px;
        font-size: 0.9375rem;
        padding: 0.625rem 0.75rem;
    }

    .mobile-items-tab .item-card-desc {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* ===================================
   Fase 5 — Dashboard mobile simplificado
   =================================== */

@media (max-width: 768px) {
    .mobile-dashboard-tab .dashboard-interactive-controls {
        display: none;
    }

    .mobile-dashboard-tab #smartAlerts {
        display: none !important;
    }

    .mobile-dashboard-tab #widgetsGrid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .mobile-dashboard-tab #widgetsGrid .widget:not([data-widget="kpi-metrics"]) {
        display: none;
    }

    .mobile-dashboard-tab [data-widget="kpi-metrics"] .widget-header {
        padding: 0.75rem 1rem;
    }

    .mobile-dashboard-tab [data-widget="kpi-metrics"] .widget-content {
        padding: 0.75rem 1rem 1rem;
    }

    .mobile-dashboard-tab .dashboard-kpi-grid {
        gap: 0.625rem;
    }

    .mobile-dashboard-tab .dashboard-kpi-item {
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 0.75rem;
        padding: 0.875rem 0.5rem;
    }

    .mobile-dashboard-tab .dashboard-kpi-item .text-2xl {
        font-size: 1.375rem;
    }

    .mobile-dashboard-tab .dashboard-kpi-stock-low {
        display: none;
    }

    .mobile-dashboard-tab .dashboard-kpi-counts-today {
        display: block !important;
    }
}

/* iOS specific styles */
.ios-device {
    -webkit-overflow-scrolling: touch;
}

.ios-device input[type="text"],
.ios-device input[type="number"],
.ios-device input[type="password"],
.ios-device input[type="email"] {
    -webkit-appearance: none;
    border-radius: 8px;
}

/* Android specific styles */
.android-device input {
    font-size: 16px; /* Prevent zoom on focus */
}

/* Camera permission indicators */
.camera-ready {
    border: 2px solid #10B981 !important;
    background-color: #F0FDF4 !important;
}

.camera-denied {
    border: 2px solid #EF4444 !important;
    background-color: #FEF2F2 !important;
}

/* Mobile device indicators */
.mobile-device .scanner-container,
.ios-device .scanner-container,
.android-device .scanner-container {
    border-radius: 12px;
    overflow: hidden;
}

/* Vibration feedback for mobile interactions */
@media (hover: none) and (pointer: coarse) {
    button:active {
        transform: scale(0.98);
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
}

