/* ============================================
   Design System Moderno - Tech Service Tracker
   ============================================ */

:root {
    /* Paleta de cores principal */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-dark: #5568d3;
    --primary-light: #8b94f5;
    
    /* Cores neutras */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Cores de status */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transições */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Espaçamentos */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
}

/* ============================================
   Tipografia
   ============================================ */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--gray-700);
    background-color: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--gray-900);
    letter-spacing: -0.025em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

/* ============================================
   Sidebar Retrátil Modernizado
   ============================================ */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    min-height: 100vh;
    background: var(--primary-gradient);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform var(--transition-base);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
    z-index: 0;
    pointer-events: none;
}

.sidebar > * {
    position: relative;
    z-index: 1;
}

/* Sidebar colapsada */
.sidebar.sidebar-collapsed {
    transform: translateX(-100%);
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-brand {
    flex: 1;
}

.sidebar-title {
    color: white;
    font-weight: 700;
    font-size: 1.125rem;
    margin: 0 0 0.25rem 0;
    white-space: nowrap;
}

.sidebar-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Sidebar Content */
.sidebar-content {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-content .nav {
    flex: 1;
}

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.85);
    border-radius: 12px;
    margin: 4px 0;
    padding: 0.75rem 1rem;
    font-weight: 500;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: rgba(255, 255, 255, 0.15);
    transition: width var(--transition-base);
    border-radius: 12px;
}

.sidebar .nav-link:hover::before,
.sidebar .nav-link.active::before {
    width: 100%;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.12);
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.sidebar .nav-link i {
    font-size: 1.125rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-link-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-base);
}

/* Botão de toggle do sidebar */
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

/* Botão hambúrguer no header (main content) */
.main-content .sidebar-toggle-btn {
    color: var(--gray-700);
}

.main-content .sidebar-toggle-btn:hover {
    background-color: var(--gray-100);
    color: var(--gray-900);
}

/* Overlay para mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    background-color: var(--gray-50);
    min-height: 100vh;
    transition: margin-left var(--transition-base);
    padding: 0 1.5rem 1.5rem;
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

/* Responsividade */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 0 1rem 1rem;
    }
}

@media (min-width: 768px) {
    .sidebar-header .sidebar-toggle-btn {
        display: none;
    }
    
    /* Scrollbar personalizada para sidebar */
    .sidebar::-webkit-scrollbar {
        width: 6px;
    }
    
    .sidebar::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .sidebar::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }
    
    .sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.5);
    }
}

/* ============================================
   Cards Modernos
   ============================================ */

.card {
    border: none;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    background: white;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-header {
    background: linear-gradient(to right, var(--gray-50), white);
    border-bottom: 1px solid var(--gray-200);
    padding: 1.25rem 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

/* Cards de estatísticas */
.card.border-left-primary {
    border-left: 4px solid #667eea;
}

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

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

.card.border-left-success {
    border-left: 4px solid var(--success);
}

/* Remover bordas coloridas de cards padrão */
.card.border-success,
.card.border-warning,
.card.border-danger,
.card.border-info {
    border-color: var(--gray-200) !important;
}

.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-danger,
.card-header.bg-info {
    background: linear-gradient(to right, var(--gray-50), white) !important;
    color: var(--gray-900) !important;
}

/* ============================================
   Botões Modernizados
   ============================================ */

.btn {
    font-weight: 500;
    border-radius: 10px;
    padding: 0.625rem 1.25rem;
    transition: all var(--transition-base);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 6px rgba(102, 126, 234, 0.25);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.35);
    filter: brightness(1.05);
}

.btn-outline-primary {
    border: 2px solid #667eea;
    color: #667eea;
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-gradient);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.35);
    filter: brightness(1.05);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

/* ============================================
   Badges e Status
   ============================================ */

.badge {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    letter-spacing: 0.025em;
}

.status-badge {
    font-size: 0.8125rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.status-pending { 
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
    color: white;
}

.status-pre_inspection_required,
.status-post_inspection_required { 
    background: linear-gradient(135deg, var(--info) 0%, #2563eb 100%);
    color: white;
}

.status-pre_inspection_in_progress,
.status-post_inspection_in_progress { 
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.status-pre_inspection_blocked,
.status-rework_required { 
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    color: white;
}

.status-work_released { 
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

.status-work_in_progress { 
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.status-completed_by_installer { 
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
}

.status-completed { 
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
}

/* ============================================
   Tabelas Modernas
   ============================================ */

.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: var(--gray-50);
    color: var(--gray-700);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem;
    border-bottom: 2px solid var(--gray-200);
}

.table tbody td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

.table tbody tr {
    transition: all var(--transition-fast);
    background-color: white;
}

.table tbody tr:hover {
    background-color: #e8edff;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.table tbody tr.table-warning:hover {
    background-color: #fef3c7;
}

.table-bordered {
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    overflow: hidden;
}

.table-bordered thead th {
    border-bottom: 2px solid var(--gray-200);
}

.table-warning {
    background-color: var(--warning-light);
}

/* ============================================
   Formulários
   ============================================ */

.form-control,
.form-select {
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    padding: 0.625rem 1rem;
    transition: all var(--transition-base);
    font-size: 0.9375rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

/* ============================================
   Alerts Modernizados
   ============================================ */

.alert {
    border: none;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

.alert.border-0 {
    border-left: none;
}

.alert-info {
    background-color: var(--gray-50);
    border-left: 3px solid var(--info);
    color: var(--gray-700);
}

.alert-warning {
    background-color: var(--gray-50);
    border-left: 3px solid var(--warning);
    color: var(--gray-700);
}

.alert-success {
    background-color: var(--gray-50);
    border-left: 3px solid var(--success);
    color: var(--gray-700);
}

.alert-danger {
    background-color: var(--gray-50);
    border-left: 3px solid var(--danger);
    color: var(--gray-700);
}

/* ============================================
   Header/Page Title
   ============================================ */

.main-content {
    background-color: var(--gray-50);
    min-height: 100vh;
}

.main-content .border-bottom {
    border-bottom: 2px solid var(--gray-200) !important;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.main-content h1,
.main-content h2 {
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
}

/* ============================================
   Imagens
   ============================================ */

.img-thumbnail {
    border-radius: 12px;
    border: 2px solid var(--gray-200);
    transition: all var(--transition-base);
    cursor: pointer;
}

.img-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
    border-color: #667eea;
}

/* Cards de imagem com hover elegante */
.card-img-top {
    transition: transform var(--transition-base);
}

.card:hover .card-img-top {
    transform: scale(1.05);
}

/* Quando modal está aberto, desabilitar TODOS os efeitos de hover em cards */
body.modal-open .card:hover .card-img-top,
body.image-modal-open .card:hover .card-img-top {
    transform: none !important;
}

body.modal-open .main-content .card:hover,
body.image-modal-open .main-content .card:hover {
    transform: none !important;
}

/* ============================================
   Modais
   ============================================ */

.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
}

/* Desabilitar efeitos de hover quando modal estiver aberto para prevenir conflitos */
body.modal-open .main-content .card:hover,
body.image-modal-open .main-content .card:hover {
    transform: none !important;
    box-shadow: var(--shadow-md) !important;
}

body.modal-open .main-content .card:hover .card-img-top,
body.modal-open .main-content .card:hover img,
body.image-modal-open .main-content .card:hover .card-img-top,
body.image-modal-open .main-content .card:hover img {
    transform: none !important;
}

body.modal-open .main-content .img-thumbnail:hover,
body.image-modal-open .main-content .img-thumbnail:hover {
    transform: none !important;
    box-shadow: var(--shadow-lg) !important;
    border-color: var(--gray-200) !important;
}

/* Prevenir qualquer interação visual com elementos de fundo quando modal está aberto */
body.image-modal-open .main-content .card,
body.image-modal-open .main-content .img-thumbnail,
body.modal-open .main-content .card,
body.modal-open .main-content .img-thumbnail {
    transition: none !important;
}

body.image-modal-open .main-content .card:hover,
body.image-modal-open .main-content .card:hover *,
body.modal-open .main-content .card:hover,
body.modal-open .main-content .card:hover * {
    transform: none !important;
    box-shadow: var(--shadow-md) !important;
    border-color: inherit !important;
}

/* Desabilitar completamente hover em imagens quando modal está aberto */
body.image-modal-open .main-content .card-img-top:hover,
body.modal-open .main-content .card-img-top:hover {
    transform: none !important;
}

/* Quando há backdrop do modal, garantir que elementos de fundo não reajam a hover */
.modal-backdrop.show ~ * .card:hover,
.modal.show ~ * .card:hover {
    transform: none !important;
    box-shadow: var(--shadow-md) !important;
}

.modal-backdrop.show ~ * .card:hover .card-img-top,
.modal.show ~ * .card:hover .card-img-top {
    transform: none !important;
}

/* Garantir que elementos dentro do modal ainda possam ter hover */
body.modal-open .modal .card:hover,
body.modal-open .modal .card:hover .card-img-top,
body.image-modal-open .modal .card:hover,
body.image-modal-open .modal .card:hover .card-img-top {
    transform: scale(1.05);
}

/* ============================================
   Paginação
   ============================================ */

.pagination .page-link {
    border: 2px solid var(--gray-200);
    color: var(--gray-700);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    margin: 0 0.25rem;
    transition: all var(--transition-base);
}

.pagination .page-link:hover {
    background: var(--primary-gradient);
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
}

.pagination .page-item.active .page-link {
    background: var(--primary-gradient);
    border-color: #667eea;
    color: white;
}

/* ============================================
   Loading States
   ============================================ */

.spinner-border {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

/* ============================================
   Responsividade
   ============================================ */

@media (max-width: 767.98px) {
    .card-body {
        padding: 1rem;
    }
    
    .sidebar {
        min-height: auto;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
}

/* ============================================
   Animações
   ============================================ */

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

.fade-in {
    animation: fadeIn var(--transition-base) ease-out;
}

/* ============================================
   Utilitários
   ============================================ */

.text-muted {
    color: var(--gray-500) !important;
}

.bg-light {
    background-color: var(--gray-50) !important;
}

.shadow {
    box-shadow: var(--shadow-md) !important;
}

.shadow-lg {
    box-shadow: var(--shadow-xl) !important;
}

/* ============================================
   List Groups
   ============================================ */

.list-group-item {
    border-left: none;
    border-right: none;
    padding: 0.75rem 0;
}

.list-group-item:first-child {
    border-top: none;
}

.list-group-item:last-child {
    border-bottom: none;
}

/* ============================================
   Efeitos de hover adicionais
   ============================================ */

.card img {
    transition: transform var(--transition-base);
}

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

/* Border esquerdo decorativo */
.border-start {
    border-left-width: 3px !important;
}

/* Melhorias de espaçamento */
.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 1rem;
}

/* Cards vazios (empty states) */
.card-body.text-center {
    color: var(--gray-500);
}

.card-body.text-center i {
    opacity: 0.5;
}

/* ============================================
   Área de Upload de Imagens
   ============================================ */

.image-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    background-color: var(--gray-50);
    transition: all var(--transition-base);
    cursor: pointer;
}

.image-upload-area:hover {
    border-color: #667eea;
    background-color: #f0f4ff;
}

.image-upload-area.drag-over {
    border-color: #667eea;
    background-color: #e8edff;
    transform: scale(1.02);
}

.image-upload-area .upload-content {
    pointer-events: none;
}

.image-upload-area .btn-link {
    pointer-events: all;
    color: #667eea;
    font-weight: 500;
}

.image-upload-area .btn-link:hover {
    color: #5568d3;
    text-decoration: underline;
}

.image-preview-item {
    position: relative;
    transition: all var(--transition-base);
}

.image-preview-item:hover {
    transform: translateY(-2px);
}

.image-preview-item .image-remove-btn {
    opacity: 0;
    transition: opacity var(--transition-base);
}

.image-preview-item:hover .image-remove-btn {
    opacity: 1;
}

.image-preview-item .image-remove-btn:hover {
    background-color: var(--danger) !important;
    transform: scale(1.1);
}

/* Mobile: botão de remoção sempre visível */
@media (max-width: 767.98px) {
    .image-preview-item .image-remove-btn {
        opacity: 1 !important;
        background-color: rgba(220, 53, 69, 0.9) !important;
    }
    
    .image-preview-item .image-remove-btn:active {
        background-color: var(--danger) !important;
        transform: scale(0.95);
    }
}

/* Border dashed customizado */
.border-2 {
    border-width: 2px !important;
}

.border-dashed {
    border-style: dashed !important;
}

