/* Custom Styles for AutoStock */

:root {
    --primary-color: #0D47A1;
    --secondary-color: #1A73E8;
    --text-color: #424242;
    --primary: #2563EB;
    --secondary: #0F172A;
    --accent: #10B981;
    --bg: #F8FAFC;
    --text-main: #1E293B;
    --text-secondary: #64748B;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
}

/* ============================================
   REQ-FR-UI-003: Padronização do comportamento do cursor
   ============================================ */

/* Elementos clicáveis - cursor pointer */
button,
a,
.btn,
.nav-link,
.navbar-brand,
.clickable,
[role="button"],
[onclick],
input[type="submit"],
input[type="button"],
input[type="reset"],
label[for],
select:not(:disabled),
input[type="checkbox"],
input[type="radio"] {
    cursor: pointer;
}

/* Links específicos */
a:not(.disabled):not([aria-disabled="true"]) {
    cursor: pointer;
}

/* Ícones clicáveis */
i[onclick],
i.clickable,
.bi[onclick],
svg[onclick],
.icon-clickable {
    cursor: pointer;
}

/* Elementos desabilitados - cursor not-allowed */
button:disabled,
.btn:disabled,
.btn.disabled,
input:disabled,
select:disabled,
textarea:disabled,
.form-control:disabled,
.form-select:disabled,
a.disabled,
.nav-link.disabled,
[aria-disabled="true"],
.disabled {
    cursor: not-allowed !important;
}

/* Estados de carregamento - cursor wait/progress */
.loading,
.is-loading,
[data-loading="true"],
body.loading,
.form-loading,
.btn.loading,
.spinner-border,
.spinner-grow {
    cursor: wait !important;
}

/* Progress indicators */
.progress,
.progress-bar {
    cursor: progress;
}

/* Elementos informativos - cursor default (mantém padrão) */
p,
span:not([onclick]),
h1, h2, h3, h4, h5, h6 {
    cursor: default;
}

/* Inputs editáveis */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
textarea,
.form-control:not(:disabled),
.form-select:not(:disabled) {
    cursor: text;
}

/* Inputs de seleção */
input[type="checkbox"],
input[type="radio"],
.form-check-input {
    cursor: pointer;
}

/* Drag and drop */
[draggable="true"] {
    cursor: grab;
}

[draggable="true"]:active {
    cursor: grabbing;
}

/* Resize handles */
textarea[resize],
.resize {
    cursor: nwse-resize;
}

/* Help cursor para elementos com tooltip */
[data-bs-toggle="tooltip"],
[title],
[data-tooltip] {
    cursor: help;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, #0D47A1 0%, #1A73E8 50%, #0D47A1 100%);
    min-height: 90vh;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.hero-pattern {
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.min-vh-75 {
    min-height: 75vh;
}

/* Smooth Scroll */
html {
    scroll-behavior: smooth;
}

/* Card Hover Effect */
.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Navbar */
.navbar-brand {
    font-size: 1.25rem;
    cursor: pointer;
}

.nav-link {
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.nav-link:hover {
    opacity: 0.8;
}

.nav-link.disabled {
    cursor: not-allowed;
}

/* Buttons */
.btn {
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:disabled,
.btn.disabled {
    cursor: not-allowed !important;
}

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 0.25rem rgba(26, 115, 232, 0.25);
}

/* Loading Spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* Dashboard Styles */
.sidebar {
    min-height: calc(100vh - 56px);
    background-color: #f8f9fa;
    transition: left 0.3s ease;
}

.sidebar .nav-link {
    color: var(--text-color);
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
    min-height: 44px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.sidebar .nav-link:hover {
    background-color: rgba(26, 115, 232, 0.1);
    color: var(--secondary-color);
    transform: translateX(4px);
}

.sidebar .nav-link.active {
    background-color: var(--secondary-color);
    color: white;
    font-weight: 600;
}

/* ============================================
   DESKTOP - Sidebar Lateral Fixa
   ============================================ */
@media (min-width: 769px) {
    /* Sidebar sempre visível em desktop */
    .sidebar {
        display: block !important;
        position: relative !important;
        min-height: calc(100vh - 56px);
        background-color: #f8f9fa;
        transition: none;
        left: 0 !important;
        top: 0 !important;
        z-index: 1;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    }
    
    /* Garantir que sidebar não sobreponha conteúdo - Bootstrap grid já gerencia isso */
    .container-fluid > .row {
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Ocultar overlay em desktop */
    .sidebar-overlay {
        display: none !important;
    }
    
    /* Ocultar menu do navbar em desktop quando há sidebar */
    /* Apenas para páginas que têm sidebar (não index.html) */
    body.has-sidebar .navbar-collapse {
        display: none !important;
    }
    
    /* Navbar toggler oculto em desktop apenas quando há sidebar */
    body.has-sidebar .navbar-toggler {
        display: none !important;
    }
    
    /* Garantir que body não tenha padding em desktop apenas quando há sidebar */
    body.has-sidebar {
        padding-top: 0 !important;
    }
    
    /* Navbar não fixo em desktop quando há sidebar */
    body.has-sidebar .navbar:not(.fixed-top) {
        position: relative !important;
    }
}

/* ============================================
   MOBILE - Menu Navbar Colapsável
   (Apenas para páginas com sidebar - classe has-sidebar adicionada via JS)
   ============================================ */
@media (max-width: 768px) {
    /* Fixar navbar no topo em mobile - apenas para páginas com sidebar */
    body.has-sidebar .navbar:not(.fixed-top) {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1050 !important;
        width: 100% !important;
    }
    
    /* Ajustar padding do body para compensar navbar fixo - apenas para páginas com sidebar */
    body.has-sidebar {
        padding-top: 56px !important;
    }
    
    /* Ocultar sidebar em mobile - apenas quando existe */
    body.has-sidebar .sidebar {
        display: none !important;
    }
    
    /* Navbar Toggler - estilos específicos para páginas com sidebar */
    body.has-sidebar .navbar-toggler {
        display: block !important;
        position: relative;
        z-index: 1051;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        padding: 0.375rem 0.75rem;
        margin-left: auto;
        border-radius: 0.375rem;
        transition: all 0.2s ease;
    }
    
    body.has-sidebar .navbar-toggler:focus {
        box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.25) !important;
        outline: none;
    }
    
    body.has-sidebar .navbar-toggler:not(.collapsed) {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Garantir que navbar-brand e toggler estejam bem alinhados - apenas para páginas com sidebar */
    body.has-sidebar .navbar .container-fluid {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        flex-wrap: nowrap !important;
    }
    
    /* Estilizar menu mobile no navbar-collapse - apenas para páginas com sidebar */
    body.has-sidebar .navbar-collapse {
        position: fixed !important;
        top: 56px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background-color: rgba(13, 71, 161, 0.98) !important;
        backdrop-filter: blur(10px);
        padding: 1rem 0 !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
        overflow-y: auto;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    body.has-sidebar .navbar-collapse.show,
    body.has-sidebar .navbar-collapse:not(.collapsing) {
        transform: translateX(0);
    }
    
    /* Overlay escuro quando menu está aberto - apenas para páginas com sidebar */
    body.has-sidebar .navbar-collapse.show::before {
        content: '';
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;

        z-index: -1;
        animation: fadeIn 0.3s ease;
    }
    
    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
    
    /* Estilos dos links no menu mobile - apenas para páginas com sidebar */
    body.has-sidebar .navbar-collapse .navbar-nav {
        width: 100%;
        padding: 0 1rem;
    }
    
    body.has-sidebar .navbar-collapse .nav-item {
        margin: 0.25rem 0;
    }
    
    body.has-sidebar .navbar-collapse .nav-link {
        color: rgba(255, 255, 255, 0.95) !important;
        padding: 0.875rem 1.25rem !important;
        display: flex;
        align-items: center;
        border-radius: 0.5rem;
        margin: 0.125rem 0;
        transition: all 0.2s ease;
        min-height: 48px;
        font-weight: 500;
        position: relative;
    }
    
    body.has-sidebar .navbar-collapse .nav-link::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 3px;
        height: 0;
        background-color: white;
        border-radius: 0 2px 2px 0;
        transition: height 0.2s ease;
    }
    
    body.has-sidebar .navbar-collapse .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.15) !important;
        color: white !important;
        transform: translateX(6px);
        padding-left: 1.5rem !important;
    }
    
    body.has-sidebar .navbar-collapse .nav-link:hover::before {
        height: 60%;
    }
    
    body.has-sidebar .navbar-collapse .nav-link.active {
        background-color: rgba(255, 255, 255, 0.25) !important;
        color: white !important;
        font-weight: 600;
        padding-left: 1.5rem !important;
    }
    
    body.has-sidebar .navbar-collapse .nav-link.active::before {
        height: 70%;
        background-color: white;
    }
    
    body.has-sidebar .navbar-collapse .nav-link i {
        width: 24px;
        text-align: center;
        font-size: 1.15rem;
        margin-right: 0.75rem;
        flex-shrink: 0;
    }
    
    body.has-sidebar .navbar-collapse .nav-link.text-danger {
        color: #ff6b6b !important;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
        margin-top: 0.75rem;
        padding-top: 1.125rem !important;
    }
    
    body.has-sidebar .navbar-collapse .nav-link.text-danger:hover {
        background-color: rgba(255, 107, 107, 0.2) !important;
        color: #ff5252 !important;
    }
    
    body.has-sidebar .navbar-collapse .nav-link.text-danger::before {
        background-color: #ff6b6b;
    }
    
    /* Bloquear scroll do body quando menu está aberto - apenas para páginas com sidebar */
    body.has-sidebar.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    /* Ajustar conteúdo principal em mobile - apenas para páginas com sidebar */
    body.has-sidebar .container-fluid > .row > main,
    body.has-sidebar .container-fluid > .row > .col-md-9,
    body.has-sidebar .container-fluid > .row > .col-lg-10 {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Garantir que não haja overflow horizontal */
    body.has-sidebar .container-fluid {
        overflow-x: hidden;
        max-width: 100%;
    }
    
    body.has-sidebar .container-fluid > .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100%;
    }
    
    /* Cards mobile de tabelas */
    .table-mobile-cards {
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0;
    }
    
    .table-mobile-cards .card {
        width: 100%;
        max-width: 100%;
        margin-bottom: 1rem;
        border: 1px solid #E2E8F0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    
    .table-mobile-cards .card-body {
        padding: 1rem;
    }
    
    .table-mobile-cards .card-body > div {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Imagens de veículos nos cards mobile */
    .table-mobile-cards .card-body img.vehicle-thumbnail,
    .table-mobile-cards .card-body .d-flex img,
    img.vehicle-thumbnail {
        max-width: 100px !important;
        width: 100px !important;
        height: 75px !important;
        object-fit: cover !important;
        border-radius: 8px;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex-shrink: 0;
    }
    
    /* Garantir que imagens na tabela apareçam em mobile */
    table img.vehicle-thumbnail {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 64px !important;
        height: 48px !important;
        object-fit: cover !important;
    }
    
    /* Imagens na página de edição de veículos */
    img.vehicle-edit-image,
    #imagesPreview img {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
        height: 100px !important;
        object-fit: cover !important;
        max-width: 100% !important;
    }
    
    /* Garantir que imagens data URI apareçam */
    img[src^="data:image"],
    img[src^="data:Image"] {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Preview de imagens */
    #imagesPreview {
        min-height: 50px;
    }
    
    #imagesPreview .col-6,
    #imagesPreview .col-md-4,
    #imagesPreview .col-lg-3 {
        display: block !important;
    }
    
    .table-mobile-cards .card-body .d-flex {
        display: flex !important;
        align-items: center;
        gap: 0.75rem;
        flex-wrap: wrap;
    }
    
    .table-mobile-cards .card-body img:not(.vehicle-thumbnail) {
        max-width: 100%;
        height: auto;
    }
    
    .table-mobile-cards .btn-group {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .table-mobile-cards .btn-group .btn,
    .table-mobile-cards .btn {
        flex: 1 1 auto;
        min-width: 44px;
        min-height: 44px !important;
        height: 44px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 1rem;
    }
    
    .table-mobile-cards .btn i {
        font-size: 1rem;
        line-height: 1;
    }
    
    /* Garantir que tabelas não quebrem layout */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    @media (max-width: 768px) {
        .table-responsive {
            overflow-x: visible;
        }
        
        .table-responsive table {
            display: none;
        }
        
        .table-responsive .table-mobile-cards {
            display: block;
        }
    }
}

/* Vehicle Card */
.vehicle-card {
    transition: transform 0.3s ease;
}

.vehicle-card:hover {
    transform: scale(1.02);
}

.vehicle-card img {
    height: 200px;
    object-fit: cover;
}

/* Stats Card */
.stats-card {
    border-left: 4px solid var(--secondary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .hero-section {
        min-height: auto;
        padding: 3rem 0;
    }
    
    .display-4 {
        font-size: 2rem;
    }
    
    .display-5 {
        font-size: 1.75rem;
    }
    
    /* Botões com tamanho mínimo para touch */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 1rem;
    }
    
    .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }
    
    /* Espaçamento entre elementos clicáveis */
    .btn + .btn,
    .nav-link + .nav-link {
        margin-top: 0.5rem;
    }
    
    /* Formulários responsivos */
    .form-control,
    .form-select {
        font-size: 16px; /* Evita zoom no iOS */
        min-height: 44px;
    }
    
    /* Cards de tabela para mobile */
    .table-mobile-card {
        display: block;
    }
    
    .table-mobile-card thead {
        display: none;
    }
    
    .table-mobile-card tbody,
    .table-mobile-card tr,
    .table-mobile-card td {
        display: block;
        width: 100%;
    }
    
    .table-mobile-card tr {
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
        padding: 1rem;
        background: white;
    }
    
    .table-mobile-card td {
        border: none;
        padding: 0.5rem 0;
        text-align: left !important;
    }
    
    .table-mobile-card td:before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: var(--text-color);
    }
    
    /* Ocultar tabela desktop em mobile */
    .table-desktop {
        display: none;
    }
}

/* Utilities */
.text-balance {
    text-wrap: balance;
}

.bg-opacity-10 {
    background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
}

.backdrop-blur {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Feature Cards */
.feature-card {
    transition: all 0.3s ease;
    background-color: #f8f9fa;
}

.feature-card:hover {
    background-color: #e3f2fd;
    transform: translateY(-5px);
}

/* Text utilities */
.text-white-50 {
    color: rgba(255, 255, 255, 0.5) !important;
}

.text-white-50:hover {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Logo Standardization */
.logo {
    max-width: 220px;
    height: auto;
    object-fit: contain;
}

.logo-preview {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

#logoPreview {
    background: #f8f9fa !important;
    border: 2px solid #dee2e6;
    border-radius: 8px;
}

.header-logo-wrapper {
    display: flex;
    align-items: center;
    padding: 0.25rem 0;
}

.header-logo {
    max-height: 150px;
    max-width: 600px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

@media (max-width: 768px) {
    .logo {
        max-width: 150px;
    }
    
    #logoPreview {
        min-width: 280px !important;
        min-height: 140px !important;
        max-width: 100% !important;
        max-height: 300px !important;
        width: auto !important;
        height: auto !important;
    }
    
    .header-logo-wrapper {
        padding: 0.15rem 0;
    }
    
    .header-logo {
        max-height: 100px;
        max-width: 400px;
        width: auto;
        height: auto;
    }
    
    /* Modal de filtros */
    .filters-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 1050;
        overflow-y: auto;
        display: none;
    }
    
    .filters-modal.show {
        display: block;
    }
    
    /* Botão CTA flutuante mobile */
    .cta-button-mobile {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        border-radius: 0;
        margin: 0;
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
    
    /* Upload de imagens mobile */
    .image-upload-area {
        min-height: 120px;
        padding: 1.5rem;
    }
    
    /* Lazy loading de imagens */
    img[loading="lazy"] {
        opacity: 0;
        transition: opacity 0.3s;
    }
    
    img[loading="lazy"].loaded {
        opacity: 1;
    }
}

/* ============================================
   ABOUT IMAGE UPLOAD SECTION
   ============================================ */
.about-image-upload {
    margin-top: 0;
}

.upload-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: flex-start;
}

.image-preview {
    width: 100%;
    max-width: 400px;
    height: 250px;
    border: 2px dashed rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
    position: relative;
    transition: all 0.3s ease;
}

.image-preview.has-image {
    border: 2px solid var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none !important;
}

.image-preview img.show {
    display: block !important;
}

.placeholder-text {
    color: var(--text-secondary);
    text-align: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.placeholder-text.hidden {
    display: none;
}

.upload-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.upload-actions .btn {
    min-width: 150px;
}

/* Dark Mode */
body.dark-mode .image-preview {
    background: #1E293B;
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .image-preview.has-image {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

body.dark-mode .placeholder-text {
    color: rgba(255, 255, 255, 0.6);
}

/* Responsive */
@media (max-width: 768px) {
    .upload-container {
        flex-direction: column;
        gap: 20px;
    }

    .image-preview {
        max-width: 100%;
        width: 100%;
    }

    .upload-actions {
        width: 100%;
    }

    .upload-actions .btn {
        flex: 1;
        min-width: auto;
    }
}
