/* ====================================
   Sistema de Almoxarifado Hospitalar
   Estilos Customizados
   ==================================== */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
}

/* Layout Geral */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Navbar Customizada */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.2rem;
}

/* Itens do menu não quebram linha (evita "Inventário de / TI" desalinhado) */
.navbar-nav .nav-link {
    white-space: nowrap;
}
@media (min-width: 992px) {
    .navbar-nav .nav-link {
        padding-left: 0.6rem;
        padding-right: 0.6rem;
        font-size: 0.92rem;
    }
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    margin-bottom: 20px;
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
}

/* Badges */
.badge {
    padding: 0.5em 0.8em;
    font-weight: 500;
}

/* Tabelas */
.table {
    background: white;
}

.table thead {
    background-color: #f8f9fa;
}

.table-hover tbody tr:hover {
    background-color: #f1f3f5;
    cursor: pointer;
}

/* Botões */
.btn {
    border-radius: 6px;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
}

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

.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
}

/* Alertas */
.alert {
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
}

.alert i {
    margin-right: 5px;
}

/* Formulários */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid #dee2e6;
    padding: 0.6rem 0.75rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* Dashboard Cards */
.card.border-primary {
    border-left: 4px solid var(--primary-color) !important;
}

.card.border-warning {
    border-left: 4px solid var(--warning-color) !important;
}

.card.border-danger {
    border-left: 4px solid var(--danger-color) !important;
}

.card.border-info {
    border-left: 4px solid var(--info-color) !important;
}

/* Footer */
.footer {
    background-color: #f8f9fa;
    margin-top: auto;
    border-top: 1px solid #dee2e6;
}

/* Paginação */
.pagination {
    margin-top: 20px;
}

.page-link {
    border-radius: 6px;
    margin: 0 2px;
    color: var(--primary-color);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ====================================
   Responsividade Mobile / PWA
   ==================================== */

/* Safe area para notch/barra home (iOS e Android) */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --bottom-nav-height: 64px;
}

/* Padding body quando bottom-nav ativa */
body.has-bottom-nav {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
}

/* ---- Bottom Navigation Bar ---- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: #fff;
    border-top: 1px solid #dee2e6;
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    display: flex;
    align-items: stretch;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: #6c757d;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 6px 4px;
    transition: color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.bottom-nav-item i {
    font-size: 1.35rem;
    line-height: 1;
}

.bottom-nav-item.active,
.bottom-nav-item:hover {
    color: var(--primary-color);
}

.bottom-nav-item.active i {
    font-weight: bold;
}

.bottom-nav-item .nav-badge {
    position: absolute;
    top: 6px;
    font-size: 0.55rem;
    padding: 2px 5px;
}

/* ---- Tablet / Mobile breakpoints ---- */

@media (max-width: 991.98px) {
    /* Navbar collapse fica abaixo da navbar */
    .navbar-collapse {
        background: inherit;
        padding: 0.5rem 0;
        border-top: 1px solid rgba(255,255,255,.1);
        margin-top: 0.5rem;
    }

    /* Evitar conteúdo sob a bottom nav no mobile */
    main {
        padding-bottom: 0.5rem;
    }
}

@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    h5 {
        font-size: 1rem;
    }

    /* Cards menores no mobile */
    .card-body {
        padding: 0.875rem;
    }

    .card-header {
        padding: 0.6rem 0.875rem;
    }

    /* Botões touch-friendly */
    .btn {
        min-height: 40px;
    }

    .btn-sm {
        min-height: 32px;
        font-size: 0.8rem;
    }

    /* Inputs touch-friendly */
    .form-control,
    .form-select {
        font-size: 16px; /* previne zoom no iOS */
        min-height: 44px;
    }

    /* Tabelas: scroll horizontal + fonte menor */
    .table {
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 0.4rem 0.5rem;
        white-space: nowrap;
    }

    /* Ocultar colunas menos importantes em mobile */
    .table .d-mobile-none {
        display: none !important;
    }

    /* Badges menores */
    .badge {
        font-size: 0.65rem;
        padding: 0.3em 0.5em;
    }

    /* Alertas */
    .alert {
        font-size: 0.875rem;
        padding: 0.75rem 1rem;
    }

    /* Footer compacto */
    .footer {
        padding: 0.75rem 0;
        font-size: 0.8rem;
    }

    /* Paginação touch-friendly */
    .page-link {
        padding: 0.5rem 0.75rem;
        min-width: 44px;
        text-align: center;
    }

    /* Dropdown menu full-width no mobile */
    .dropdown-menu {
        width: 100%;
    }
}

@media (max-width: 575.98px) {
    /* Container sem padding lateral excessivo */
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Cards do dashboard empilham 2 por linha */
    h2 {
        font-size: 1.25rem;
    }

    /* Botão de instalação PWA no mobile */
    #btnInstalarApp {
        bottom: calc(var(--bottom-nav-height) + 12px + var(--safe-area-bottom)) !important;
    }

    /* Ocultar ícone grande em cards pequenos */
    .card-icon-lg {
        font-size: 1.75rem !important;
    }
}

/* ---- PWA Install Banner ---- */
#pwa-install-banner {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 8px);
    left: 12px;
    right: 12px;
    z-index: 1060;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,.18);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideUp 0.3s ease;
    border: 1px solid #dee2e6;
}

#pwa-install-banner img {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
}

#pwa-install-banner .banner-text {
    flex: 1;
    min-width: 0;
}

#pwa-install-banner .banner-text strong {
    display: block;
    font-size: 0.875rem;
    color: #212529;
}

#pwa-install-banner .banner-text small {
    color: #6c757d;
    font-size: 0.75rem;
}

#pwa-install-banner .banner-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

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

/* ---- Modo PWA standalone ---- */
@media (display-mode: standalone) {
    /* Padding top para a status bar no iOS */
    .navbar {
        padding-top: calc(var(--safe-area-top) + 0.5rem);
    }
    .bottom-nav {
        padding-bottom: var(--safe-area-bottom);
    }
}

/* ---- Tablet (769–991px): layout 2 colunas leve ---- */
@media (min-width: 769px) and (max-width: 991.98px) {
    .bottom-nav {
        display: none !important;
    }
    body.has-bottom-nav {
        padding-bottom: 0;
    }
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert {
    animation: fadeIn 0.3s ease;
}

/* Loading */
.spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

/* Customizações específicas */
.text-muted {
    color: #6c757d !important;
}

small, .small {
    font-size: 0.875rem;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* Breadcrumb */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: #6c757d;
}

/* Icons */
i.bi {
    vertical-align: middle;
}

/* Dropdown Menu */
.dropdown-menu {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: 8px;
}

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

/* Modal */
.modal-content {
    border: none;
    border-radius: 10px;
}

.modal-header {
    border-radius: 10px 10px 0 0;
}

/* Status badges personalizados */
.badge.bg-success {
    background-color: #198754 !important;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

.badge.bg-danger {
    background-color: #dc3545 !important;
}

.badge.bg-info {
    background-color: #0dcaf0 !important;
    color: #000 !important;
}

/* Print styles */
@media print {
    .navbar, .footer, .btn, .alert {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}
