/* School Cooperative Online Portal - Apple Design Language CSS */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  --font-en: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-th: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Apple Light Glassmorphism Palette */
  --bg-body: #f5f5f7;
  --bg-app: rgba(255, 255, 255, 0.72);
  --bg-card: rgba(255, 255, 255, 0.82);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-card-glass: rgba(255, 255, 255, 0.65);
  --bg-elevated: #ffffff;
  
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --primary-light: rgba(0, 113, 227, 0.08);
  --primary-glow: rgba(0, 113, 227, 0.25);
  
  --success: #34c759;
  --success-light: rgba(52, 199, 89, 0.12);
  --warning: #ff9500;
  --warning-light: rgba(255, 149, 0, 0.12);
  --danger: #ff3b30;
  --danger-light: rgba(255, 59, 48, 0.12);
  --purple: #af52de;
  --purple-light: rgba(175, 82, 222, 0.12);

  --border-glass: rgba(255, 255, 255, 0.6);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(0, 113, 227, 0.4);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
  --shadow-float: 0 24px 48px -12px rgba(15, 23, 42, 0.14);

  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-th), var(--font-en);
  background: 
    radial-gradient(circle at 15% 15%, #e0f2fe 0%, transparent 40%),
    radial-gradient(circle at 85% 20%, #f3e8ff 0%, transparent 35%),
    radial-gradient(circle at 50% 80%, #ecfdf5 0%, transparent 45%),
    #f8fafc;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Glass Header / Navigation */
.apple-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #0071e3 0%, #34c759 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.25);
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* App Switcher & Top Actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
}

.app-switcher-btn:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.branch-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(0, 113, 227, 0.08);
  border: 1px solid rgba(0, 113, 227, 0.15);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}

.role-selector {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: #ffffff;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.lang-btn {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.lang-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Main Container */
.coop-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px;
  flex: 1;
}

/* Segmented Control / Apple Tabs */
.segmented-bar {
  display: flex;
  background: rgba(0, 0, 0, 0.06);
  padding: 4px;
  border-radius: var(--radius-pill);
  max-width: fit-content;
  margin: 0 auto 28px;
  gap: 4px;
  backdrop-filter: blur(10px);
}

.seg-btn {
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.seg-btn.active {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Apple Cards Balance Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.apple-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-md);
  transition: var(--transition);
}

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

.apple-card.primary-card {
  background: linear-gradient(135deg, rgba(0, 113, 227, 0.92) 0%, rgba(26, 86, 219, 0.95) 100%);
  color: #ffffff;
}

.apple-card.primary-card .card-label,
.apple-card.primary-card .card-subtext {
  color: rgba(255, 255, 255, 0.8);
}

.apple-card.green-card {
  background: linear-gradient(135deg, rgba(52, 199, 89, 0.92) 0%, rgba(34, 153, 67, 0.95) 100%);
  color: #ffffff;
}

.apple-card.green-card .card-label,
.apple-card.green-card .card-subtext {
  color: rgba(255, 255, 255, 0.8);
}

.apple-card.purple-card {
  background: linear-gradient(135deg, rgba(175, 82, 222, 0.92) 0%, rgba(135, 42, 182, 0.95) 100%);
  color: #ffffff;
}

.apple-card.purple-card .card-label,
.apple-card.purple-card .card-subtext {
  color: rgba(255, 255, 255, 0.8);
}

.apple-card.dark-card {
  background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
  color: #ffffff;
}

.apple-card.dark-card .card-label,
.apple-card.dark-card .card-subtext {
  color: rgba(255, 255, 255, 0.7);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: rgba(255, 255, 255, 0.2);
}

.card-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.card-amount {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  font-family: var(--font-en), var(--font-th);
}

.card-subtext {
  font-size: 12px;
  color: var(--text-muted);
}

/* Quick Actions Bar */
.actions-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.action-btn:hover {
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.action-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.action-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

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

/* Content Grid & Sections */
.content-section {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(180%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass);
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

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

.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tables */
.apple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.apple-table th {
  text-align: left;
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.apple-table td {
  padding: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  color: var(--text-primary);
}

.apple-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.badge-pending {
  background: var(--warning-light);
  color: #b45309;
}

.badge-approved {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-completed, .badge-reconciled {
  background: var(--success-light);
  color: #15803d;
}

.badge-rejected, .badge-variance {
  background: var(--danger-light);
  color: #b91c1c;
}

/* Form Controls */
.form-group {
  margin-bottom: 16px;
}

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: #ffffff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

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

.btn-secondary {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.1);
}

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

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

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-sheet {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-float);
  border: 1px solid var(--border-glass);
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 28px;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Official E-Receipt Template */
.receipt-box {
  background: #ffffff;
  border: 1px dashed rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-md);
  padding: 24px;
  position: relative;
}

.receipt-seal {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 80px;
  height: 80px;
  border: 3px double #15803d;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #15803d;
  font-weight: 700;
  font-size: 10px;
  text-align: center;
  transform: rotate(-12deg);
  opacity: 0.85;
}

/* Floating AI Button */
.ai-floating-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0071e3 0%, #af52de 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(175, 82, 222, 0.4);
  transition: var(--transition);
  z-index: 900;
  border: 2px solid #ffffff;
}

.ai-floating-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 14px 30px rgba(175, 82, 222, 0.5);
}

/* Responsive */
@media (max-width: 768px) {
  .apple-nav {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
  }
  .nav-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .segmented-bar {
    width: 100%;
    overflow-x: auto;
  }
  .cards-grid {
    grid-template-columns: 1fr;
  }
  .actions-bar {
    grid-template-columns: 1fr 1fr;
  }
}
