/**
 * Project Law - Custom Stylesheet
 * File: web/psis/ui/css/law-custom.css
 * Description: Shared CSS framework for Web-School Law Portal Redesign
 * Includes: Design tokens, typography engine, sticky flex layout, touch targets,
 *            micro-animations, button variants, status badges, and mobile responsive cards.
 */

/* ==========================================================================
   1. DESIGN TOKENS & CSS VARIABLES
   ========================================================================== */
:root {
  /* ==========================================================================
     60-30-10 UI/UX COLOR RULE CONFIGURATION:
     - 60% DOMINANT NEUTRAL  : Clean Soft Slate Canvas (#F8FAFC / #FFFFFF)
     - 30% SECONDARY STRUCTURE: Deep Slate Blue & Teal (#1E293B / #0D9488)
     - 10% VIBRANT ACCENT     : Neon Teal & Electric Blue Call-to-Action (#14B8A6 / #2563EB)
     ========================================================================== */
  
  /* 60% Dominant Neutral Surface Colors */
  --bg-60-main: #F8FAFC;          /* Clean Bright Slate Background (60%) */
  --bg-60-surface: #FFFFFF;       /* Pure White Surface (Card & Containers) */
  --bg-60-subtle: #F1F5F9;        /* Light Neutral Tint */
  --border-color: #E2E8F0;        /* Subtle Border */
  
  /* 30% Secondary Structural Colors */
  --color-30-primary: #1E293B;    /* Deep Slate Navy (Headers, Typography, Structure) */
  --color-30-dark: #0F172A;       /* Midnight Slate */
  --color-30-teal: #0D9488;       /* Deep Muted Teal (Structural Headers & Sub-titles) */
  --grad-30-header: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
  --grad-30-card-header: linear-gradient(135deg, #0D9488 0%, #1E293B 100%);
  --grad-30-hero-bg: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
  
  /* 10% Vibrant Accent Call-to-Action Colors (Pops out to guide user attention) */
  --accent-10-teal: #14B8A6;      /* Vibrant Neon Teal Accent (10%) */
  --accent-10-blue: #2563EB;      /* Vibrant Slate Blue CTA (10%) */
  --grad-10-btn-primary: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
  --grad-10-btn-emerald: linear-gradient(135deg, #0D9488 0%, #14B8A6 100%);
  
  /* Status Color Standard */
  --success-emerald: #10B981;
  --emerald-light: #ECFDF5;
  --danger-coral: #F43F5E;
  
  /* Typography Colors (High Contrast) */
  --text-main: #0F172A;           /* Deep Charcoal Body Text */
  --text-muted: #64748B;          /* 30% Subdued Structural Text */
  --text-white: #FFFFFF;
  
  /* Modern Reading Font Stack: Prompt & IBM Plex Sans Thai */
  --font-family-body: 'Prompt', 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-family-heading: 'Prompt', 'IBM Plex Sans Thai', sans-serif;
  
  /* Soft Clean Elevation & Shadows */
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 36px -8px rgba(15, 23, 42, 0.1);
  --shadow-hover: 0 20px 40px -8px rgba(37, 99, 235, 0.25);
  --shadow-cta-glow: 0 8px 20px rgba(37, 99, 235, 0.35);

  /* Radius & Transitions */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Backward-Compatible Aliases (old names -> new 60-30-10 tokens) */
  --bg-light: var(--bg-60-main);
  --bg-surface: var(--bg-60-surface);
  --bg-subtle: var(--bg-60-subtle);
  --primary-navy: var(--color-30-primary);
  --navy-dark: var(--color-30-dark);
  --navy-light: #334155;
  --accent-blue: var(--accent-10-blue);
  --accent-teal: var(--color-30-teal);
  --grad-header: var(--grad-30-header);
  --grad-card-header: var(--grad-30-card-header);
  --grad-hero-bg: var(--grad-30-hero-bg);
  --grad-btn-primary: var(--grad-10-btn-primary);
  --grad-btn-emerald: var(--grad-10-btn-emerald);
}

@import url('https://fonts.googleapis.com/css2?family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ==========================================================================
   2. RESET & BASE TYPOGRAPHY ENGINE (MODERN PROMPT FONT)
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body, button, input, select, textarea, .form-control, .btn, .navbar, .card, .menuHead, h1, h2, h3, h4, h5, h6, table, th, td, label, p, a, span:not([class*="fa-"]), div:not([class*="fa-"]), small, strong, b {
  font-family: 'Prompt', 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Ensure FontAwesome icons keep their icon fonts */
[class^="fa-"], [class*=" fa-"], .fa, .fas, .far, .fal, .fad, .fab, .fa-solid, .fa-regular, .fa-light, .fa-thin, .fa-duotone, .fa-brands, i[class*="fa-"] {
  font-family: "Font Awesome 6 Pro", "Font Awesome 6 Free", "FontAwesome" !important;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  color: #1E293B;
  background-color: var(--bg-60-main);
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, .heading-font {
  color: #0F172A;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 0;
}

h1 { font-size: 1.875rem; line-height: 2.25rem; }
h2 { font-size: 1.5rem; line-height: 2rem; }
h3 { font-size: 1.25rem; line-height: 1.75rem; }

a {
  color: var(--accent-10-blue);
  text-decoration: none;
  transition: var(--transition-fast);
}

a:hover {
  color: var(--color-30-primary);
  text-decoration: none;
}

/* ==========================================================================
   3. STICKY FLEX LAYOUT CONTAINER SYSTEM (FOOTER FIXED POSITION FIX)
   ========================================================================== */
html {
  height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-60-main);
}

.app-wrapper,
.wrapper,
body > form,
form#eduForm,
form.form-horizontal,
.content-wrapper {
  display: flex !important;
  flex-direction: column !important;
  min-height: 100vh !important;
  width: 100% !important;
  flex: 1 0 auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

.app-header {
  flex-shrink: 0;
}

section.content,
.app-main {
  flex: 1 0 auto !important;
  width: 100%;
}

/* Fixed Footer Floating Bug -> Change position to static/sticky flex footer */
.app-footer,
footer.site-footer,
.site-footer,
div.footer,
footer.footer,
.footer,
.main-footer {
  position: static !important;
  bottom: auto !important;
  left: auto !important;
  flex-shrink: 0 !important;
  margin-top: auto !important;
  width: 100% !important;
  background-color: var(--primary-navy) !important;
  color: var(--text-white) !important;
  padding: 0.6rem 0 !important;
  border-top: none !important;
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.05) !important;
}

.app-container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Glassmorphism Main Card Container */
.main-card-container {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.25rem;
  margin-top: 1rem;
  margin-bottom: 2.5rem;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

.main-card-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--grad-card-header);
}

/* Hero Section Upgrade - Earth Tone */
.hero-section {
  background: var(--grad-hero-bg) !important;
  border: 1px solid #D8D2C6 !important;
  border-radius: var(--radius-lg) !important;
  padding: 2.5rem 1.5rem !important;
  position: relative;
  overflow: hidden;
}

.hero-section::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(82, 121, 111, 0.12) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

/* Modern Input Search Bar with Glowing Focus - OPEC Bright Theme */
.search-bar-container .input-group {
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(30, 58, 138, 0.08);
  border: 2px solid #CBD5E1;
  transition: var(--transition-normal);
  background: #FFFFFF;
}

.search-bar-container .input-group:focus-within {
  border-color: var(--accent-blue);
  box-shadow: 0 0 24px rgba(37, 99, 235, 0.25);
  transform: translateY(-2px);
}

/* Custom DataTables Pagination Controls (10 - เธ—เธฑเน�เธ�เธซเธกเธ”) */
.dataTables_wrapper {
  font-family: var(--font-family-body);
  padding-top: 0.5rem;
}

.dataTables_length select {
  border-radius: var(--radius-sm) !important;
  padding: 0.35rem 0.75rem !important;
  border: 1px solid var(--border-color) !important;
  font-weight: 500 !important;
  color: var(--primary-navy) !important;
  margin: 0 0.4rem !important;
}

.dataTables_paginate .pagination {
  justify-content: flex-end;
  margin-top: 1rem;
  gap: 4px;
}

.dataTables_paginate .page-item .page-link {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--primary-navy) !important;
  font-weight: 500 !important;
  padding: 0.5rem 0.85rem !important;
  transition: var(--transition-fast) !important;
}

.dataTables_paginate .page-item.active .page-link {
  background: var(--grad-btn-primary) !important;
  border-color: var(--accent-blue) !important;
  color: #FFFFFF !important;
  box-shadow: var(--shadow-sm) !important;
}

/* Modern Compact Search Panel Styling */
.search-panel-modern {
  transition: var(--transition-normal);
}

.search-panel-modern:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1) !important;
}

.search-panel-modern:focus-within {
  border-color: #0D9488 !important;
  box-shadow: 0 8px 28px rgba(13, 148, 136, 0.15) !important;
}

.search-panel-modern .form-control,
.search-panel-modern .custom-select {
  border-radius: 10px;
  border: 1.5px solid #E2E8F0;
  font-size: 0.95rem;
  padding: 0.6rem 0.85rem;
  transition: var(--transition-fast);
  background-color: #F8FAFC;
}

.search-panel-modern .form-control:focus,
.search-panel-modern .custom-select:focus {
  border-color: #0D9488;
  background-color: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

/* 60% Dominant Canvas Layout */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-60-main);
}

.main-card-container {
  background: var(--bg-60-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2.25rem;
  margin-top: 1rem;
  margin-bottom: 2.5rem;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
}

/* 30% Secondary Structural Header & Navbar */
.navbar-opec,
.navbar-law {
  background: var(--grad-30-header) !important;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  padding: 0.85rem 1.5rem;
  min-height: 72px;
}

.hero-section {
  background: var(--grad-30-hero-bg) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  padding: 2.25rem 1.5rem !important;
}

.card-detail-modern .card-header-custom {
  background: var(--grad-30-card-header);
  color: var(--text-white);
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 10% Vibrant Accent Call-To-Action Buttons & Focus States */
.btn-primary-navy {
  background: var(--grad-10-btn-primary) !important;
  color: var(--text-white) !important;
  border: none !important;
  box-shadow: var(--shadow-cta-glow) !important;
}

.btn-primary-navy:hover {
  background: linear-gradient(135deg, #1D4ED8 0%, #1E40AF 100%) !important;
  color: var(--text-white) !important;
  transform: translateY(-2px);
}

.btn-emerald {
  background: var(--grad-10-btn-emerald) !important;
  color: var(--text-white) !important;
  border: none !important;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.25) !important;
}

.btn-emerald:hover {
  background: linear-gradient(135deg, #0F766E 0%, #0D9488 100%) !important;
  color: var(--text-white) !important;
  transform: translateY(-2px);
}

.search-panel-container:focus-within {
  box-shadow: 0 12px 32px -4px rgba(37, 99, 235, 0.15) !important;
  border-color: var(--accent-10-blue) !important;
}

.search-bar-container .form-control {
  border: none !important;
  padding-left: 1.5rem !important;
  font-size: 1.05rem !important;
  background: transparent !important;
}

.search-bar-container .btn-primary-navy {
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0 !important;
  padding-left: 1.75rem !important;
  padding-right: 1.75rem !important;
}

/* Table Design Upgrade */
.table-desktop {
  border-collapse: separate !important;
  border-spacing: 0 8px !important;
  background: transparent !important;
}

.table-desktop thead th {
  background: var(--primary-navy) !important;
  color: var(--text-white) !important;
  border: none !important;
  font-weight: 600 !important;
  letter-spacing: 0.03em;
  padding: 1rem 1.25rem !important;
}

.table-desktop thead th:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.table-desktop thead th:last-child { border-radius: 0 var(--radius-md) var(--radius-md) 0; }

.table-desktop tbody tr {
  background: #FFFFFF !important;
  box-shadow: var(--shadow-sm) !important;
  border-radius: var(--radius-md) !important;
  transition: var(--transition-normal) !important;
}

.table-desktop tbody tr:hover {
  transform: translateY(-3px) scale(1.002) !important;
  box-shadow: var(--shadow-hover) !important;
  background: #FFFFFF !important;
}

.table-desktop tbody td {
  border: none !important;
  padding: 1.15rem 1.25rem !important;
  border-top: 1px solid var(--border-color) !important;
  border-bottom: 1px solid var(--border-color) !important;
}

.table-desktop tbody td:first-child {
  border-left: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) 0 0 var(--radius-md) !important;
}

.table-desktop tbody td:last-child {
  border-right: 1px solid var(--border-color) !important;
  border-radius: 0 var(--radius-md) var(--radius-md) 0 !important;
}

/* ==========================================================================
   4. TOUCH TARGET MINIMUM RULES & FORM CONTROLS
   ========================================================================== */
/* WCAG AA 44px Minimum Touch Target Rule */
.min-touch-target,
.btn-custom,
.btn-action,
.form-control-custom,
.custom-select-lg,
.nav-link-custom {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.form-control-custom {
  width: 100%;
  padding: 0.625rem 1rem;
  font-size: 1rem;
  font-family: var(--font-family-body);
  color: var(--text-main);
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
}

.form-control-custom:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* ==========================================================================
   5. BUTTON VARIANTS & MICRO-ANIMATIONS
   ========================================================================== */
.btn-transition {
  transition: var(--transition-normal);
  cursor: pointer;
  border: none;
}

.hover-lift {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.hover-shadow:hover {
  box-shadow: var(--shadow-lg);
}

/* Custom Button Variants */
.btn-custom {
  font-family: var(--font-family-body);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  gap: 0.5rem;
  text-decoration: none;
}

.btn-primary-navy {
  background-color: var(--primary-navy);
  color: var(--text-white);
  border: 1px solid var(--primary-navy);
}

.btn-primary-navy:hover {
  background-color: var(--navy-dark);
  color: var(--text-white);
}

.btn-emerald {
  background-color: var(--success-emerald);
  color: var(--text-white);
  border: 1px solid var(--success-emerald);
}

.btn-emerald:hover {
  background-color: var(--emerald-dark);
  color: var(--text-white);
}

.btn-outline-custom {
  background-color: transparent;
  color: var(--primary-navy);
  border: 1.5px solid var(--primary-navy);
}

.btn-outline-custom:hover {
  background-color: var(--primary-navy);
  color: var(--text-white);
}

/* ==========================================================================
   6. NAVBAR OVERRIDES & BRANDING STYLING
   ========================================================================== */
.navbar-opec,
.navbar-law {
  background: var(--grad-header) !important;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.15);
  padding: 0.85rem 1.5rem;
  min-height: 72px;
}

.navbar-opec .navbar-brand,
.navbar-law .navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-white) !important;
  font-family: var(--font-family-heading);
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.navbar-opec .nav-link,
.navbar-law .nav-link {
  color: rgba(255, 255, 255, 0.9) !important;
  font-weight: 500;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-pill);
  transition: var(--transition-fast);
}

.navbar-opec .nav-link:hover,
.navbar-law .nav-link:hover {
  color: var(--text-white) !important;
  background-color: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
}

/* Standardized Bootstrap 4.6 Navbar Toggler Hamburger Button */
.navbar-toggler {
  padding: 0.5rem 0.75rem;
  font-size: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  color: var(--text-white);
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.95%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* ==========================================================================
   7. CARD & DETAIL VIEW LAYOUT
   ========================================================================== */
.card-detail-modern {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.card-detail-modern .card-header-custom {
  background: var(--grad-card-header);
  color: var(--text-white);
  padding: 1.35rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-detail-modern .card-body-custom {
  padding: 2rem 1.5rem;
}

.detail-row {
  display: flex;
  flex-wrap: wrap;
  padding: 0.875rem 0;
  border-bottom: 1px dashed var(--border-color);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  flex: 0 0 30%;
  max-width: 30%;
  font-weight: 600;
  color: var(--navy-dark);
}

.detail-value {
  flex: 0 0 70%;
  max-width: 70%;
  color: var(--text-main);
  line-height: 1.6;
}

/* ==========================================================================
   8. STATUS BADGES
   ========================================================================== */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 0.35em 0.75em;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
}

.badge-status-active {
  background-color: var(--emerald-light);
  color: var(--emerald-dark);
}

.badge-status-inactive {
  background-color: #FEE2E2;
  color: var(--danger-dark);
}

/* ==========================================================================
   9. MOBILE RESPONSIVE CARD VIEW & BREAKPOINTS (@media max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
  .app-container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .main-card-container {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .filter-section {
    flex-direction: column;
    gap: 0.75rem;
  }

  .detail-label,
  .detail-value {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .detail-label {
    margin-bottom: 0.25rem;
  }

  /* Mobile Card View Classes */
  .table-desktop {
    display: none !important;
  }

  .mobile-law-card {
    display: block;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
  }

  .mobile-law-card .card-law-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-navy);
    margin-bottom: 0.5rem;
  }

  .mobile-law-card .card-law-meta {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
  }

  .mobile-law-card .card-law-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
  }

  .mobile-law-card .card-law-actions .btn {
    flex: 1;
    text-align: center;
  }
}

@media (min-width: 769px) {
  .mobile-law-card {
    display: none !important;
  }
  
  .table-desktop {
    display: table;
  }
}
