/* =====================================================================
   GLOBAL THEME — Modern Gradient + Glassmorphism
   ===================================================================== */
:root {
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-accent: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-cool: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gradient-warm: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  --gradient-dark: linear-gradient(135deg, #232526 0%, #414345 100%);
  --gradient-bg: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
  
  --primary: #667eea;
  --primary-dark: #764ba2;
  --text-dark: #1a1a2e;
  --text-muted: #6b7280;
  
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.6);
  --shadow-sm: 0 4px 16px rgba(102, 126, 234, 0.08);
  --shadow-md: 0 8px 24px rgba(102, 126, 234, 0.12);
  --shadow-lg: 0 20px 40px rgba(102, 126, 234, 0.18);
}

* {
  box-sizing: border-box;
}

body.app-body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background: var(--gradient-bg);
  background-attachment: fixed;
  min-height: 100vh;
  color: var(--text-dark);
  position: relative;
  overflow-x: hidden;
}

/* Ornamen lingkaran gradient di background */
body.app-body::before,
body.app-body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  z-index: -1;
  pointer-events: none;
}
body.app-body::before {
  width: 500px;
  height: 500px;
  background: var(--gradient-accent);
  top: -200px;
  right: -200px;
  animation: float 20s ease-in-out infinite;
}
body.app-body::after {
  width: 400px;
  height: 400px;
  background: var(--gradient-cool);
  bottom: -150px;
  left: -150px;
  animation: float 25s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 40px) scale(1.1); }
}

/* =====================================================================
   NAVBAR — Glassmorphism
   ===================================================================== */
.navbar-glass {
  background: rgba(255, 255, 255, 0.75) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  padding: 0.6rem 0;
  transition: all 0.3s ease;
}

.navbar-spacer {
  height: 76px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.2rem;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.brand-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 1.15rem;
}

.navbar-dark .navbar-toggler-icon {
  filter: invert(1);
}

.nav-link-modern {
  color: var(--text-dark) !important;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1rem !important;
  border-radius: 10px;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-link-modern:hover,
.nav-link-modern.active {
  background: var(--gradient-primary);
  color: white !important;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

/* User pill di navbar */
.user-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.9rem 0.4rem 0.4rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  backdrop-filter: blur(10px);
}

.user-pill-icon {
  width: 32px;
  height: 32px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.9rem;
}

.user-pill-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.user-pill-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-dark);
}

.user-pill-role {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-logout {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(245, 87, 108, 0.2);
  background: rgba(245, 87, 108, 0.08);
  color: #f5576c;
  transition: all 0.25s ease;
}

.btn-logout:hover {
  background: var(--gradient-accent);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(245, 87, 108, 0.4);
}

/* =====================================================================
   MAIN CONTENT
   ===================================================================== */
.main-content {
  position: relative;
  z-index: 1;
}

.footer-modern {
  border-top: 1px solid rgba(0,0,0,0.05);
  margin-top: 3rem;
}

/* =====================================================================
   CARD & BUTTONS
   ===================================================================== */
.card {
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}

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

.btn-primary {
  background: var(--gradient-primary);
  border: none;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-radius: 12px;
  padding: 0.65rem 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.35);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--gradient-primary);
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
  color: white;
}

.btn-outline-primary {
  border: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 600;
  border-radius: 12px;
}

.btn-outline-primary:hover {
  background: var(--gradient-primary);
  border-color: transparent;
  color: white;
  transform: translateY(-2px);
}

.form-control,
.form-select {
  border: 2px solid rgba(102, 126, 234, 0.15);
  border-radius: 12px;
  padding: 0.65rem 1rem;
  font-weight: 500;
  transition: all 0.25s ease;
  background: rgba(255,255,255,0.9);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
  background: white;
}

.form-label {
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.4rem;
}

/* =====================================================================
   TABLE MODERN
   ===================================================================== */
.table {
  border-radius: 16px;
  overflow: hidden;
}

.table thead th {
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: none;
  padding: 1rem;
}

.table tbody td {
  padding: 1rem;
  border-color: rgba(0,0,0,0.05);
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background: rgba(102, 126, 234, 0.04);
}

/* =====================================================================
   ALERT & BADGE
   ===================================================================== */
.alert {
  border: none;
  border-radius: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.badge {
  padding: 0.4em 0.8em;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.3px;
}

/* =====================================================================
   LOGIN PAGE — Center stage
   ===================================================================== */
.login-wrapper {
  min-height: calc(100vh - 200px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 3rem 2.5rem;
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.6s ease;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  width: 72px;
  height: 72px;
  background: var(--gradient-primary);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 2rem;
  margin: 0 auto 1.5rem;
  box-shadow: 0 12px 24px rgba(102, 126, 234, 0.4);
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 12px 24px rgba(102, 126, 234, 0.4); }
  50% { box-shadow: 0 16px 32px rgba(102, 126, 234, 0.6); }
}

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.25rem;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.login-footer {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed rgba(0,0,0,0.08);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* =====================================================================
   SIGNAUTRE PAD & VIEWER — Keep styling but upgrade
   ===================================================================== */
#canvasWrap {
  border: 2px dashed rgba(102, 126, 234, 0.4);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  min-height: 220px;
  transition: border-color 0.25s;
}

#canvasWrap:hover {
  border-color: var(--primary);
}

.sig-preview {
  max-width: 100%;
  max-height: 160px;
  object-fit: contain;
  background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/16px 16px;
  border-radius: 14px;
  padding: .5rem;
}

/* Nav tabs modern */
.nav-tabs {
  border: none;
  gap: 0.5rem;
}

.nav-tabs .nav-link {
  border: none;
  border-radius: 10px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.7rem 1.3rem;
  transition: all 0.25s;
  background: rgba(102, 126, 234, 0.06);
}

.nav-tabs .nav-link:hover {
  background: rgba(102, 126, 234, 0.12);
  color: var(--primary);
}

.nav-tabs .nav-link.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.35);
}

/* Viewer layout */
#viewerLayout { display: flex; gap: 1rem; min-height: 75vh; }
#thumbCol { width: 140px; flex: 0 0 auto; overflow-y: auto; max-height: 80vh; }
#thumbCol .thumb { 
  border: 2px solid transparent; 
  border-radius: 10px; 
  cursor: pointer; 
  margin-bottom: .5rem; 
  background: #fff; 
  overflow: hidden;
  transition: all 0.2s;
}
#thumbCol .thumb:hover { border-color: rgba(102,126,234,0.4); }
#thumbCol .thumb.active { border-color: var(--primary); box-shadow: 0 4px 12px rgba(102,126,234,0.3); }
#thumbCol canvas { width: 100%; height: auto; display: block; }
#mainCol { 
  flex: 1 1 auto; 
  overflow: auto; 
  background: linear-gradient(135deg, #f5f7fa 0%, #e4ecfb 100%); 
  border-radius: 16px; 
  padding: 1rem; 
  max-height: 80vh; 
  box-shadow: inset 0 0 20px rgba(102, 126, 234, 0.05);
}

#pdfStage { position: relative; margin: 0 auto; display: inline-block; line-height: 0; }
#pdfCanvas { display: block; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.15); border-radius: 4px; }
#overlay { position: absolute; inset: 0; pointer-events: auto; }

.sig-drag { 
  position: absolute; 
  cursor: grab; 
  user-select: none; 
  border: 2px dashed var(--primary); 
  background: rgba(102, 126, 234, 0.06); 
  touch-action: none;
  border-radius: 4px;
}
.sig-drag img { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.sig-drag .sig-close { 
  position: absolute; top: -10px; right: -10px; 
  background: linear-gradient(135deg, #f5576c, #f093fb); 
  color: #fff; border: none; border-radius: 50%; 
  width: 24px; height: 24px; font-size: 14px; 
  cursor: pointer; pointer-events: auto; 
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(245, 87, 108, 0.5);
}
.sig-drag .sig-resize { 
  position: absolute; right: -6px; bottom: -6px; 
  width: 16px; height: 16px; 
  background: var(--gradient-primary); 
  border-radius: 4px; cursor: nwse-resize; pointer-events: auto; 
}

.sig-existing { 
  position: absolute; pointer-events: none; opacity: .95; 
  border: 1px dotted rgba(0,0,0,0.2);
  border-radius: 4px;
}
.sig-existing img { display: block; width: 100%; height: 100%; object-fit: fill; }

/* Toolbar viewer */
#toolbar { display: flex; gap: .5rem; align-items: center; margin-bottom: .75rem; flex-wrap: wrap; }
#toolbar .pager { display: flex; gap: .25rem; align-items: center; }
#toolbar input[type=number] { width: 64px; }
#toolbar .btn-light { 
  background: rgba(255,255,255,0.9); 
  border: 1px solid rgba(102,126,234,0.15);
  color: var(--text-dark);
  border-radius: 10px;
}
#toolbar .btn-light:hover { background: var(--gradient-primary); color: white; }

/* Responsif */
@media (max-width: 992px) {
  .navbar-collapse { padding-top: 1rem; }
  .user-pill { margin-bottom: 0.5rem; }
}

@media (max-width: 768px) {
  #viewerLayout { flex-direction: column; }
  #thumbCol { 
    width: 100%; max-height: 100px; 
    display: flex; gap: .5rem; 
    overflow-x: auto; overflow-y: hidden; 
  }
  #thumbCol .thumb { width: 80px; flex: 0 0 auto; margin-bottom: 0; }
  #mainCol { max-height: none; }
  .login-card { padding: 2rem 1.5rem; }
}