/* ============================================
   SISTEM IKD MBSJ - Main Stylesheet
   ============================================ */

:root {
  --primary: #1a237e;
  --primary-light: #3949ab;
  --primary-dark: #0d1554;
  --secondary: #0277bd;
  --accent: #00897b;
  --success: #2e7d32;
  --warning: #f57f17;
  --danger: #c62828;
  --info: #0288d1;
  --bg-light: #f5f7fa;
  --bg-white: #ffffff;
  --text-dark: #212121;
  --text-muted: #757575;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 260px;
  --header-height: 64px;
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
  line-height: 1.6;
  min-height: 100vh;
}

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

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

.login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  font-weight: bold;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.form-select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: white;
  cursor: pointer;
  outline: none;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
}

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

.btn-secondary {
  background: var(--bg-light);
  color: var(--text-dark);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #1b5e20;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #8e0000;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn-icon {
  padding: 8px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-light);
  color: var(--primary);
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  overflow-y: auto;
}

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

.sidebar-logo {
  width: 48px;
  height: 48px;
  background: white;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-weight: bold;
  font-size: 18px;
}

.sidebar-brand {
  font-size: 16px;
  font-weight: 700;
}

.sidebar-brand-sub {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
}

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

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.5;
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.nav-item.active {
  background: var(--primary-light);
  color: white;
  font-weight: 600;
}

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

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  opacity: 0.6;
  text-align: center;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

/* Header */
.header {
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-title {
  font-size: 18px;
  font-weight: 600;
}

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

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

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

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.user-info {
  text-align: left;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* Page Content */
.page-content {
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   CARDS & STATS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

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

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

.stat-icon.blue { background: #e3f2fd; color: #1565c0; }
.stat-icon.green { background: #e8f5e9; color: #2e7d32; }
.stat-icon.orange { background: #fff3e0; color: #e65100; }
.stat-icon.red { background: #fce4ec; color: #c62828; }
.stat-icon.purple { background: #f3e5f5; color: #6a1b9a; }
.stat-icon.teal { background: #e0f2f1; color: #00695c; }

.stat-info h3 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-info p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================
   TABLES
   ============================================ */
.card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

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

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-light);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:hover {
  background: #f8f9ff;
}

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

/* ============================================
   BADGES & STATUS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fff3e0; color: #e65100; }
.badge-danger { background: #fce4ec; color: #c62828; }
.badge-info { background: #e3f2fd; color: #1565c0; }
.badge-secondary { background: #f5f5f5; color: #616161; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  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(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ============================================
   FORM LAYOUTS
   ============================================ */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-row.single {
  grid-template-columns: 1fr;
}

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

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-item {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}

.tab-item:hover {
  color: var(--primary);
}

.tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================
   UPLOAD AREA
   ============================================ */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.upload-area:hover {
  border-color: var(--primary);
  background: #f8f9ff;
}

.upload-area .upload-icon {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.upload-area p {
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   IMAGE GRID (EKSA)
   ============================================ */
.image-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.image-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.image-card .image-placeholder {
  height: 160px;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

.image-card .image-label {
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  background: var(--bg-light);
}

/* ============================================
   SCORING (EKSA)
   ============================================ */
.score-input {
  display: flex;
  align-items: center;
  gap: 12px;
}

.score-input input {
  width: 80px;
  text-align: center;
  padding: 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
}

.score-input span {
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================
   SEARCH BAR
   ============================================ */
.search-bar {
  position: relative;
  max-width: 360px;
}

.search-bar input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
}

.search-bar input:focus {
  border-color: var(--primary);
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ============================================
   RESPONSIVE
   ============================================ */
/* ============================================
   RESPONSIVE - TABLET (iPad)
   ============================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .page-content {
    padding: 16px;
  }
  
  .modal {
    max-width: 90vw !important;
  }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    position: fixed;
    z-index: 1000;
  }
  
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .header {
    padding: 0 12px;
  }
  
  .header-title {
    font-size: 15px;
  }
  
  .page-content {
    padding: 12px;
  }
  
  .page-header h1 {
    font-size: 18px;
  }
  
  .page-header p {
    font-size: 12px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  
  .stat-card {
    padding: 14px;
    gap: 10px;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  .stat-info h3 {
    font-size: 22px;
  }
  
  .stat-info p {
    font-size: 11px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
  
  .image-grid {
    grid-template-columns: 1fr;
  }
  
  .card-header {
    padding: 14px 16px;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  
  .data-table th,
  .data-table td {
    padding: 8px 10px;
    font-size: 12px;
  }
  
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal-overlay {
    padding: 8px;
    align-items: flex-start;
  }
  
  .modal {
    max-width: 100% !important;
    max-height: 95vh;
    border-radius: 12px;
    margin-top: 8px;
  }
  
  .modal-header {
    padding: 14px 16px;
  }
  
  .modal-body {
    padding: 14px 16px !important;
  }
  
  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .filters-bar {
    width: 100%;
  }
  
  .filter-select {
    flex: 1;
    min-width: 0;
  }
  
  .search-bar {
    max-width: 100%;
    width: 100%;
  }
  
  .user-info {
    display: none;
  }
  
  .header-user {
    padding: 4px;
  }
  
  /* Login page mobile */
  .login-card {
    padding: 32px 24px;
  }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE
   ============================================ */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .stat-card {
    padding: 12px;
  }
  
  .stat-info h3 {
    font-size: 20px;
  }
  
  .page-header h1 {
    font-size: 16px;
  }
  
  .data-table th,
  .data-table td {
    padding: 6px 8px;
    font-size: 11px;
  }
  
  .btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
  }
}

/* ============================================
   TOUCH FRIENDLY
   ============================================ */
@media (pointer: coarse) {
  .btn-icon {
    padding: 10px;
    min-width: 40px;
    min-height: 40px;
  }
  
  .nav-item {
    padding: 12px 14px;
    min-height: 44px;
  }
  
  .form-control,
  .form-select {
    padding: 14px 16px;
    font-size: 16px;
  }
  
  .data-table td,
  .data-table th {
    padding: 12px 10px;
  }
  
  .filter-select {
    padding: 10px 14px;
  }
}

/* ============================================
   SIDEBAR OVERLAY (Mobile)
   ============================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 999;
}

.sidebar-overlay.active {
  display: block;
}

/* ============================================
   NOTIFICATION DOT
   ============================================ */
.notif-badge {
  position: relative;
}

.notif-badge::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* ============================================
   FILTERS BAR
   ============================================ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: white;
  cursor: pointer;
}


/* ============================================
   SWIPE ACTIONS (Mobile)
   ============================================ */
.swipe-row {
  position: relative;
  overflow: hidden;
}

.swipe-row .swipe-actions-left,
.swipe-row .swipe-actions-right {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.swipe-row .swipe-actions-left {
  left: 0;
  background: #2e7d32;
  padding: 0 16px;
  border-radius: 0 8px 8px 0;
}

.swipe-row .swipe-actions-right {
  right: 0;
  background: #c62828;
  padding: 0 16px;
  border-radius: 8px 0 0 8px;
}

.swipe-row.swiped-left .swipe-actions-right {
  opacity: 1;
}

.swipe-row.swiped-right .swipe-actions-left {
  opacity: 1;
}

.swipe-action-btn {
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* PWA Install Banner */
.pwa-install-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  max-width: 90%;
}

.pwa-install-banner button {
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pwa-install-banner .btn-install {
  background: #1a237e;
  color: white;
}

.pwa-install-banner .btn-dismiss {
  background: #f5f5f5;
  color: #666;
}
