/**
 * Sistema de Inventário Compex
 * Estilos CSS - Interface Touch-Friendly e Responsiva
 */

/* ============================================
   Reset e Base
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Container Principal
   ============================================ */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
}

/* ============================================
   Tela de Login
   ============================================ */
.login-container {
    max-width: 400px;
    margin: 50px auto;
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #2c3e50;
    font-size: 24px;
    margin-bottom: 10px;
}

.login-header p {
    color: #7f8c8d;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px; /* Previne zoom no iOS */
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s;
    touch-action: manipulation;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* ============================================
   Botões
   ============================================ */
.btn {
    display: inline-block;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    touch-action: manipulation;
    min-height: 44px; /* Touch target mínimo */
    width: 100%;
}

.btn-primary {
    background-color: #3498db;
    color: #fff;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-primary:active {
    background-color: #21618c;
    transform: scale(0.98);
}

.btn-success {
    background-color: #27ae60;
    color: #fff;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
    color: #fff;
}

.btn-secondary {
    background-color: #95a5a6;
    color: #fff;
}

/* ============================================
   Alertas e Mensagens
   ============================================ */
.alert {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background-color: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.alert-success {
    background-color: #efe;
    color: #3c3;
    border: 1px solid #cfc;
}

.alert-info {
    background-color: #e8f4f8;
    color: #2980b9;
    border: 1px solid #bde0f0;
}

/* ============================================
   Header da Aplicação (legado - mantido para compatibilidade)
   ============================================ */
.app-header {
    background-color: #2c3e50;
    color: #fff;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 20px;
    margin-bottom: 5px;
}

.app-header .user-info {
    font-size: 14px;
    opacity: 0.9;
}

.app-header .logout-link {
    float: right;
    color: #fff;
    text-decoration: none;
    padding: 8px 15px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin-top: -35px;
    font-size: 14px;
    touch-action: manipulation;
}

/* ============================================
   Menu de Navegação
   ============================================ */
/* Estilos globais do menu estão em menu.php para evitar conflitos */
/* Mantendo apenas estilos básicos aqui para compatibilidade */

.nav-link {
    -webkit-tap-highlight-color: transparent !important;
}

.nav-link:active {
    transform: scale(0.98);
}

.nav-link-logout {
    -webkit-tap-highlight-color: transparent !important;
}

.nav-link-logout:active {
    transform: scale(0.98);
}

/* ============================================
   Tela de Leitura
   ============================================ */
.leitura-container {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto 20px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#video {
    width: 100%;
    display: block;
}

#canvas {
    display: none;
}

/* Container para QuaggaJS */
#interactive.viewport {
    width: 100%;
    height: auto;
    position: relative;
    overflow: hidden;
}

#interactive.viewport canvas,
#interactive.viewport video {
    width: 100%;
    height: auto;
    display: block;
}

.camera-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    height: 200px;
    border: 2px solid #3498db;
    border-radius: 8px;
    pointer-events: none;
}

.scanning-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(52, 152, 219, 0.9);
    color: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
}

.camera-controls {
    text-align: center;
    margin: 20px 0;
}

.btn-camera {
    min-width: 120px;
    margin: 0 10px;
}

/* ============================================
   Produto Encontrado
   ============================================ */
.produto-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.produto-info h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 20px;
}

.produto-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.produto-details .detail-item {
    padding: 10px;
    background: #fff;
    border-radius: 4px;
}

.produto-details .detail-label {
    font-size: 12px;
    color: #7f8c8d;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.produto-details .detail-value {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.estoque-info {
    font-size: 18px;
    font-weight: 600;
    color: #27ae60;
}

/* ============================================
   Formulário de Ajuste
   ============================================ */
.ajuste-form {
    margin-top: 20px;
}

.quantidade-group {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.quantidade-group input {
    flex: 1;
    max-width: 200px;
}

.quantidade-buttons {
    display: flex;
    gap: 10px;
}

.btn-quantidade {
    width: 50px;
    height: 50px;
    padding: 0;
    font-size: 20px;
    min-height: 50px;
}

.tipo-operacao {
    margin-bottom: 15px;
}

.tipo-operacao label {
    display: inline-flex;
    align-items: center;
    margin-right: 20px;
    cursor: pointer;
    font-size: 16px;
}

.tipo-operacao input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    cursor: pointer;
}

/* ============================================
   Tabela de Histórico
   ============================================ */
.table-container {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: #2c3e50;
    color: #fff;
}

thead th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
}

tbody tr {
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background-color: #f8f9fa;
}

tbody td {
    padding: 15px;
    font-size: 14px;
}

.tipo-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.tipo-entrada {
    background-color: #d4edda;
    color: #155724;
}

.tipo-saida {
    background-color: #f8d7da;
    color: #721c24;
}

.tipo-ajuste {
    background-color: #fff3cd;
    color: #856404;
}

/* ============================================
   Responsividade
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .login-container {
        margin: 20px auto;
        padding: 20px;
    }
    
    .app-header h1 {
        font-size: 18px;
    }
    
    .app-header .logout-link {
        float: none;
        display: block;
        margin-top: 10px;
        text-align: center;
    }
    
    .camera-overlay {
        height: 150px;
    }
    
    .produto-details {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 12px;
    }
    
    thead th,
    tbody td {
        padding: 10px 8px;
    }
    
    .quantidade-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .quantidade-group input {
        max-width: 100%;
    }
}

/* ============================================
   Loading e Estados
   ============================================ */
.loading {
    text-align: center;
    padding: 40px;
    color: #7f8c8d;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   Melhorias de Touch
   ============================================ */
button, a, input[type="submit"], input[type="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

input, textarea, select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Previne zoom no iOS ao focar inputs */
@media screen and (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
}

