/* ============================================================
   🎨 CSS GLOBAL OTIMIZADO - DeliverXai
   ============================================================ */

/* ============================================================
   1. VARIÁVEIS E RESET
   ============================================================ */
:root {
    /* 🎨 Paleta principal */
    --primary-dark: #0f2a38;
    --primary: #1A3B4F;
    --primary-light: #2c4d63;

    /* 🚀 Cores da marca */
    --accent-green: #00b44b;
    --accent-orange: #ff7b00;
    --accent-yellow: #ffd43b;
    --accent-hover: #48cae4;

    /* ✅ Estados */
    --success: #06d6a0;
    --warning: #ffb703;
    --danger: #e63946;

    /* 🖋️ Texto */
    --text-primary: #f8f9fa;
    --text-secondary: #e9ecef;
    --text-muted: #adb5bd;

    /* 🧱 Fundo */
    --bg-primary: #0a1a24;
    --bg-card: #0f2a38;
    --bg-light: #f1f5f9;

    /* 🧩 Bordas e sombras */
    --border: #2c4d63;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);

    /* 📐 Layout */
    --navbar-height: 80px;
    --container-width: 1200px;
    --radius: 8px;
    --transition: all 0.3s ease;

    /* ============================================================
       📐 Z-INDEX HIERARQUIA (do menor para o maior)
       ============================================================ */
    --z-base: 1;              /* Elementos base */
    --z-content: 10;          /* Conteúdo padrão */
    --z-dropdown: 100;        /* Dropdowns */
    --z-sticky: 200;          /* Elementos sticky */
    --z-navbar: 1000;         /* Navbar */
    --z-overlay: 999;        /* Overlay do menu */
    --z-menu: 1050;           /* Menu mobile (acima do overlay) */
    --z-modal: 1060;          /* Modals */
    --z-tooltip: 1070;        /* Tooltips */
    --z-toast: 999999;        /* Toast (sempre acima de tudo) */
    --z-toggler: 1100;        /* Botão toggler do menu */
}

/* ============================================================
   2. RESET
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: var(--z-base);
}

/* ============================================================
   3. ELEMENTOS BASE
   ============================================================ */
a {
    color: var(--accent-orange);
    text-decoration: none;
    transition: var(--transition);
}
a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

ul,
ol {
    list-style: none;
}

label {
    color: var(--text-primary);
}

/* ============================================================
   4. TIPOGRAFIA
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}
h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.text-muted { color: var(--text-muted); }
.text-light { color: var(--text-primary); }
.text-center { text-align: center; }
.text-end { text-align: right; }

/* ============================================================
   5. LAYOUT
   ============================================================ */
.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.5rem;
}

main {
    flex: 1;
    padding: 2rem 0;
    position: relative;
    z-index: var(--z-content);
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -0.75rem;
}
.col {
    flex: 1;
    padding: 0 0.75rem;
}
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333%; max-width: 33.333%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* ============================================================
   6. CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    z-index: var(--z-base);
}
.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}
.card-text {
    color: var(--text-secondary);
}

/* ============================================================
   7. BOTÕES
   ============================================================ */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 1rem;
    position: relative;
    z-index: var(--z-base);
}
.btn-primary {
    background: var(--accent-orange);
    color: var(--text-primary);
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-secondary {
    background: var(--primary-light);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-success {
    background: var(--success);
    color: var(--text-primary);
}
.btn-success:hover {
    filter: brightness(0.9);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-danger {
    background: var(--danger);
    color: var(--text-primary);
}
.btn-danger:hover {
    filter: brightness(0.9);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-outline-light {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--text-primary);
}
.btn-outline-light:hover {
    background: var(--text-primary);
    color: var(--bg-primary);
    text-decoration: none;
}

.btn-lg { padding: 0.8rem 2rem; font-size: 1.1rem; }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.875rem; }
.btn-block { display: block; width: 100%; }

/* ============================================================
   8. FORMULÁRIOS
   ============================================================ */
.form-group {
    margin-bottom: 1.25rem;
}
.form-label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    font-size: 1rem;
    position: relative;
    z-index: var(--z-base);
}
.form-control:focus {
    outline: none;
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px rgba(255, 123, 0, 0.2);
}
.form-control::placeholder {
    color: var(--text-muted);
}
.form-control.is-invalid {
    border-color: var(--danger);
}
.form-control:disabled {
    color: var(--text-muted);
}

.invalid-feedback {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 0.2rem;
}

/* ============================================================
   9. BADGES E ALERTAS
   ============================================================ */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    z-index: var(--z-base);
}
.badge-success { background: var(--success); color: var(--bg-primary); }
.badge-warning { background: var(--warning); color: var(--bg-primary); }
.badge-danger { background: var(--danger); color: var(--text-primary); }
.badge-info { background: var(--accent-hover); color: var(--bg-primary); }

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-left: 4px solid;
    position: relative;
    z-index: var(--z-base);
}
.alert-success {
    background: rgba(6, 214, 160, 0.15);
    border-color: var(--success);
    color: var(--success);
}
.alert-danger {
    background: rgba(230, 57, 70, 0.15);
    border-color: var(--danger);
    color: var(--danger);
}
.alert-warning {
    background: rgba(255, 183, 3, 0.15);
    border-color: var(--warning);
    color: var(--warning);
}
.alert-info {
    background: rgba(72, 202, 228, 0.15);
    border-color: var(--accent-hover);
    color: var(--accent-hover);
}

/* ============================================================
   10. PRODUCT CARD
   ============================================================ */
.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    z-index: var(--z-base);
}
.product-card:hover {
    transform: scale(1.01);
    border-color: var(--accent-orange);
}
.product-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}
.product-card .body {
    padding: 1rem;
}
.product-card .price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-orange);
}
.product-card .old-price {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-decoration: line-through;
    margin-left: 0.5rem;
}

/* ============================================================
   11. NAVBAR
   ============================================================ */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    padding: 0 1.5rem;
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--accent-orange);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: var(--z-navbar);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary) !important;
    position: relative;
    z-index: var(--z-navbar);
}
.navbar-brand img {
    height: 50px;
    width: 50px;
    object-fit: contain;
    border-radius: 50%;
}
.navbar-brand span {
    color: var(--accent-orange);
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: var(--z-navbar);
}
.navbar-nav a {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
    font-weight: 500;
}
.navbar-nav a:hover {
    background: var(--accent-orange);
    color: var(--text-primary);
    text-decoration: none;
}
.navbar-nav .active {
    background: var(--accent-orange);
    color: var(--text-primary);
}

/* ============================================================
   12. MENU MOBILE - SLIDE LATERAL (CORRIGIDO)
   ============================================================ */

/* Botão toggler */
.navbar-toggler {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: none;
    z-index: var(--z-toggler);
    position: relative;
    transition: var(--transition);
}
.navbar-toggler:hover {
    background: var(--accent-orange);
    border-color: var(--accent-orange);
}

.navbar-toggler-icon {
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath stroke='rgba(255,255,255,0.8)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E") center/contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath stroke='rgba(255,255,255,0.8)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E") center/contain no-repeat;
    transition: var(--transition);
}
.navbar-toggler.active .navbar-toggler-icon {
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath stroke='rgba(255,255,255,0.8)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M6 6L24 24M6 24L24 6'/%3E%3C/svg%3E") center/contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath stroke='rgba(255,255,255,0.8)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M6 6L24 24M6 24L24 6'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Overlay do menu - FICA ATRÁS DO MENU */
.navbar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.navbar-overlay.active {
    opacity: 1;
    visibility: visible;
    z-index: var(--z-overlay); /* 1040 */
}

/* Menu mobile - FICA ACIMA DO OVERLAY */
.navbar-collapse {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    background: var(--primary-dark);
    z-index: var(--z-menu); /* 1050 - MAIOR QUE O OVERLAY */
    padding: 1.5rem 1.5rem 2rem;
    overflow-y: auto;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
    display: flex !important;
    flex-direction: column;
    border-left: 2px solid var(--accent-orange);
}
.navbar-collapse.show {
    right: 0;
}

/* Menu Header */
.navbar-collapse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: var(--z-menu);
}
.navbar-collapse-header .brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}
.navbar-collapse-header .brand img {
    height: 40px;
    width: 40px;
    object-fit: contain;
}
.navbar-collapse-header .close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    transition: var(--transition);
}
.navbar-collapse-header .close-btn:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

/* Menu Nav */
.navbar-collapse .navbar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    padding: 0;
    margin: 0;
    list-style: none;
    position: relative;
    z-index: var(--z-menu);
}
.navbar-collapse .navbar-nav .nav-item {
    width: 100%;
}
.navbar-collapse .navbar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius);
    transition: var(--transition);
    font-weight: 500;
    font-size: 1rem;
    width: 100%;
    text-decoration: none;
    position: relative;
    z-index: var(--z-menu);
}
.navbar-collapse .navbar-nav .nav-link:hover,
.navbar-collapse .navbar-nav .nav-link.active {
    background: var(--accent-orange);
    color: var(--text-primary);
    text-decoration: none;
}
.navbar-collapse .navbar-nav .nav-link .badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    padding: 0.15rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
}

/* Menu Footer */
.navbar-collapse-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    position: relative;
    z-index: var(--z-menu);
}

/* ============================================================
   13. TOAST NOTIFICATIONS - SEMPRE ACIMA DE TUDO
   ============================================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-toast) !important; /* 999999 */
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
    width: 100%;
    pointer-events: none;
}

.toast-container .toast {
    pointer-events: auto;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: slideInRight 0.5s ease-out forwards;
    overflow: hidden;
    min-width: 280px;
    position: relative;
    z-index: var(--z-toast) !important;
}

/* ============================================================
   14. MODAL (se houver)
   ============================================================ */
.modal {
    z-index: var(--z-modal) !important; /* 1060 */
}
.modal-backdrop {
    z-index: calc(var(--z-modal) - 1) !important;
}
/* ============================================================
   14. MODAL (se houver)
   ============================================================ */
.modal {
    z-index: var(--z-modal) !important; /* 1060 */
}
.modal-backdrop {
    z-index: calc(var(--z-modal) - 1) !important;
}
/* ============================================================
   15. ANIMAÇÕES
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

/* ============================================================
   16. RODAPÉ
   ============================================================ */
footer {
    background: var(--primary-dark);
    border-top: 2px solid var(--border);
    padding: 1.5rem 0;
    margin-top: auto;
    text-align: center;
    color: var(--text-muted);
    position: relative;
    z-index: var(--z-base);
}
footer a {
    color: var(--accent-orange);
}
footer a:hover {
    color: var(--accent-hover);
}

/* ============================================================
   17. UTILIDADES
   ============================================================ */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mt-5 { margin-top: 3rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mb-5 { margin-bottom: 3rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }
.rounded { border-radius: var(--radius); }
.shadow { box-shadow: var(--shadow); }
.border-bottom { border-bottom: 1px solid var(--border); }

/* ============================================================
   18. RESPONSIVIDADE
   ============================================================ */
@media (max-width: 992px) {
    .navbar-toggler {
        display: block;
    }

    .navbar .container .navbar-collapse:not(.show) {
        display: none !important;
    }
    .navbar .container .navbar-collapse {
        display: flex !important;
    }

    .col-3, .col-4 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .navbar-collapse.show ~ * {
        pointer-events: none;
    }
}

@media (max-width: 576px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.6rem; }

    .container {
        padding: 0 1rem;
    }

    .col-3, .col-4, .col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .navbar-brand {
        font-size: 1.2rem;
    }
    .navbar-brand span {
        display: none !important;
    }

    .product-card img {
        height: 150px;
    }

    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    .toast-container .toast {
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 400px) {
    .navbar-collapse {
        width: 280px;
        max-width: 90vw;
        right: -280px;
    }
}

@media (min-width: 993px) {
    .navbar-toggler,
    .navbar-overlay {
        display: none !important;
    }

    .navbar .container .navbar-collapse {
        position: static !important;
        right: auto !important;
        width: auto !important;
        height: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        border-left: none !important;
        padding: 0 !important;
        overflow: visible !important;
        transition: none !important;
        display: flex !important;
        z-index: var(--z-navbar) !important;
    }
    .navbar .container .navbar-collapse .navbar-nav {
        flex-direction: row;
        gap: 0.5rem;
    }
    .navbar .container .navbar-collapse .navbar-nav .nav-link {
        padding: 0.4rem 1rem;
        font-size: 0.9rem;
    }
    .navbar-collapse-header,
    .navbar-collapse-footer {
        display: none !important;
    }
}