/* =====================================================================
   Daily Diary / Student Portal — Base + Mobile-Responsive Styles
   ===================================================================== */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: #f2f4f7;
  margin: 0;
  color: #222;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Navbar ---------- */
.navbar {
  background: #1e3a5f;
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.navbar a { color: #fff; text-decoration: none; margin-left: 16px; font-size: 14px; }
.navbar .brand { font-size: 18px; font-weight: bold; }

/* ---------- Layout ---------- */
.container { max-width: 1000px; margin: 24px auto; padding: 0 16px; }

.card {
  background: #fff;
  border-radius: 10px;
  padding: 22px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 20px;
}

h1, h2, h3 { color: #1e3a5f; }
h1 { font-size: clamp(20px, 5vw, 28px); }
h2 { font-size: clamp(18px, 4.5vw, 24px); }
h3 { font-size: clamp(15px, 4vw, 18px); }

/* ---------- Tables: horizontally scrollable on small screens ---------- */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; min-width: 480px; }
th, td { padding: 10px; border-bottom: 1px solid #e2e2e2; text-align: left; font-size: 14px; }
th { background: #eef2f7; white-space: nowrap; }

/* ---------- Forms: touch-friendly ---------- */
label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=password], input[type=date], input[type=month],
input[type=number], input[type=time], input[type=email], input[type=tel],
select, textarea {
  width: 100%;
  padding: 12px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
  min-height: 44px; /* comfortable touch target */
}
textarea { min-height: 90px; resize: vertical; }
select { -webkit-appearance: none; appearance: none; background: #fff; }

/* ---------- Buttons: touch-friendly (44px min tap target) ---------- */
.btn {
  display: inline-block;
  background: #1e3a5f;
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  text-decoration: none;
  margin-top: 14px;
  min-height: 44px;
  line-height: 1.2;
  text-align: center;
}
.btn:hover { background: #14283f; }
.btn:active { transform: scale(0.98); }
.btn-danger { background: #b32d2e; }
.btn-secondary { background: #6c757d; }

/* ---------- Alerts ---------- */
.alert { padding: 12px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #d4edda; color: #155724; }
.alert-error { background: #f8d7da; color: #721c24; }

/* ---------- Login box ---------- */
.login-box {
  max-width: 380px;
  margin: 80px auto;
  background: #fff;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; }
.badge-admin { background: #ffe0b2; color: #a05a00; }
.badge-teacher { background: #d1ecf1; color: #0c5460; }

.diary-image { max-width: 220px; width: 100%; border-radius: 8px; margin-top: 8px; border: 1px solid #ddd; }

/* ---------- Grid ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* =====================================================================
   RESPONSIVE BREAKPOINTS
   ===================================================================== */

/* Tablet and below */
@media (max-width: 768px) {
  .container { padding: 0 12px; margin: 16px auto; }
  .card { padding: 16px; border-radius: 8px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Phones */
@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }

  /* Navbar becomes a stacked, full-width bar */
  .navbar {
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
  }
  .navbar .brand { font-size: 16px; margin-bottom: 6px; }
  .navbar > div:not(.brand) {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 4px;
    width: 100%;
  }
  .navbar a {
    margin-left: 0;
    font-size: 13px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.12);
    border-radius: 5px;
  }
  .navbar span { font-size: 13px; display: block; margin-bottom: 4px; }

  .login-box { margin: 32px 16px; padding: 22px; max-width: none; }

  h1 { font-size: 20px; }
  h2 { font-size: 18px; }

  .btn { width: 100%; margin-top: 10px; }
  .btn + .btn { margin-left: 0 !important; }
  /* When two buttons sit side by side inline, stack them on phones */
  .card > .btn, .card > a.btn { display: block; }

  th, td { padding: 8px 6px; font-size: 13px; }

  .diary-image { max-width: 100%; }
}

/* Very small phones */
@media (max-width: 380px) {
  .container { padding: 0 8px; }
  .card { padding: 12px; }
  .btn { padding: 12px 14px; font-size: 14px; }
}
