/* ============================================================
   KPAC PORTAL - MAIN STYLESHEET
   Kushinga Phikelela Agricultural College
   ============================================================ */

:root {
  --green-dark:   #1a4731;
  --green-mid:    #2d6a4f;
  --green-light:  #52b788;
  --gold:         #c9a84c;
  --gold-light:   #f0d080;
  --cream:        #faf7f0;
  --white:        #ffffff;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-300:     #d1d5db;
  --gray-500:     #6b7280;
  --gray-700:     #374151;
  --gray-900:     #111827;
  --red:          #dc2626;
  --blue:         #2563eb;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.14);
  --radius:       10px;
  --radius-sm:    6px;
  --sidebar-w:    260px;
  --header-h:     64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--green-mid); text-decoration: none; }
a:hover { color: var(--green-dark); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 50%, var(--green-light) 100%);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo .crest {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 12px;
  border: 4px solid var(--gold);
}

.login-logo h1 {
  color: var(--green-dark);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
}

.login-logo p {
  color: var(--gray-500);
  font-size: 0.82rem;
  margin-top: 4px;
}

.login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.login-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: border-color 0.2s;
  background: var(--gray-50);
}

.login-form input:focus {
  outline: none;
  border-color: var(--green-mid);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}

.login-form .form-group { margin-bottom: 18px; }

.btn-login {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 8px;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26,71,49,0.4);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--gray-500);
  font-size: 0.82rem;
}

/* ============================================================
   PORTAL LAYOUT
   ============================================================ */
.portal-layout {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--green-dark);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform 0.3s;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

.sidebar-brand .crest {
  width: 56px;
  height: 56px;
  background: var(--gold);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin-bottom: 8px;
}

.sidebar-brand h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-light);
  line-height: 1.3;
}

.sidebar-brand p {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--green-light);
}

.sidebar-user-avatar-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--green-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  border: 2px solid var(--green-light);
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info strong {
  display: block;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-info span {
  font-size: 0.73rem;
  color: rgba(255,255,255,0.55);
  text-transform: capitalize;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  padding: 10px 20px 4px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  font-weight: 700;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: rgba(255,255,255,0.75);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav a span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.sidebar-nav a.active {
  background: rgba(82,183,136,0.2);
  color: var(--green-light);
  border-left-color: var(--green-light);
}

.sidebar-nav a .nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  padding: 8px 0;
  transition: color 0.15s;
}

.sidebar-footer a:hover { color: #ef4444; }

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.top-bar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-dark);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-info strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
}

.stat-info span {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 4px;
  display: block;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 22px;
}

.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gray-50);
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 22px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead tr { background: var(--green-dark); color: white; }
thead th { padding: 12px 14px; text-align: left; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background 0.1s; }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 11px 14px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  background: var(--gray-50);
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green-mid);
  background: white;
  box-shadow: 0 0 0 3px rgba(45,106,79,0.1);
}

.form-group textarea { resize: vertical; min-height: 90px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-primary { background: var(--green-mid); color: white; }
.btn-primary:hover { background: var(--green-dark); color: white; }

.btn-gold { background: var(--gold); color: var(--green-dark); }
.btn-gold:hover { background: var(--gold-light); color: var(--green-dark); }

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b91c1c; color: white; }

.btn-outline {
  background: transparent;
  color: var(--green-mid);
  border: 1.5px solid var(--green-mid);
}
.btn-outline:hover { background: var(--green-mid); color: white; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-200); color: var(--gray-700); }
.badge-urgent { background: #dc2626; color: white; }

/* ============================================================
   ANNOUNCEMENTS
   ============================================================ */
.announcement-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 14px;
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--green-mid);
  box-shadow: var(--shadow-sm);
}

.announcement-card.urgent { border-left-color: var(--red); }
.announcement-card.important { border-left-color: var(--gold); }

.announcement-card h3 {
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--green-dark);
}

.announcement-card p { font-size: 0.88rem; color: var(--gray-700); }

.announcement-card .ann-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.77rem;
  color: var(--gray-500);
}

/* ============================================================
   PROFILE SECTION
   ============================================================ */
.profile-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 28px;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  border-radius: var(--radius);
  color: white;
  margin-bottom: 22px;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(255,255,255,0.3);
}

.profile-avatar-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  font-weight: 700;
  border: 4px solid rgba(255,255,255,0.3);
}

.profile-info h2 { font-size: 1.4rem; margin-bottom: 4px; }
.profile-info p { color: rgba(255,255,255,0.75); font-size: 0.88rem; margin-bottom: 3px; }

.profile-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.detail-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.detail-item label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.detail-item span { font-size: 0.95rem; color: var(--gray-900); font-weight: 500; }

/* ============================================================
   BALANCE CARD
   ============================================================ */
.balance-card {
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 22px;
  text-align: center;
}

.balance-card.paid {
  background: linear-gradient(135deg, #065f46, #10b981);
  color: white;
}

.balance-card.owing {
  background: linear-gradient(135deg, #991b1b, #dc2626);
  color: white;
}

.balance-card .amount {
  font-size: 2.4rem;
  font-weight: 800;
  margin: 8px 0;
}

.balance-card p { opacity: 0.85; font-size: 0.9rem; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--green-dark);
  color: white;
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: white; cursor: pointer; font-size: 20px; line-height: 1; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-green { color: var(--green-mid); }
.text-red { color: var(--red); }
.text-muted { color: var(--gray-500); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-gap { display: flex; align-items: center; gap: 10px; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; color: var(--gray-700); margin-bottom: 6px; }
.empty-state p { font-size: 0.85rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); }
  .sidebar.open { transform: translateX(0); width: 260px; }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .profile-header { flex-direction: column; text-align: center; }
}

@media print {
  .sidebar, .top-bar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
}
