/**
 * SIMEI 2.0 - Sistema Integrado de Monitoramento e Ensalamento
 * Desenvolvido por: Herick Bruno de Souza Leal e Vitor Vieira Barbosa
 * Todos os direitos reservados.
 * Protegido pela Lei nº 9.609/1998 (Lei de Software) e Lei nº 9.610/1998 (Lei de Direitos Autorais)
 * Reprodução, cópia, modificação ou distribuição não autorizada é crime.
 */

/* Estilos extraídos de solicitar.php - Visual Original */

.tipo-solicitacao {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.tipo-option {
    position: relative;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.tipo-option:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.tipo-option.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}

.tipo-option input[type="radio"],
.tipo-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tipo-option .icon {
    font-size: 2rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    display: block;
}

.tipo-option.selected .icon {
    color: #3b82f6;
}

.tipo-option .title {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.tipo-option .description {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.4;
}

.materiais-section {
    display: none;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: #f9fafb;
}

.materiais-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.material-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.material-item:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.material-item input[type="checkbox"] {
    margin-right: 0.75rem;
    transform: scale(1.1);
}

.material-info {
    flex: 1;
}

.material-name {
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.material-qty {
    font-size: 0.875rem;
    color: #6b7280;
}

.material-item-with-qty {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.material-item-with-qty:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.material-checkbox {
    display: flex;
    align-items: center;
}

.material-quantity {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.materiais-grid-scrollable {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 1rem;
    background: white;
}

.materiais-grid-scrollable::-webkit-scrollbar {
    width: 8px;
}

.materiais-grid-scrollable::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.materiais-grid-scrollable::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.materiais-grid-scrollable::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.material-item-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
}

.material-item-search:hover {
    border-color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

.material-item-search:last-child {
    margin-bottom: 0;
}

.material-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.material-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.horarios-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 768px) {
    .horarios-section {
        grid-template-columns: 1fr;
    }

    .material-item-with-qty {
        padding: 0.5rem;
    }

    .material-quantity {
        justify-content: flex-start;
    }
    
    /* Corrigir grid de tipo-solicitacao no mobile */
    .tipo-solicitacao {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }
    
    .tipo-option {
        padding: 0.875rem;
    }
}


/* --- Estilos extraídos de pendentes.php (Visual Original) --- */

/* Correções de Fundo */
body.bg-fix {
    background-image: none !important;
    background-color: #f4f6f9 !important;
}

.main-content.bg-white {
    background-color: var(--surface);
    min-height: 100vh;
}

/* Badges de Tipo */
.tipo-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tipo-datashow { background: #dbeafe; color: #1e40af; }
.tipo-materiais { background: #d1fae5; color: #065f46; }
.tipo-software { background: #E0E7FF; color: #3730A3; }

/* Botão Info */
.btn-info {
    background-color: #0ea5e9;
    color: white;
    border: none;
    text-decoration: none;
}
.btn-info:hover { background-color: #0284c7; }

/* Listas de Materiais */
.materiais-list {
    font-size: 0.875rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.materiais-list .material-item {
    display: inline-block;
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    margin: 0.125rem;
}

/* Células e Textos */
.observacao-cell { max-width: 200px; }

.observacao-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: help;
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.clickable-row:hover { background-color: #f3f4f6; }

/* Badges de Turno */
.turno-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}
.turno-matutino { background: #fef3c7; color: #92400e; }
.turno-vespertino { background: #dbeafe; color: #1e40af; }
.turno-noturno { background: #e0e7ff; color: #3730a3; }

/* Modais */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #ffffff;
    color: #1f2937;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Modal no Modo Escuro */
body.dark .modal-content {
    background-color: #1f2937;
    color: #e5e7eb;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* Inputs dentro do modal respeitam a largura do container */
.modal-content .form-input,
.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Grid de formulários dentro do modal */
.modal-content .form-group {
    margin-bottom: 1rem;
}

/* Botões de ação do modal alinhados */
.modal-content .btn {
    white-space: nowrap;
}

.modal-content-large {
    background-color: var(--card-bg);
    color: var(--text);
    margin: 2% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-title { margin: 0; color: var(--text); }

.close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
}
.close:hover { color: #374151; }

.modal-body { line-height: 1.6; }

/* Detalhes do Modal */
.detail-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface);
    color: var(--text);
    border-radius: 6px;
}

.detail-section h3, .detail-section h4 {
    margin: 0 0 0.75rem 0;
    color: var(--text);
    font-size: 1.1rem;
}

.detail-row { display: flex; margin-bottom: 0.5rem; }

.detail-label {
    font-weight: 600;
    color: var(--muted-text);
    min-width: 120px;
}

.detail-value {
    color: var(--text);
    flex: 1;
    /* Forçar quebra de linha para textos longos */
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.materiais-column { max-width: 200px; }

.material-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.125rem 0.375rem;
    margin: 0.125rem 0;
    background: #f3f4f6;
    border-radius: 3px;
    font-size: 0.75rem;
}

.material-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 0.5rem;
}

.material-qty {
    font-weight: 600;
    color: #059669;
    background: #d1fae5;
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
    min-width: 30px;
    text-align: center;
}

/* Responsividade */
@media (max-width: 768px) {
    .modal-content-large {
        width: 95%;
        margin: 5% auto;
        padding: 1rem;
    }
    .detail-row { flex-direction: column; }
    .detail-label { min-width: auto; margin-bottom: 0.25rem; }
}

/* --- Estilos extraídos de materiais.php (Visual Original) --- */

/* Badges de Status */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-disponivel {
    background: #d1fae5;
    color: #065f46;
}

.status-indisponivel {
    background: #fee2e2;
    color: #991b1b;
}

/* Tabela e Ações */
.actions-cell {
    white-space: nowrap;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Filtros */
.search-container {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-container .form-group {
        margin-bottom: 0;
    }
}

/* --- Estilos extraídos de relatorios.php (Dashboard) --- */

.dashboard-container {
    background: #f8fafc;
    min-height: 100vh;
}

/* Grid de Cards Estatísticos */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid #f1f5f9;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-color);
}

/* Cores dos Cards */
.stat-card.green { --card-color: #10b981; }
.stat-card.red { --card-color: #ef4444; }
.stat-card.orange { --card-color: #f59e0b; }
.stat-card.blue { --card-color: #3b82f6; }
.stat-card.purple { --card-color: #8b5cf6; }

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: white;
}

/* Gradientes dos Ícones */
.stat-card.green .stat-icon { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.red .stat-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card.orange .stat-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-card.blue .stat-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-card.purple .stat-icon { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.stat-number {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: #1f2937;
    line-height: 1;
}

.stat-label {
    font-size: 1rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-description {
    font-size: 0.875rem;
    color: #9ca3af;
    margin-top: 0.5rem;
    line-height: 1.4;
}

/* Tabela de Relatório */
.relatorio-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.relatorio-table th {
    background: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.relatorio-table td {
    padding: 1rem;
    border-bottom: 1px solid #f3f4f6;
    color: #4b5563;
}

.relatorio-table tr:hover { background: #f9fafb; }

/* Status Específicos do Relatório */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}
.status-pendente { background: #fef3c7; color: #92400e; }
.status-aprovada { background: #d1fae5; color: #065f46; }
.status-retirada { background: #dbeafe; color: #1e40af; }
.status-devolvida { background: #e0e7ff; color: #3730a3; }
.status-cancelada { background: #fee2e2; color: #991b1b; }

/* Botões de Exportação */
.export-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Itens Danificados */
.damaged-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.damaged-item {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.damaged-item-name { font-weight: 600; color: #dc2626; margin-bottom: 0.5rem; }
.damaged-item-qty { font-size: 1.5rem; font-weight: bold; color: #991b1b; }

/* Formulário de Filtro */
.filter-form {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}

@media (max-width: 768px) {
    .form-row, .stats-grid { grid-template-columns: 1fr; }
    .export-buttons { justify-content: center; }
}

/* --- Estilos extraídos de usuarios.php --- */

/* Grids do Formulário */
.user-form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.user-form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Checkbox Ativo */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-auto-width {
    width: auto;
}

/* Botões e Alinhamentos */
.form-buttons-end {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Barra de Pesquisa e Filtros */
.search-form-flex {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.flex-grow-1 {
    flex-grow: 1;
}

.filters-form-flex {
    display: flex;
    gap: 1rem;
    align-items: end;
    flex-wrap: wrap;
}

.w-200 {
    width: 200px;
}

/* Títulos e Textos */
.table-section-title {
    margin: 2rem 0 1rem 0;
    text-align: center;
}

.text-blue-highlight {
    color: #2563eb;
}

.actions-flex {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-small-custom {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.empty-state-cell {
    padding: 2rem;
    color: #6b7280;
}

/* Responsividade para Grids */
@media (max-width: 768px) {
    .user-form-grid-2,
    .user-form-grid-3 {
        grid-template-columns: 1fr;
    }
    
    .filters-form-flex {
        flex-direction: column;
        align-items: stretch;
    }
    
    .w-200 {
        width: 100%;
    }
}

/* --- Estilos da Tela de Login (index.php) --- */

/* Container da Logo do CETAM/IBC */
.login-logo-container {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

/* Ajuste específico para o olho de senha no Login */
.toggle-password-login {
    position: absolute;
    right: 15px;
    top: 38px; /* Ajuste fino para alinhar com o input */
    cursor: pointer;
    color: #6b7280;
    z-index: 10;
}


/* --- CORREÇÃO DE RESPONSIVIDADE MOBILE --- */

/* 1. Evita que a tela "dance" para os lados (scroll horizontal indesejado) */
html, body {
    overflow-x: hidden;
    width: 100%;
}

@media (max-width: 768px) {
    /* 2. Remove a margem da esquerda que era para a Sidebar no PC */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem !important;
    }

    /* 3. Ajusta os Modais para não cortarem na tela do celular */
    .modal {
        padding-top: 0;
        z-index: 9999; /* Garante que fique na frente de tudo */
    }

    .modal-content, 
    .modal-content-large,
    .modal-content-normal {
        width: 90% !important; /* Ocupa 90% da tela */
        margin: 5% auto !important; /* Centraliza */
        max-width: none !important; /* Remove limite de largura fixa */
        max-height: 90vh; /* Não deixa ser maior que a altura da tela */
        overflow-y: auto; /* Permite rolar se o modal for comprido */
    }

    /* 4. Força tabelas a terem barra de rolagem se forem muito largas */
    .table-container {
        width: 100%;
        overflow-x: auto;
        display: block;
    }
}

/* Overrides finais para modo escuro: garantir que textos dentro do modal e sidebar fiquem brancos */
body.dark .sidebar-header p,
body.dark .modal-content-large .detail-value,
body.dark .modal-content .detail-value,
body.dark .detail-section .detail-value,
body.dark .modal-content-large .material-item-row,
body.dark .modal-content .material-item-row,
body.dark .material-name,
body.dark .detail-section p,
body.dark .detail-section small {
    color: #ffffff !important;
}

/* Opcional: aumentar contraste de pequenos textos dentro do modal */
body.dark .modal-content-large .detail-value,
body.dark .modal-content .detail-value {
    opacity: 1 !important;
    color: #ffffff !important;
}
