<?php
session_start();
require_once '../config.php';

$maxDiscount = 0.00;

$res = $conn->query("SELECT discount_percent FROM discount_settings ORDER BY id DESC LIMIT 1");
if ($res && $row = $res->fetch_assoc()) {
    $maxDiscount = (float)$row['discount_percent'];
}
function e($v){ return htmlspecialchars($v ?? '', ENT_QUOTES); }

// Prefill (optional)
$prefill = $_SESSION['last_invoice'] ?? null;
$cname = $prefill['customer_name'] ?? '';
$cgst  = $prefill['customer_gst'] ?? '';
$phone = $prefill['phone'] ?? '';
$discount = $prefill['discount_percent'] ?? '';
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Customer Information</title>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">

<style>
body{
  font-family:Inter,Arial,Helvetica,sans-serif;
  background:#eef2f7;
  margin:0;
}

/* Sidebar spacing */
.container{
  margin-left:260px;
  padding:30px;
}

/* Center card */
.card{
  max-width:720px;
  margin:40px auto;
  background:#ffffff;
  padding:24px;
  border-radius:16px;
  box-shadow:0 10px 30px rgba(0,0,0,0.05);
}

/* Title */
.title{
  font-size:19px;
  font-weight:700;
  color:#0f172a;
  margin-bottom:6px;
  display:flex;
  align-items:center;
  gap:10px;
}

.subtitle{
  color:#64748b;
  font-size:12.5px;
  margin-bottom:25px;
}

/* Form */
.form-group{
  margin-bottom:14px;
}

label{
  display:block;
  font-size:13px;
  margin-bottom:6px;
  color:#1e293b;
}

/* Input */
.input{
  width:100%;
  height:42px;
  padding:0 12px;
  border-radius:12px;
  border:1px solid #e2e8f0;
  background:#f8fafc;
  font-size:13.5px;
  transition:0.2s;
}

.input:focus{
  outline:none;
  border-color:#3b82f6;
  background:#fff;
  box-shadow:0 0 0 2px rgba(59,130,246,0.1);
}

/* Button center */
.btn-wrap{
  display:flex;
  justify-content:center;
  margin-top:25px;
}

.btn{
  height:40px;
  padding:0 18px;
  border-radius:25px;
  border:none;
  background:#1e293b;
  color:#fff;
  font-size:13.5px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:8px;
  transition:0.2s;
}

.btn:hover{
  background:#0f172a;
}
/* ================= MOBILE RESPONSIVE ================= */
@media (max-width:768px){

  /* 🔥 REMOVE SIDEBAR GAP */
  .container{
    margin-left:0 !important;
    padding:15px;
  }

  body{
    padding-top:70px;
  }

  /* 🔥 CARD FULL WIDTH */
  .card{
    margin:10px auto;
    padding:18px;
    border-radius:14px;
  }

  /* TITLE */
  .title{
    font-size:17px;
  }

  .subtitle{
    font-size:12px;
  }

  /* 🔥 INPUT FIX */
  .input{
    height:40px;
    font-size:13px;
  }

  /* 🔥 BUTTON FULL WIDTH */
  .btn-wrap{
    width:100%;
  }

  .btn{
    width:100%;
    justify-content:center;
    height:42px;
  }

}
</style>

</head>
<body>

<?php include 'salesmanagersidebar.php'; ?>
<?php include '../header.php'; ?>

<div class="container">

  <div class="card">

    <div class="title">
      <i class="fa fa-user"></i> Customer Information
    </div>

    <div class="subtitle">
      All fields optional — click Create Bill to continue.
    </div>

<!-- REMOVE these two full blocks completely -->
<!-- Customer GST No -->
<!-- Discounts (%) -->

<!-- REPLACE form section with this exact input structure -->

<form method="get" action="create_bill.php">

  <div class="form-group">
    <label>Consignee Name</label>
    <input class="input" type="text" name="consignee_name" placeholder="Optional">
  </div>

  <div class="form-group">
    <label>Consignee Address</label>
    <textarea class="input" name="consignee_address" style="height:90px;padding:12px;" placeholder="Optional"></textarea>
  </div>

  <div class="form-group">
    <label>Consignee Contact Details</label>
    <textarea class="input" name="consignee_contact" style="height:90px;padding:12px;" placeholder="Name / TEL / Mail"></textarea>
  </div>

  <div class="form-group">
    <label>Buyer Name</label>
    <input class="input" type="text" name="buyer_name" placeholder="Optional">
  </div>

  <div class="form-group">
    <label>Buyer Address</label>
    <textarea class="input" name="buyer_address" style="height:90px;padding:12px;" placeholder="Optional"></textarea>
  </div>

  <div class="form-group">
    <label>Buyer Contact Details</label>
    <textarea class="input" name="buyer_contact" style="height:90px;padding:12px;" placeholder="Name / TEL / Mail"></textarea>
  </div>

  <div class="form-group">
  <label>Consignee Phone</label>
  <input class="input" type="text" name="consignee_phone" placeholder="Optional">
</div>

<div class="form-group">
  <label>Buyer Phone</label>
  <input class="input" type="text" name="buyer_phone" placeholder="Optional">
</div>

  <div class="btn-wrap">
    <button type="submit" class="btn">
      <i class="fa fa-file-invoice"></i> Create Bill
    </button>
  </div>

</form>

  </div>

</div>

</body>
</html>