<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Breno Paiva Advocacia — Login</title>
    <link rel="stylesheet" href="<?php echo base_url('assets/bootstrap/css/bootstrap.min.css')?>">
    <link rel="stylesheet" href="<?php echo base_url('assets/css/font-awesome.min.css')?>">
    <?php if(!empty($turnstile_key)): ?>
    <script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
    <?php endif; ?>
    <style>
        body { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); min-height:100vh; display:flex; align-items:center; justify-content:center; font-family:'Segoe UI',Arial,sans-serif; }
        .login-wrapper { width:100%; max-width:420px; padding:20px; }
        .login-card { background:#fff; border-radius:12px; box-shadow:0 20px 60px rgba(0,0,0,0.4); overflow:hidden; }
        .login-header { background:linear-gradient(135deg,#1a1a2e,#0f3460); padding:35px 30px; text-align:center; }
        .login-header img { max-height:70px; max-width:240px; }
        .login-header h4 { color:#fff; margin-top:12px; font-size:14px; letter-spacing:2px; text-transform:uppercase; opacity:.8; }
        .login-body { padding:35px 30px; }
        .form-group { margin-bottom:20px; }
        .form-group label { font-weight:600; color:#333; font-size:13px; margin-bottom:6px; display:block; }
        .input-group-addon { background:#f8f9fa; border-color:#dee2e6; color:#6c757d; }
        .form-control { border-radius:0 6px 6px 0; border-color:#dee2e6; height:44px; font-size:14px; }
        .form-control:focus { border-color:#0f3460; box-shadow:0 0 0 3px rgba(15,52,96,.15); }
        .input-group { border-radius:6px; overflow:hidden; }
        .input-group .form-control { border-radius:0; }
        .input-group-addon:first-child { border-radius:6px 0 0 6px; }
        .btn-login { width:100%; height:46px; background:linear-gradient(135deg,#1a1a2e,#0f3460); border:none; color:#fff; font-size:15px; font-weight:600; border-radius:6px; letter-spacing:.5px; transition:all .3s; }
        .btn-login:hover { background:linear-gradient(135deg,#0f3460,#e94560); transform:translateY(-1px); box-shadow:0 4px 15px rgba(0,0,0,.3); }
        .alert { border-radius:6px; font-size:13px; padding:10px 14px; }
        .forgot-link { text-align:center; margin-top:18px; }
        .forgot-link a { color:#0f3460; font-size:13px; text-decoration:none; }
        .forgot-link a:hover { text-decoration:underline; }
        .login-footer { background:#f8f9fa; padding:14px; text-align:center; font-size:11px; color:#aaa; border-top:1px solid #eee; }
        .security-badge { display:flex; align-items:center; justify-content:center; gap:6px; font-size:11px; color:#888; margin-top:12px; }
        .cf-turnstile { margin:16px 0; display:flex; justify-content:center; }
        .toggle-pass { position:absolute; right:10px; top:50%; transform:translateY(-50%); cursor:pointer; color:#999; z-index:10; }
        .pass-wrapper { position:relative; }
        .pass-wrapper .form-control { border-radius:6px; padding-right:36px; }
    </style>
</head>
<body>
<div class="login-wrapper">
    <div class="login-card">
        <div class="login-header">
            <img src="<?php echo base_url('assets/uploads/images/Nova logo Breno Paiva Adv site.jpg')?>" alt="Breno Paiva Advocacia"
                 onerror="this.style.display='none'">
            <h4>Sistema de Gestão Jurídica</h4>
        </div>
        <div class="login-body">

            <?php if(!empty($error)): ?>
            <div class="alert alert-danger">
                <i class="fa fa-exclamation-triangle"></i> <?php echo $error?>
            </div>
            <?php endif; ?>

            <?php if($this->session->flashdata('message')): ?>
            <div class="alert alert-success">
                <i class="fa fa-check-circle"></i> <?php echo $this->session->flashdata('message')?>
            </div>
            <?php endif; ?>

            <form method="post" action="<?php echo site_url('admin/login')?>">
                <div class="form-group">
                    <label><i class="fa fa-user"></i> <?php echo lang('username')?></label>
                    <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-user"></i></span>
                        <input type="text" name="username" class="form-control" 
                               placeholder="<?php echo lang('username')?>" 
                               value="<?php echo set_value('username')?>" 
                               autocomplete="username" required>
                    </div>
                </div>

                <div class="form-group">
                    <label><i class="fa fa-lock"></i> <?php echo lang('password')?></label>
                    <div class="pass-wrapper">
                        <input type="password" name="password" id="inp-pass" class="form-control" 
                               placeholder="••••••••" autocomplete="current-password" required>
                        <span class="toggle-pass" onclick="togglePass()">
                            <i class="fa fa-eye" id="eye-icon"></i>
                        </span>
                    </div>
                </div>

                <?php if(!empty($turnstile_key)): ?>
                <div class="cf-turnstile" data-sitekey="<?php echo $turnstile_key?>"></div>
                <?php endif; ?>

                <input type="hidden" name="submitted" value="1">
                <button type="submit" class="btn btn-login">
                    <i class="fa fa-sign-in"></i> Entrar
                </button>
            </form>

            <div class="forgot-link">
                <a href="<?php echo site_url('forgot/forgot_password')?>">
                    <i class="fa fa-key"></i> Esqueci minha senha
                </a>
            </div>

            <div class="security-badge">
                <i class="fa fa-shield"></i>
                <span>Conexão segura · Bloqueio após <?php echo $max_attempts?> tentativas</span>
            </div>
        </div>
        <div class="login-footer">
            Breno Paiva Advocacia - Gerência de Tecnologia da Informação
        </div>
    </div>
</div>
<script>
function togglePass() {
    var inp = document.getElementById('inp-pass');
    var ico = document.getElementById('eye-icon');
    if (inp.type === 'password') {
        inp.type = 'text';
        ico.className = 'fa fa-eye-slash';
    } else {
        inp.type = 'password';
        ico.className = 'fa fa-eye';
    }
}
</script>
</body>
</html>
