/* VitaPel - Estilos Customizados para Responsividade */

/* ============================================================
   MELHORIAS PARA FORMULÁRIOS - APENAS EM MOBILE
   ============================================================ */

/* IMPORTANTE: Aplicar APENAS em telas pequenas (mobile) */
@media (max-width: 767px) {
  
  /* Labels de formulário - APENAS MOBILE */
  label, .control-label {
    font-size: 1rem !important;
    font-weight: 600 !important;
    display: block !important;
    width: 100% !important;
    text-align: left !important;
    margin-bottom: 0.5rem !important;
    padding: 0 !important;
    line-height: 1.5 !important;
  }
  
  /* Input fields - APENAS MOBILE */
  .form-control {
    width: 100% !important;
    font-size: 16px !important; /* Evita zoom automático no iOS */
    padding: 0.875rem 1rem !important;
    margin-bottom: 0.5rem !important;
  }
  
  /* Select boxes - APENAS MOBILE */
  select.form-control {
    height: auto !important;
    min-height: 44px !important;
    padding: 0.875rem 1rem !important;
  }
  
  /* Help text - APENAS MOBILE */
  .help-block, .helptext {
    font-size: 0.875rem !important;
    display: block !important;
    width: 100% !important;
    margin-top: 0.25rem !important;
    margin-bottom: 0.75rem !important;
    line-height: 1.5 !important;
  }
  
  /* Form groups - APENAS MOBILE */
  .form-group {
    margin-bottom: 1.25rem !important;
    width: 100% !important;
  }
  
  /* Bootstrap grid em formulários - APENAS MOBILE */
  .form-horizontal .form-group > div[class*="col-"] {
    width: 100% !important;
    float: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  .form-horizontal .control-label {
    width: 100% !important;
    float: none !important;
  }
  
  /* Botões em formulários - APENAS MOBILE */
  .form-group .btn,
  .form-actions .btn,
  form .btn {
    width: 100% !important;
    margin-bottom: 0.75rem !important;
    font-size: 1rem !important;
    padding: 0.875rem 1rem !important;
    min-height: 44px !important;
  }
  
  /* Input groups - APENAS MOBILE */
  .input-group {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }
  
  .input-group .form-control {
    width: 100% !important;
  }
  
  .input-group-addon {
    width: 100% !important;
    text-align: left !important;
    margin-bottom: 0.5rem !important;
  }
  
  /* Error messages - APENAS MOBILE */
  .errorlist {
    padding-left: 0 !important;
    list-style: none !important;
  }
  
  .errorlist li {
    color: #e06c58 !important;
    font-size: 0.875rem !important;
    margin-bottom: 0.5rem !important;
    padding: 0.5rem !important;
    background-color: rgba(224, 108, 88, 0.1) !important;
    border-left: 3px solid #e06c58 !important;
    border-radius: 4px !important;
  }
  
  /* Required field indicator - APENAS MOBILE */
  .asteriskField {
    color: #e06c58 !important;
    font-weight: bold !important;
  }
}

/* ============================================================
   DESKTOP - Garantir tamanhos normais
   ============================================================ */

@media (min-width: 768px) {
  /* Garantir que no desktop os tamanhos sejam adequados */
  .form-control {
    font-size: 1rem;
    padding: 0.75rem 1rem;
  }
  
  .btn {
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
  }
  
  label, .control-label {
    font-size: 1rem;
  }
  
  .help-block {
    font-size: 0.875rem;
  }
}

/* Melhorias gerais de responsividade */
@media (max-width: 767px) {

    /* Ajuste de título principal */
    .container-fluid h1 {
        font-size: 1.5em;
        margin-bottom: 15px;
    }

    /* Ajuste de botões em mobile */
    .btn {
        margin-bottom: 10px;
        white-space: normal;
        word-wrap: break-word;
    }

    /* Melhor espaçamento de panels */
    .panel {
        margin-bottom: 15px;
    }

    /* Ajuste de badges */
    .badge {
        display: inline-block;
        word-break: break-word;
        white-space: normal;
        max-width: 100%;
    }
}

/* Tabelas Responsivas - Layout de Cards em Mobile */
@media (max-width: 767px) {

    /* Esconde a tabela tradicional e cria layout de cards */
    .table-responsive table.table thead {
        display: none;
    }

    .table-responsive table.table,
    .table-responsive table.table tbody,
    .table-responsive table.table tr,
    .table-responsive table.table td {
        display: block;
        width: 100%;
    }

    .table-responsive table.table tr {
        margin-bottom: 20px;
        border: 1px solid #ddd;
        border-radius: 5px;
        padding: 10px;
        background: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .table-responsive table.table td {
        text-align: left !important;
        padding: 8px 10px;
        border: none;
        position: relative;
        padding-left: 40%;
        min-height: 40px;
    }

    /* Adiciona labels antes de cada célula */
    .table-responsive table.table td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 35%;
        padding-right: 10px;
        font-weight: bold;
        text-align: left;
        color: #337ab7;
    }

    /* Ajustes para células com ícones/botões */
    .table-responsive table.table td.text-center {
        padding-left: 40%;
    }

    /* Botões de ação */
    .table-responsive table.table td .btn {
        margin: 2px;
    }

    /* Footer da tabela */
    .table-responsive table.table tfoot th {
        display: block;
        text-align: center;
        padding: 15px;
        background: #f5f5f5;
        border-radius: 5px;
        margin-top: 10px;
    }
}

/* Ajustes específicos para textos longos */
@media (max-width: 767px) {

    /* Limita tamanho de textos em células */
    .table-responsive table.table td {
        word-wrap: break-word;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    /* Observações e comentários */
    .table-responsive table.table td small {
        display: block;
        margin-top: 5px;
    }
}

/* Grid system - garante que tudo empilhe corretamente em mobile */
@media (max-width: 767px) {
    [class*="col-"] {
        margin-bottom: 10px;
    }
}

/* Ajustes para formulários */
@media (max-width: 767px) {
    .form-group {
        margin-bottom: 15px;
    }

    .form-control {
        font-size: 16px; /* Previne zoom automático em iOS */
    }

    select.form-control {
        max-width: 100%;
    }
}

/* Cards de dashboard */
@media (max-width: 767px) {
    .panel-body {
        padding: 10px;
    }

    .panel-heading {
        padding: 10px 15px;
    }
}

/* Lista de exercícios em treinos */
@media (max-width: 767px) {
    .table-responsive table.table td a[href*="youtube"],
    .table-responsive table.table td a[href*="whatsapp"] {
        display: inline-block;
        margin: 5px 0;
    }
}

/* Ajuste de canvas para gráficos */
@media (max-width: 767px) {
    canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Melhorias para o login */
@media (max-width: 767px) {
    .text-justify {
        text-align: left !important;
    }

    ul {
        padding-left: 20px;
    }
}

/* Navbar mobile */
@media (max-width: 767px) {
    .navbar-collapse {
        max-height: 400px;
        overflow-y: auto;
    }

    .navbar-nav {
        margin: 0;
    }

    .navbar-nav > li > a {
        padding: 10px 15px;
    }
}

/* Barra de status fixa no rodapé */
@media (max-width: 767px) {
    .navbar-fixed-bottom {
        position: relative; /* Evita sobreposição em mobile */
        margin-top: 20px;
    }
}

/* Melhorias para leitura de textos longos */
.text-break {
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

.text-truncate-mobile {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 767px) {
    .text-truncate-mobile {
        white-space: normal;
        max-height: none;
    }
}

/* Botões de ação sempre visíveis */
@media (max-width: 767px) {
    .btn-group {
        display: flex;
        flex-direction: column;
    }

    .btn-group > .btn {
        width: 100%;
        margin-bottom: 5px;
    }
}

/* Scroll horizontal para tabelas muito grandes (fallback) */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Estilos para impressão */
@media print {
    .table-responsive {
        overflow: visible;
    }

    .btn,
    .navbar,
    .panel-body form {
        display: none;
    }

    .table {
        border: 1px solid #ddd;
    }

    .table td,
    .table th {
        border: 1px solid #ddd;
        padding: 8px;
    }
}

/* Acessibilidade - aumenta área de toque em mobile */
@media (max-width: 767px) {
    .btn,
    a.btn {
        min-height: 44px;
        line-height: 44px;
        padding: 0 15px;
    }

    .btn-sm {
        min-height: 36px;
        line-height: 36px;
    }
}

/* Animações suaves para transições */
@media (prefers-reduced-motion: no-preference) {
    .table-responsive table.table tr {
        transition: box-shadow 0.3s ease;
    }

    .table-responsive table.table tr:hover {
        box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    }
}
