/* ============================================================
   iPad Borrow System - Premium Stylesheet
   ระบบยืม-คืน iPad | สไตล์ชีทหลัก
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ============================================================
   CSS Variables / ตัวแปร CSS
   ============================================================ */
:root {
    /* สีหลัก */
    --primary:        #6C63FF;
    --primary-light:  #8B83FF;
    --primary-dark:   #5A52E0;
    --primary-glow:   rgba(108, 99, 255, 0.35);

    /* สีสถานะ */
    --success:        #00D68F;
    --success-light:  #33E0A5;
    --success-dark:   #00B377;
    --success-glow:   rgba(0, 214, 143, 0.30);

    --warning:        #FFB400;
    --warning-light:  #FFC840;
    --warning-dark:   #E0A000;
    --warning-glow:   rgba(255, 180, 0, 0.30);

    --danger:         #FF6B6B;
    --danger-light:   #FF8A8A;
    --danger-dark:    #E05555;
    --danger-glow:    rgba(255, 107, 107, 0.30);

    --info:           #00C9FF;
    --info-light:     #40D4FF;
    --info-dark:      #00A8D6;
    --info-glow:      rgba(0, 201, 255, 0.30);

    /* พื้นหลัง & พื้นผิว */
    --bg-gradient-1:  #0f0c29;
    --bg-gradient-2:  #302b63;
    --bg-gradient-3:  #24243e;
    --glass-bg:       rgba(255, 255, 255, 0.06);
    --glass-bg-hover: rgba(255, 255, 255, 0.10);
    --glass-border:   rgba(255, 255, 255, 0.12);
    --glass-border-hover: rgba(255, 255, 255, 0.22);
    --surface:        rgba(255, 255, 255, 0.04);
    --surface-hover:  rgba(255, 255, 255, 0.08);

    /* ข้อความ */
    --text-primary:   #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.65);
    --text-muted:     rgba(255, 255, 255, 0.40);
    --text-dark:      #1a1a2e;

    /* ตัวอักษร */
    --font-primary:   'Inter', 'Sarabun', sans-serif;
    --font-thai:      'Sarabun', 'Inter', sans-serif;

    /* ขนาด */
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      16px;
    --radius-xl:      24px;
    --radius-full:    9999px;

    /* เงา */
    --shadow-sm:      0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md:      0 4px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg:      0 8px 40px rgba(0, 0, 0, 0.35);
    --shadow-glow:    0 0 30px rgba(108, 99, 255, 0.20);

    /* Sidebar */
    --sidebar-width:  260px;
    --sidebar-collapsed: 0px;

    /* ความเร็ว Animation */
    --speed-fast:     0.15s;
    --speed-normal:   0.3s;
    --speed-slow:     0.5s;
}

/* ============================================================
   Reset & Base / รีเซ็ตและพื้นฐาน
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 50%, var(--bg-gradient-3) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ============================================================
   Custom Scrollbar / แถบเลื่อนแบบกำหนดเอง
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(108, 99, 255, 0.4);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(108, 99, 255, 0.6);
}

/* ============================================================
   Animations / แอนิเมชัน
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-30px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 5px var(--primary-glow); }
    50%      { box-shadow: 0 0 25px var(--primary-glow), 0 0 50px rgba(108, 99, 255, 0.10); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(100px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100px); }
}
@keyframes borderRotate {
    0%   { --angle: 0deg; }
    100% { --angle: 360deg; }
}

/* ============================================================
   Layout / โครงร่าง
   ============================================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    transition: margin-left var(--speed-normal) ease;
    animation: fadeIn var(--speed-slow) ease;
}

/* ============================================================
   Sidebar / แถบด้านข้าง
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(15, 12, 41, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--speed-normal) cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
}
.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--glass-border);
}
.sidebar-brand .brand-icon {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.35);
}
.sidebar-brand h1 {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: var(--text-primary);
}
.sidebar-brand span {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
}
.nav-section-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 12px 12px 6px;
    font-weight: 600;
}
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--speed-fast) ease;
    margin-bottom: 3px;
    position: relative;
}
.sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
}
.sidebar-nav .nav-link:hover {
    background: var(--glass-bg-hover);
    color: var(--text-primary);
    transform: translateX(4px);
}
.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.22), rgba(0, 201, 255, 0.10));
    color: var(--primary-light);
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(108, 99, 255, 0.25);
}
.sidebar-nav .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--glass-border);
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
}

/* ============================================================
   Top Bar / แถบด้านบน
   ============================================================ */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.top-bar-left h2 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.top-bar-left .breadcrumb-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.datetime-display {
    font-size: 0.82rem;
    color: var(--text-secondary);
    background: var(--glass-bg);
    padding: 8px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.datetime-display i {
    color: var(--primary-light);
}

/* ============================================================
   Search Bar / ช่องค้นหา
   ============================================================ */
.search-bar {
    position: relative;
    width: 260px;
    transition: width var(--speed-normal) ease;
}
.search-bar:focus-within {
    width: 340px;
}
.search-bar input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-primary);
    transition: all var(--speed-normal) ease;
    outline: none;
}
.search-bar input::placeholder {
    color: var(--text-muted);
}
.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(255, 255, 255, 0.08);
}
.search-bar .search-icon {
    position: absolute;
    left: 14px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
    transition: color var(--speed-fast) ease;
}
.search-bar input:focus + .search-icon,
.search-bar:focus-within .search-icon {
    color: var(--primary-light);
}

/* ============================================================
   Glassmorphism Card / การ์ดแบบกระจก
   ============================================================ */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--speed-normal) ease;
    animation: fadeInUp var(--speed-slow) ease both;
}
.glass-card:hover {
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============================================================
   Stats Cards / การ์ดสถิติ
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    position: relative;
    overflow: hidden;
    transition: all var(--speed-normal) cubic-bezier(.4,0,.2,1);
    animation: fadeInUp var(--speed-slow) ease both;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-card.blue::before   { background: linear-gradient(90deg, var(--info), var(--primary)); }
.stat-card.green::before  { background: linear-gradient(90deg, var(--success), #00E5A0); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--primary), #A78BFA); }
.stat-card.red::before    { background: linear-gradient(90deg, var(--danger), #FF9A8B); }

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--glass-border-hover);
}
.stat-card .stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.stat-card .stat-icon {
    width: 46px; height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
}
.stat-card.blue .stat-icon   { background: linear-gradient(135deg, var(--info), var(--primary)); box-shadow: 0 4px 15px var(--info-glow); }
.stat-card.green .stat-icon  { background: linear-gradient(135deg, var(--success), #00E5A0); box-shadow: 0 4px 15px var(--success-glow); }
.stat-card.purple .stat-icon { background: linear-gradient(135deg, var(--primary), #A78BFA); box-shadow: 0 4px 15px var(--primary-glow); }
.stat-card.red .stat-icon    { background: linear-gradient(135deg, var(--danger), #FF9A8B); box-shadow: 0 4px 15px var(--danger-glow); }

.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.01em;
}
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    animation: countUp var(--speed-slow) ease both;
}
.stat-card .stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    margin-top: 6px;
}
.stat-change.up   { color: var(--success); background: rgba(0, 214, 143, 0.12); }
.stat-change.down { color: var(--danger);  background: rgba(255, 107, 107, 0.12); }

/* ============================================================
   Quick Actions / ปุ่มลัด
   ============================================================ */
.quick-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
    animation: fadeInUp var(--speed-slow) ease 0.25s both;
}

/* ============================================================
   Buttons / ปุ่ม
   ============================================================ */
.btn-premium {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--radius-full);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--speed-normal) cubic-bezier(.4,0,.2,1);
    text-decoration: none;
    position: relative;
    overflow: hidden;
}
.btn-premium::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity var(--speed-fast);
}
.btn-premium:hover::after { opacity: 1; }
.btn-premium:active { transform: scale(0.97); }

.btn-primary-gradient {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--primary-glow);
    color: #fff;
}
.btn-success-gradient {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    color: #fff;
    box-shadow: 0 4px 15px var(--success-glow);
}
.btn-success-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--success-glow);
    color: #fff;
}
.btn-danger-gradient {
    background: linear-gradient(135deg, var(--danger), var(--danger-dark));
    color: #fff;
    box-shadow: 0 4px 15px var(--danger-glow);
}
.btn-danger-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px var(--danger-glow);
    color: #fff;
}
.btn-outline-glass {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
}
.btn-outline-glass:hover {
    background: var(--glass-bg-hover);
    border-color: var(--primary);
    color: var(--primary-light);
    transform: translateY(-2px);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 0.78rem;
}
.btn-lg {
    padding: 14px 32px;
    font-size: 0.95rem;
}
.btn-icon-only {
    width: 38px; height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

/* ============================================================
   Data Table / ตารางข้อมูล
   ============================================================ */
.table-section {
    animation: fadeInUp var(--speed-slow) ease 0.3s both;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}
.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title i {
    color: var(--primary-light);
}
.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--glass-bg);
    padding: 4px;
    border-radius: var(--radius-full);
    border: 1px solid var(--glass-border);
}
.filter-tab {
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--speed-fast) ease;
    border: none;
    background: transparent;
    font-family: var(--font-primary);
}
.filter-tab:hover { color: var(--text-primary); }
.filter-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.premium-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
}
.premium-table thead th {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border: none;
    background: transparent;
    white-space: nowrap;
}
.premium-table tbody tr {
    background: var(--glass-bg);
    transition: all var(--speed-fast) ease;
    border-radius: var(--radius-md);
}
.premium-table tbody tr:hover {
    background: var(--glass-bg-hover);
    transform: scale(1.005);
}
.premium-table tbody td {
    padding: 14px 16px;
    font-size: 0.85rem;
    border: none;
    vertical-align: middle;
    color: var(--text-secondary);
}
.premium-table tbody td:first-child { border-radius: var(--radius-md) 0 0 var(--radius-md); }
.premium-table tbody td:last-child  { border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.premium-table tbody tr:nth-child(even) {
    background: var(--surface);
}
.premium-table tbody tr:nth-child(even):hover {
    background: var(--surface-hover);
}

/* ============================================================
   Status Badges / ป้ายสถานะ
   ============================================================ */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-status .dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.badge-available     { background: rgba(0,214,143,0.12); color: var(--success); }
.badge-available .dot{ background: var(--success); box-shadow: 0 0 6px var(--success-glow); }
.badge-borrowed      { background: rgba(108,99,255,0.12); color: var(--primary-light); }
.badge-borrowed .dot { background: var(--primary); box-shadow: 0 0 6px var(--primary-glow); }
.badge-overdue       { background: rgba(255,107,107,0.12); color: var(--danger); }
.badge-overdue .dot  { background: var(--danger); box-shadow: 0 0 6px var(--danger-glow); animation: pulse 2s infinite; }
.badge-maintenance   { background: rgba(255,180,0,0.12); color: var(--warning); }
.badge-maintenance .dot { background: var(--warning); box-shadow: 0 0 6px var(--warning-glow); }

/* ============================================================
   iPad Grid Cards / การ์ดกริด iPad
   ============================================================ */
.ipad-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 18px;
    margin-top: 18px;
    animation: fadeInUp var(--speed-slow) ease 0.4s both;
}
.ipad-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--speed-normal) cubic-bezier(.4,0,.2,1);
    position: relative;
    overflow: hidden;
}
.ipad-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--glass-border-hover);
}
.ipad-card .ipad-status-dot {
    position: absolute;
    top: 16px; right: 16px;
    width: 10px; height: 10px;
    border-radius: 50%;
}
.ipad-card .ipad-status-dot.available   { background: var(--success); box-shadow: 0 0 8px var(--success-glow); }
.ipad-card .ipad-status-dot.borrowed    { background: var(--primary); box-shadow: 0 0 8px var(--primary-glow); }
.ipad-card .ipad-status-dot.maintenance { background: var(--warning); box-shadow: 0 0 8px var(--warning-glow); }
.ipad-card .ipad-icon {
    width: 52px; height: 52px;
    background: var(--surface);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}
.ipad-card .ipad-model {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 4px;
}
.ipad-card .ipad-serial {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    margin-bottom: 8px;
}
.ipad-card .ipad-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================================
   Forms / ฟอร์ม
   ============================================================ */
.form-floating-custom label,
.form-label-custom {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}
.form-control-glass {
    width: 100%;
    padding: 11px 16px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.88rem;
    transition: all var(--speed-normal) ease;
    outline: none;
}
.form-control-glass:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: rgba(255, 255, 255, 0.06);
}
.form-control-glass::placeholder {
    color: var(--text-muted);
}
.form-control-glass.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-glow);
}
.form-control-glass option {
    background: var(--bg-gradient-3);
    color: var(--text-primary);
}
select.form-control-glass {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.5)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.invalid-feedback-glass {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
    display: none;
}
.form-control-glass.is-invalid ~ .invalid-feedback-glass {
    display: block;
}
.form-group {
    margin-bottom: 18px;
}

/* ============================================================
   Modals / หน้าต่างป๊อปอัพ
   ============================================================ */
.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.60);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--speed-fast) ease;
}
.modal-backdrop-custom.show {
    display: flex;
}
.modal-glass {
    background: rgba(25, 22, 58, 0.92);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp var(--speed-normal) cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
}
.modal-glass .modal-header-glass {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 28px 0;
}
.modal-glass .modal-header-glass h3 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
.modal-glass .modal-header-glass h3 i {
    color: var(--primary-light);
}
.modal-close {
    width: 34px; height: 34px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--speed-fast) ease;
}
.modal-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.modal-glass .modal-body-glass {
    padding: 22px 28px;
}
.modal-glass .modal-footer-glass {
    padding: 0 28px 22px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ============================================================
   Toast Notifications / การแจ้งเตือน
   ============================================================ */
.toast-container {
    position: fixed;
    top: 24px; right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: rgba(25, 22, 58, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 420px;
    animation: toastIn var(--speed-normal) cubic-bezier(.4,0,.2,1);
    position: relative;
    overflow: hidden;
}
.toast-item.removing {
    animation: toastOut var(--speed-normal) ease forwards;
}
.toast-item::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    animation: shrink linear forwards;
}
@keyframes shrink {
    from { width: 100%; }
    to   { width: 0; }
}
.toast-item.toast-success::after { background: var(--success); }
.toast-item.toast-error::after   { background: var(--danger); }
.toast-item.toast-warning::after { background: var(--warning); }
.toast-item.toast-info::after    { background: var(--info); }

.toast-item .toast-icon {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.toast-success .toast-icon { background: rgba(0,214,143,0.15); color: var(--success); }
.toast-error   .toast-icon { background: rgba(255,107,107,0.15); color: var(--danger); }
.toast-warning .toast-icon { background: rgba(255,180,0,0.15); color: var(--warning); }
.toast-info    .toast-icon { background: rgba(0,201,255,0.15); color: var(--info); }

.toast-item .toast-body {
    flex: 1;
}
.toast-item .toast-title {
    font-size: 0.82rem;
    font-weight: 700;
}
.toast-item .toast-message {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}
.toast-item .toast-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color var(--speed-fast);
}
.toast-item .toast-close-btn:hover {
    color: var(--text-primary);
}

/* ============================================================
   Loading Spinner / ตัวโหลด
   ============================================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 12, 41, 0.80);
    backdrop-filter: blur(6px);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}
.loading-overlay.show { display: flex; }
.spinner {
    width: 44px; height: 44px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.loading-text {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* ============================================================
   Progress Bar / แถบความคืบหน้า
   ============================================================ */
.progress-glass {
    width: 100%;
    height: 6px;
    background: var(--surface);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-glass .progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 1s cubic-bezier(.4,0,.2,1);
}
.progress-fill.primary { background: linear-gradient(90deg, var(--primary), var(--info)); }
.progress-fill.success { background: linear-gradient(90deg, var(--success), #00E5A0); }
.progress-fill.danger  { background: linear-gradient(90deg, var(--danger), #FF9A8B); }

/* ============================================================
   Empty State / สถานะว่าง
   ============================================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
    opacity: 0.3;
}
.empty-state h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.empty-state p {
    font-size: 0.82rem;
}

/* ============================================================
   Floating Action Button / ปุ่มลอย
   ============================================================ */
.fab {
    position: fixed;
    bottom: 28px; right: 28px;
    width: 56px; height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    box-shadow: 0 6px 25px var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    transition: all var(--speed-normal) cubic-bezier(.4,0,.2,1);
    animation: pulseGlow 3s infinite;
}
.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 8px 35px rgba(108, 99, 255, 0.45);
}

/* ============================================================
   Mobile Sidebar Toggle
   ============================================================ */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px; left: 16px;
    z-index: 1100;
    width: 40px; height: 40px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   Responsive / การแสดงผลตามขนาดหน้าจอ
   ============================================================ */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 992px) {
    .sidebar-toggle { display: flex; }
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 20px 16px;
        padding-top: 60px;
    }
    .top-bar { flex-direction: column; align-items: flex-start; }
    .search-bar, .search-bar:focus-within { width: 100%; }
}
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: 1fr; }
    .quick-actions { flex-direction: column; }
    .quick-actions .btn-premium { width: 100%; justify-content: center; }
    .premium-table { font-size: 0.8rem; }
    .premium-table thead th,
    .premium-table tbody td { padding: 10px 12px; }
    .ipad-grid { grid-template-columns: 1fr; }
    .modal-glass { width: 98%; max-height: 95vh; border-radius: var(--radius-lg); }
    .fab { bottom: 20px; right: 20px; width: 50px; height: 50px; font-size: 1.2rem; }
}
@media (max-width: 480px) {
    .top-bar-left h2 { font-size: 1.25rem; }
    .stat-card .stat-value { font-size: 1.6rem; }
    .section-header { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Print Styles / สไตล์การพิมพ์
   ============================================================ */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .sidebar, .fab, .sidebar-toggle, .quick-actions, .toast-container,
    .loading-overlay, .modal-backdrop-custom, .top-bar-right { display: none !important; }
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    .glass-card, .stat-card, .ipad-card {
        background: #fff !important;
        border: 1px solid #ddd !important;
        backdrop-filter: none !important;
        box-shadow: none !important;
        color: #000 !important;
        break-inside: avoid;
    }
    .premium-table tbody tr {
        background: none !important;
    }
    .premium-table tbody tr:nth-child(even) {
        background: #f5f5f5 !important;
    }
    .premium-table th, .premium-table td {
        color: #000 !important;
    }
    .badge-status { border: 1px solid #aaa; }
    .stat-card .stat-value { color: #000 !important; }
    .stat-card .stat-label { color: #555 !important; }
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* ============================================================
   Utilities / ยูทิลิตี้
   ============================================================ */
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.text-muted-glass { color: var(--text-muted); }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.mt-section { margin-top: 32px; }
.mb-section { margin-bottom: 32px; }
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}
.table-responsive-glass {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}
.action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
}
