@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Playfair+Display:wght@600;700&display=swap');

:root, .light {
  /* LIGHT THEME (Default) */
  --bg-main: #fcfcfc;
  --bg-card: #ffffff;
  --bg-sidebar: #f7f7f8;
  --bg-hover: #f1f1f3;
  
  --border-color: #e5e5e5;
  --border-focus: #111111;
  
  --text-main: #111111;
  --text-muted: #666666;
  --text-inverse: #ffffff;
  
  /* Brand Colors - Classy Deep Emerald & Gold */
  --brand-primary: #1e3a2b; /* Deep classy green */
  --brand-primary-hover: #152b1f;
  --brand-accent: #c4a661; /* Soft matte gold for bg */
  --brand-accent-text: #967a3a; /* Darker gold for text readability */
  
  /* Status Colors */
  --danger-bg: #fef2f2;
  --danger-text: #b91c1c;
  --danger-border: #f87171;
  
  --success-bg: #f0fdf4;
  --success-text: #15803d;
  
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  --transition: all 0.15s ease-in-out;
}

/* DARK THEME */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg-main: #0a0a0a;
    --bg-card: #141414;
    --bg-sidebar: #0f0f0f;
    --bg-hover: #1f1f1f;
    
    --border-color: #262626;
    --border-focus: #ededed;
    
    --text-main: #ededed;
    --text-muted: #a3a3a3;
    --text-inverse: #0a0a0a;
    
    /* Brand adjustments for dark mode */
    --brand-primary: #2a513d;
    --brand-primary-hover: #35664d;
    --brand-accent: #d8ba73;
    --brand-accent-text: #d8ba73;
    
    --danger-bg: rgba(153, 27, 27, 0.1);
    --danger-text: #f87171;
    --danger-border: rgba(248, 113, 113, 0.3);
    
    --success-bg: rgba(21, 128, 61, 0.1);
    --success-text: #4ade80;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  }
}

/* Allow manual override via class="dark" */
.dark {
  --bg-main: #0a0a0a;
  --bg-card: #141414;
  --bg-sidebar: #0f0f0f;
  --bg-hover: #1f1f1f;
  --border-color: #262626;
  --border-focus: #ededed;
  --text-main: #ededed;
  --text-muted: #a3a3a3;
  --text-inverse: #0a0a0a;
  --brand-primary: #2a513d;
  --brand-primary-hover: #35664d;
  --brand-accent: #d8ba73;
  --brand-accent-text: #d8ba73;
  --danger-bg: rgba(153, 27, 27, 0.1);
  --danger-text: #f87171;
  --danger-border: rgba(248, 113, 113, 0.3);
  --success-bg: rgba(21, 128, 61, 0.1);
  --success-text: #4ade80;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* TYPOGRAPHY */
h1, h2, h3, h4 {
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.ru-title {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
}

.ru-subtitle {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

/* LAYOUTS */
.ru-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background-color: var(--bg-main);
}

.ru-sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.ru-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.ru-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

.ru-content {
  padding: 2.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* CARDS */
.ru-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* BUTTONS */
.ru-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  outline: none;
}

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

.ru-btn-gold {
  background-color: var(--brand-accent);
  color: #111111 !important;
  border-color: var(--brand-accent);
  font-weight: 700;
}

.ru-btn-gold:hover:not(:disabled) {
  background-color: #e5cd8d;
  border-color: #e5cd8d;
  color: #111111 !important;
}

.ru-btn-outline {
  background-color: transparent;
  color: var(--text-main);
  border-color: var(--border-color);
}

.ru-btn-outline:hover:not(:disabled) {
  background-color: var(--bg-hover);
  border-color: var(--text-muted);
}

.ru-btn-outline-gold {
  background-color: transparent;
  color: var(--brand-accent-text);
  border-color: var(--brand-accent);
}

.ru-btn-outline-gold:hover:not(:disabled) {
  background-color: var(--brand-accent);
  color: #111111 !important;
}

.ru-input-group {
  margin-bottom: 1.25rem;
}

/* CUSTOM UTILITIES FOR GOLD OPACITY */
.bg-ruang-gold\/5 { background-color: rgba(196, 166, 97, 0.05); }
.bg-ruang-gold\/10 { background-color: rgba(196, 166, 97, 0.1); }
.bg-ruang-gold\/15 { background-color: rgba(196, 166, 97, 0.15); }
.bg-ruang-gold\/20 { background-color: rgba(196, 166, 97, 0.2); }
.bg-ruang-gold\/30 { background-color: rgba(196, 166, 97, 0.3); }
.bg-ruang-gold\/50 { background-color: rgba(196, 166, 97, 0.5); }
.border-ruang-gold\/20 { border-color: rgba(196, 166, 97, 0.2); }
.border-ruang-gold\/30 { border-color: rgba(196, 166, 97, 0.3); }
.hover\:bg-ruang-gold\/20:hover { background-color: rgba(196, 166, 97, 0.2); }
.hover\:bg-ruang-gold\/30:hover { background-color: rgba(196, 166, 97, 0.3); }
.hover\:bg-ruang-gold\/50:hover { background-color: rgba(196, 166, 97, 0.5); }
.border-ruang-gold-deep\/20 { border-color: rgba(216, 186, 115, 0.2); }
.text-on-gold { color: #111111 !important; }

.ru-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.ru-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.ru-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--border-focus);
}

.ru-input::placeholder {
  color: var(--text-muted);
}

/* ALERTS */
.ru-alert {
  padding: 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
}

.ru-alert-danger {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}

/* --- LAYOUT UTILITIES --- */
.hidden { display: none !important; }
.block { display: block; }

/* LOGIN SPECIFIC */
.ru-login-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  background-color: var(--bg-sidebar);
}

.ru-login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.ru-login-header img {
  display: block;
  margin: 0 auto 1.5rem auto;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.ru-login-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.ru-login-card {
  width: 100%;
  max-width: 400px;
  background-color: var(--bg-card);
  padding: 2.5rem 2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

/* GRIDS */
.ru-grid {
  display: grid;
  gap: 1.5rem;
}
.ru-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1024px) {
  .ru-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .ru-grid-3 { grid-template-columns: 1fr; }
}

/* ABSOLUTE REACTIVE COLOR OVERRIDES (Overrides conflicting Tailwind utilities) */
body {
  color: var(--text-main);
}

/* Force all standard Tailwind white/gray text to map to our semantic variables */
.text-white, .text-slate-100, .text-slate-200, .text-gray-100, .text-gray-200, .text-gray-800, .text-slate-800, .text-slate-900, .text-ruang-900 {
  color: var(--text-main) !important;
}

.text-gray-400, .text-gray-500, .text-slate-400, .text-slate-500, .text-ruang-text-soft, .text-ruang-text-muted {
  color: var(--text-muted) !important;
}

/* Ensure Gold text stays gold (with light/dark mode contrast adjustment) */
.text-ruang-gold, .text-ruang-gold-bright, .text-amber-500, .text-amber-600 {
  color: var(--brand-accent-text) !important;
}

/* Exception: Gold buttons should ALWAYS have dark text for maximum contrast in both Light & Dark modes */
.bg-ruang-gold, button.bg-ruang-gold, .bg-ruang-gold span, .bg-ruang-gold svg {
  color: #111111 !important;
}

/* Exception: Indigo/Purple/Red buttons usually need pure white text regardless of mode */
.bg-indigo-500, .bg-purple-500, .bg-red-500, .bg-red-600, .bg-green-600,
button.bg-indigo-500, button.bg-purple-500, button.bg-red-500 {
  color: #ffffff !important;
}

/* Absolute backgrounds for legacy tailwind classes */
.bg-slate-800, .bg-gray-800, .bg-ruang-800 {
  background-color: var(--bg-card) !important;
}
.bg-slate-900, .bg-gray-900, .bg-ruang-900 {
  background-color: var(--bg-main) !important;
}
.border-slate-700, .border-slate-800, .border-gray-700, .border-gray-800, .border-ruang-700 {
  border-color: var(--border-color) !important;
}

/* Missing text and accent mappings */
.text-ruang-text { color: var(--text-main) !important; }
.bg-ruang-700 { background-color: var(--border-color) !important; }
.bg-ruang-gold, .bg-ruang-gold-bright { background-color: var(--brand-accent) !important; color: #111111 !important; }
.border-ruang-gold, .border-ruang-gold-bright { border-color: var(--brand-accent) !important; }
.border-ruang-gold-deep { border-color: var(--brand-primary) !important; }

/* Tailwind hover fixes for gold buttons */
.hover\:bg-ruang-gold:hover { background-color: var(--brand-accent) !important; color: #111111 !important; }
.hover\:bg-ruang-gold-bright:hover { background-color: #e5cd8d !important; color: #111111 !important; }
.hover\:text-on-gold:hover { color: #111111 !important; }

/* ==========================================================================
   MOBILE RESPONSIVENESS (GOD-TIER)
   ========================================================================== */

/* LEGACY TAILWIND GRID FALLBACKS */
.grid { display: grid; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

/* Default to 1 column on mobile */
.grid-cols-1, .grid-cols-2, .grid-cols-3, .grid-cols-4,
.md\:grid-cols-2, .md\:grid-cols-3, .md\:grid-cols-4,
.lg\:grid-cols-2, .lg\:grid-cols-3, .lg\:grid-cols-4 {
  grid-template-columns: 1fr;
}

/* On desktop, restore columns */
@media (min-width: 769px) {
  .md\:grid-cols-2, .grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
  .md\:grid-cols-3, .grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
  .md\:grid-cols-4, .grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Flex legacy classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.w-full { width: 100%; }
.h-full { height: 100%; }

/* Layout Restructuring for Mobile */
@media (max-width: 768px) {
  .ru-layout {
    flex-direction: column;
    overflow-y: auto;
  }
  
  .ru-sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    position: relative; /* Prevent sidebar from overlapping */
    flex-shrink: 0;
  }

  /* Make sidebar nav elements wrap */
  .ru-sidebar nav {
    display: flex;
    flex-wrap: wrap;
    padding: 0 0.5rem;
  }
  
  .ru-sidebar nav a, .ru-sidebar nav div {
    flex: 1 1 auto;
    justify-content: center;
    border: 1px solid var(--border-color) !important;
    margin: 0.25rem !important;
    border-radius: var(--radius-md) !important;
    text-align: center;
    padding: 0.75rem 0.5rem !important;
  }
  
  /* Reset height of scrollable main so it scrolls naturally in the page */
  .ru-main {
    overflow-y: visible;
    height: auto;
  }
  
  .ru-content {
    padding: 1rem;
  }
  
  /* Make Data Tables scrollable horizontally */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
  }
  
  /* Fix HR Slide-over Modal size on mobile */
  .fixed .w-full, .fixed .md\:w-\[85vw\] {
    width: 100vw !important;
    height: 100vh !important;
  }
  
  /* Smaller texts on mobile */
  .text-4xl { font-size: 2rem !important; }
  .p-8 { padding: 1rem !important; }
}
