/*
SYSTEM OS - VISAOTEC SISTEMAS
------------------------------
CSS Responsivo e Otimizado
Autor: Sistema OS
Data: 2024
*/

/* ==========================================================================
   1. CONFIGURAÇÕES BASE
   ========================================================================== */

body {
    font-size: 14px;
    line-height: 1.5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Tipografia responsiva */
@media (max-width: 1200px) { html { font-size: 15px; } }
@media (max-width: 992px) { html { font-size: 14px; } }
@media (max-width: 768px) { html { font-size: 13px; } }
@media (max-width: 576px) { html { font-size: 12px; } }

/* ==========================================================================
   2. COMPONENTES EXISTENTES (MANTIDOS)
   ========================================================================== */

/* Breadcrumb */
.breadcrumb {
    padding-left: 0;
    margin-bottom: 1rem;
    background-color: transparent !important;
}

/* Tabelas */
.table td, .table th {
    padding-right: 0;
}

.table td {
    padding: .25rem;
    font-size: .8rem;
    line-height: 1.4;
}

.table th {
    padding-left: 5px !important;
    font-size: .8rem;
    font-weight: 600;
}

/* Formulários */
form.user .form-control-user {
    font-size: .8rem;
    border-radius: 5px;
    padding: 0.5rem 0.75rem;
    height: calc(1.5em + 1rem);
    border: 1px solid #d1d3e2;
    width: 100%;
    transition: all 0.15s ease-in-out;
}

form.user .form-control-user:focus {
    border-color: #1165f1;
    box-shadow: 0 0 0 0.2rem rgba(17, 101, 241, 0.25);
    outline: 0;
}

.custom-select {
    font-size: .8rem;
    border-radius: 5px;
    max-height: 27px;
    padding-top: 2px;
    padding-left: 0.25rem;
    padding-bottom: 2px;
    border: 1px solid #d1d3e2;
    width: 100%;
}

.form-control-user-date {
    font-size: .8rem;
    border-radius: 5px;
    padding: 0.1rem 1rem;
    max-height: 27px;
    height: 27px;
    border: 1px solid #d1d3e2;
    width: 100%;
}

/* Alertas */
.alert-danger {
    background-color: #ff0000; 
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.alert-success {
    background-color: #93c54b; 
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.text-success {
    color: #93c54b !important; 
}

.border-left-success {
    color: #93c54b !important;
}

/* Cards */
.card-header {
    background-color: white;
    border-bottom: none;
    padding: 0.75rem 1.25rem;
}

/* Botões */
.btn-sm {
    padding: .25rem 0.7rem;
    font-size: .675rem;
    line-height: 1.5;
    border-radius: 0.25rem;
}

.btn-primary {
    background-color: #1165f1 !important;
    border-color: #1165f1;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

.btn-primary:hover {
    background-color: #0d56d8 !important;
    border-color: #0c50cc;
}

/* Utilidades de texto */
.font-small {
    font-size: .8rem;
}

/* Legends */
legend {
    width: auto;
    padding: 0 5px;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

/* Textarea */
textarea {
    min-height: 50px !important;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid #d1d3e2;
    width: 100%;
    resize: vertical;
}

/* DataTables */
.button.dt-button, div.dt-button, a.dt-button {
    background-color: #1165f1 !important;
    color: white;
    border: none;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.dt-buttons {
    float: left;
    width: auto;
    margin-bottom: 1rem;
}

/* Paginação */
.page-item.active .page-link {
    background-color: #1165f1;
    border-color: #1165f1;
}

/* Badges */
.badge-primary {
    background-color: #1165f1;
}

.bg-primary {
    background-color: #1165f1 !important;
}

/* DataTables expand/collapse */
table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > td:first-child::before, 
table.dataTable.dtr-inline.collapsed > tbody > tr[role="row"] > th:first-child::before {
    background-color: #1165f1;
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
}

/* Select2 */
.select2-container {
    font-size: .8rem;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
    width: 100% !important;
}

.select2-container--default .select2-selection--single {
    border: 1px solid #d1d3e2;
    border-radius: 5px;
    height: calc(1.5em + 0.75rem + 2px);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #6e707e;
    line-height: 1.5;
    padding-left: 0.75rem;
    padding-right: 2rem;
}

/* Form específico */
#form_produtos input {
    background-color: yellow;
}

/* Close button */
.close {
    font-size: 1.1rem;
    color: white !important;
    opacity: 0.8;
}

.close:hover {
    opacity: 1;
}

/* Conta home */
.conta-home {
    height: 5rem;
    overflow-y: scroll;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
}

/* Padding utilities */
.pl-4-5 {
    padding-left: 2rem !important;
}

/* Badge counter */
.badge-counter {
    font-size: 95%;
}

/* SweetAlert */
.swal2-popup {
    font-size: 0.8rem !important;
}

.swal2-title {
    font-size: 1.2rem !important;
}

.swal2-content {
    font-size: 0.9rem !important;
}

/* Inputs disabled/readonly */
.form-control:disabled, .form-control[readonly] {
    background-color: #fff;
    opacity: 1;
}

/* Top 5 */
.top-5 {
    height: 391.667px;
    min-height: 391.667px;
}

/* Esconder banner de hospedagem */
img[src="https://cdn.000webhost.com/000webhost/logo/footer-powered-by-000webhost-white2.png"] {
    display: none;
}

/* ==========================================================================
   3. MELHORIAS DE RESPONSIVIDADE
   ========================================================================== */

/* Inputs responsivos */
@media (max-width: 768px) {
    form.user .form-control-user,
    .custom-select,
    .form-control-user-date {
        font-size: 0.75rem;
        padding: 0.4rem 0.5rem;
    }
    
    .custom-select {
        max-height: 24px;
        padding-top: 1px;
        padding-left: 0.2rem;
    }
    
    .form-control-user-date {
        max-height: 24px;
        height: 24px;
        padding: 0.1rem 0.5rem;
    }
}

/* Tabelas responsivas */
@media (max-width: 768px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table td, .table th {
        font-size: 0.75rem;
        padding: 0.2rem;
        white-space: nowrap;
    }
    
    .table th {
        padding-left: 3px !important;
    }
}

/* Botões responsivos */
@media (max-width: 576px) {
    .btn-sm {
        padding: 0.2rem 0.5rem;
        font-size: 0.65rem;
    }
    
    .btn-primary {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .button.dt-button, 
    div.dt-button, 
    a.dt-button {
        width: 100%;
        margin-right: 0;
        margin-bottom: 0.5rem;
        display: block;
    }
    
    .dt-buttons {
        width: 100%;
        float: none;
    }
}

/* Cards responsivos */
@media (max-width: 768px) {
    .card-header {
        padding: 0.5rem 1rem;
    }
}

/* Alertas responsivos */
@media (max-width: 768px) {
    .alert-danger,
    .alert-success {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Select2 responsivo */
@media (max-width: 768px) {
    .select2-container {
        font-size: 0.75rem;
    }
    
    .select2-container--default .select2-selection--single {
        height: calc(1.5em + 0.5rem + 2px);
    }
}

/* Conta home responsiva */
@media (max-width: 768px) {
    .conta-home {
        height: 4rem;
        font-size: 0.8rem;
    }
}

/* Top 5 responsivo */
@media (max-width: 768px) {
    .top-5 {
        height: auto;
        min-height: 300px;
    }
}

/* ==========================================================================
   4. MEDIA QUERIES ESPECÍFICAS DO SISTEMA
   ========================================================================== */

@media only screen and (max-width: 600px) {
    .container-contas {
        margin-top: 3rem;
    }

    .conta-home .none {
        display: none;
    }
    
    /* Adicionais para mobile */
    .breadcrumb {
        font-size: 0.75rem;
        padding: 0.5rem 0;
    }
    
    legend {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
    
    .font-small {
        font-size: 0.75rem;
    }
    
    .pl-4-5 {
        padding-left: 1rem !important;
    }
    
    .badge-counter {
        font-size: 85%;
    }
    
    .swal2-popup {
        font-size: 0.7rem !important;
        width: 90% !important;
        margin: 0 auto;
    }
}

/* ==========================================================================
   5. MELHORIAS PARA DISPOSITIVOS GRANDES
   ========================================================================== */

@media (min-width: 1200px) {
    .table td {
        padding: 0.35rem;
    }
    
    .table th {
        padding-left: 8px !important;
    }
    
    form.user .form-control-user {
        padding: 0.6rem 0.75rem;
    }
    
    .conta-home {
        height: 6rem;
    }
}

/* ==========================================================================
   6. MELHORIAS DE ACESSIBILIDADE
   ========================================================================== */

/* Foco visível para navegação por teclado */
.form-control-user:focus,
.custom-select:focus,
.form-control-user-date:focus,
.select2-container--default.select2-container--focus .select2-selection--single,
.btn-primary:focus,
.btn-sm:focus {
    outline: 2px solid #1165f1;
    outline-offset: 2px;
}

/* Estados hover melhorados */
.btn-primary:hover,
.btn-sm:hover,
.button.dt-button:hover,
div.dt-button:hover,
a.dt-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

/* Contraste para textos */
.alert-danger,
.alert-success,
.btn-primary,
.button.dt-button,
div.dt-button,
a.dt-button,
.badge-primary,
.bg-primary {
    color: white !important;
}

/* ==========================================================================
   7. CORREÇÕES DE LAYOUT
   ========================================================================== */

/* Garantir que inputs tenham largura consistente */
form.user .form-control-user,
.custom-select,
.form-control-user-date,
.select2-container {
    max-width: 100%;
    box-sizing: border-box;
}

/* Espaçamento entre elementos de formulário */
form.user .form-group {
    margin-bottom: 1rem;
}

/* Alinhamento vertical em tabelas */
.table td {
    vertical-align: middle;
}

/* Scroll suave */
.conta-home,
.table-responsive {
    scrollbar-width: thin;
    scrollbar-color: #1165f1 #f1f1f1;
}

.conta-home::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.conta-home::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.conta-home::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: #1165f1;
    border-radius: 3px;
}

/* ==========================================================================
   8. UTILIDADES ADICIONAIS
   ========================================================================== */

/* Para inputs com erro (se necessário) */
.form-control-user.is-invalid {
    border-color: #ff0000;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23ff0000' viewBox='0 0 12 12'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23ff0000' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* Placeholders consistentes */
::placeholder {
    color: #6c757d;
    opacity: 1;
    font-size: 0.8rem;
}

/* Estados loading (se necessário) */
.btn-primary.loading,
.btn-sm.loading {
    position: relative;
    color: transparent !important;
}

.btn-primary.loading::after,
.btn-sm.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}