/* TVK Grievance Management System - Modern Admin UI */
:root {
  --primary: #1e3a5f;
  --primary-dark: #0f2744;
  --primary-light: #2d5a8a;
  --accent: #e11d48;
  --accent-light: #fb7185;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0284c8;
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-ta: 'Noto Sans Tamil', 'Inter', sans-serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body.lang-ta { font-family: var(--font-ta); }

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--accent); }

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease, width .25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  min-height: var(--header-height);
}

.sidebar-brand .logo {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-brand small {
  font-size: .7rem;
  opacity: .7;
  font-weight: 400;
}

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

.nav-section {
  padding: .5rem 1.25rem .25rem;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .5;
  margin-top: .5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.25rem;
  color: rgba(255,255,255,.85);
  font-size: .9rem;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--accent);
}

.nav-item svg, .nav-item .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: .9;
}

.nav-item .badge-count {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: .7rem;
  padding: .15rem .45rem;
  border-radius: 999px;
  font-weight: 600;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: .5rem;
  color: var(--text);
}

.page-title {
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-switch {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.lang-switch button {
  border: none;
  background: transparent;
  padding: .35rem .7rem;
  font-size: .8rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
}

.lang-switch button.active {
  background: var(--primary);
  color: #fff;
}

.notif-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: .5rem;
  color: var(--text-muted);
  border-radius: 8px;
}

.notif-btn:hover { background: var(--bg); color: var(--text); }

.notif-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid #fff;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  padding: .35rem .6rem;
  border-radius: 10px;
  transition: background .15s;
}

.user-menu:hover { background: var(--bg); }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
}

.user-info { line-height: 1.2; }
.user-info .name { font-weight: 600; font-size: .875rem; }
.user-info .role { font-size: .7rem; color: var(--text-muted); }

.content-area {
  flex: 1;
  padding: 1.5rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-header h2, .card-header h3 {
  font-size: 1rem;
  font-weight: 650;
}

.card-body { padding: 1.25rem; }

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: transform .15s, box-shadow .15s;
}

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

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green { background: #dcfce7; color: #15803d; }
.stat-icon.orange { background: #ffedd5; color: #c2410c; }
.stat-icon.red { background: #fee2e2; color: #b91c1c; }
.stat-icon.purple { background: #f3e8ff; color: #7e22ce; }
.stat-icon.cyan { background: #cffafe; color: #0e7490; }
.stat-icon.gray { background: #f1f5f9; color: #475569; }

.stat-content .value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-content .label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  font-size: .875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: #be123c; color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); border-color: var(--text-muted); }

.btn-sm {
  padding: .35rem .7rem;
  font-size: .8rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: .825rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text);
}

.form-label .required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: .6rem .85rem;
  font-size: .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(45, 90, 138, .15);
}

.form-control.is-invalid {
  border-color: var(--danger);
}

.form-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

.form-error {
  font-size: .75rem;
  color: var(--danger);
  margin-top: .25rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  padding-right: 2.2rem;
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.table th {
  text-align: left;
  padding: .75rem 1rem;
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .25rem .6rem;
  font-size: .75rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

/* Alerts */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  font-size: .9rem;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* Filters bar */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.filters-bar .form-group {
  margin-bottom: 0;
  min-width: 140px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 0;
  font-size: .875rem;
}

.pagination-links {
  display: flex;
  gap: .35rem;
}

.pagination-links a, .pagination-links span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 .5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}

.pagination-links a:hover { background: var(--bg); }
.pagination-links .active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 1.25rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.5rem;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item .time {
  font-size: .75rem;
  color: var(--text-muted);
}

.timeline-item .event {
  font-weight: 600;
  font-size: .9rem;
}

.timeline-item .detail {
  font-size: .825rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, #1e40af 100%);
  padding: 1.5rem;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 2rem;
}

.login-card .brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-card .brand .logo {
  width: 56px;
  height: 56px;
  background: var(--accent);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.4rem;
  margin-bottom: .75rem;
}

.login-card h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: .25rem;
}

/* Multi-step form */
.steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
  position: relative;
}

.steps::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  position: relative;
  z-index: 1;
  flex: 1;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: var(--text-muted);
}

.step.active .step-num {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step.done .step-num {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.step-label {
  font-size: .7rem;
  color: var(--text-muted);
  text-align: center;
}

.step.active .step-label { color: var(--primary); font-weight: 600; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: .5;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all .2s;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform .2s;
}

.modal-overlay.show .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body { padding: 1.35rem; }
.modal-footer {
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
}

/* Mobile */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .menu-toggle {
    display: block;
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
    display: none;
  }
  .sidebar-overlay.show {
    display: block;
  }
}

@media (max-width: 640px) {
  .content-area { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 1rem; }
  .user-info { display: none; }
  .filters-bar { flex-direction: column; }
  .filters-bar .form-group { width: 100%; }
}

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .825rem; }
.text-xs { font-size: .75rem; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Print */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .content-area { padding: 0; }
}