/* ============================================
   Leave System - Main Stylesheet
   ============================================ */

:root {
  /* ── Smart Solution Brand CI ── */
  --brand-black: #0f1117;
  --brand-green: #22c55e;
  --brand-green-dark: #16a34a;
  --brand-green-light: #4ade80;
  --brand-green-bg: #f0fdf4;

  --primary: #22c55e;
  --primary-light: #4ade80;
  --primary-dark: #16a34a;
  --success: #10B981;
  --success-light: #D1FAE5;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --info: #3B82F6;
  --info-light: #DBEAFE;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 28px 80px -44px rgba(15,23,42,0.6), 0 12px 30px -22px rgba(15,23,42,0.28);
  --focus-ring: 0 0 0 4px rgba(20,184,166,0.16);
}

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

body {
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    radial-gradient(circle at 18% -10%, rgba(34,197,94,0.13), transparent 32rem),
    linear-gradient(180deg, #F8FAF9 0%, #F3F6F5 100%);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============ Typography ============ */

h1 { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); }
h2 { font-size: 1.35rem; font-weight: 600; color: var(--gray-800); }
h3 { font-size: 1.1rem; font-weight: 600; color: var(--gray-700); }

/* ============ Layout ============ */

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

/* ============ Navbar ============ */

.navbar {
  background: var(--brand-black);
  border-bottom: 2px solid var(--brand-green);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-logo {
  height: 30px;
  width: auto;
  display: block;
  object-fit: contain;
}

@media (max-width: 480px) {
  .navbar-logo { height: 24px; }
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.6);
  flex-shrink: 0;
}

.navbar-user .user-name {
  font-weight: 600;
  color: white;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar-nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  align-items: center;
}

.navbar-nav a {
  padding: 5px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.65);
  transition: all 0.15s;
  white-space: nowrap;
}

.navbar-nav a:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.navbar-nav a.active {
  background: var(--brand-green);
  color: #000;
  font-weight: 700;
}

.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-logout:hover {
  background: rgba(239,68,68,0.15);
  border-color: #EF4444;
  color: #fca5a5;
}

/* ============ Cards ============ */

.card {
  background: rgba(255,255,255,0.94);
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

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

/* ============ Forms ============ */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--gray-800);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: #14B8A6;
  box-shadow: var(--focus-ring);
}

.form-control::placeholder {
  color: var(--gray-400);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ============ Radio / Toggle ============ */

.radio-group {
  display: flex;
  gap: 8px;
}

.radio-btn {
  flex: 1;
}

.radio-btn input {
  display: none;
}

.radio-btn label {
  display: block;
  text-align: center;
  padding: 10px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--gray-600);
  transition: all 0.2s;
}

.radio-btn input:checked + label {
  border-color: var(--brand-green);
  background: rgba(34,197,94,0.06);
  color: var(--brand-green-dark);
  font-weight: 600;
}

.radio-btn label:hover {
  border-color: var(--primary-light);
}

/* ============ Buttons ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  text-decoration: none;
  line-height: 1.4;
}

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

.btn-primary {
  background: linear-gradient(135deg, #14B8A6 0%, #22C55E 58%, #A3E635 100%);
  color: #052E26;
  font-weight: 700;
  box-shadow: 0 16px 40px -20px rgba(20,184,166,0.75);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #0D9488 0%, #16A34A 62%, #84CC16 100%);
  color: #FFFFFF;
  transform: translateY(-1px);
  box-shadow: 0 20px 46px -22px rgba(20,184,166,0.84);
}

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

.btn-success:hover:not(:disabled) {
  background: #059669;
}

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

.btn-danger:hover:not(:disabled) {
  background: #DC2626;
}

.btn-warning {
  background: #f59e0b;
  color: white;
}
.btn-warning:hover:not(:disabled) {
  background: #d97706;
}

.btn-outline {
  background: rgba(255,255,255,0.82);
  color: var(--gray-600);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.05rem;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 8px;
}

/* ============ Badges ============ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

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

.badge-approved {
  background: var(--success-light);
  color: #065F46;
}

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

.badge-cancelled {
  background: var(--gray-100);
  color: var(--gray-500);
}

.badge-sick { background: #FEE2E2; color: #B91C1C; }
.badge-personal { background: #DBEAFE; color: #1D4ED8; }
.badge-annual { background: #D1FAE5; color: #065F46; }
.badge-maternity { background: #F3E8FF; color: #7C3AED; }

/* ============ Summary Box ============ */

.summary-box {
  background: linear-gradient(135deg, var(--brand-black) 0%, #1a2332 100%);
  border: 1px solid rgba(34,197,94,0.3);
  color: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.summary-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-green), var(--brand-green-dark));
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.summary-item {
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.summary-item .value {
  font-size: 1.5rem;
  font-weight: 700;
}

.summary-item .label {
  font-size: 0.75rem;
  opacity: 0.85;
}

/* ============ Leave Preview ============ */

.leave-preview {
  background: var(--info-light);
  border: 1px solid #93C5FD;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
}

.leave-preview h3 {
  color: var(--info);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.leave-preview .preview-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
}

.leave-preview .preview-total {
  border-top: 1px solid #93C5FD;
  margin-top: 8px;
  padding-top: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary-dark);
}

/* ============ Table ============ */

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tr:hover {
  background: var(--gray-50);
}

/* ============ Leave List (Mobile-friendly) ============ */

.leave-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.leave-item {
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--gray-200);
  border-radius: 18px;
  padding: 16px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.leave-item:hover {
  border-color: rgba(20,184,166,0.25);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.leave-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.leave-item-name {
  font-weight: 600;
  color: var(--gray-900);
}

.leave-item-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  font-size: 0.85rem;
  color: var(--gray-600);
}

.leave-item-body .item-label {
  color: var(--gray-400);
  font-size: 0.75rem;
}

.leave-item-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}

/* ============ Balance Cards ============ */

.balance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.balance-card {
  border-radius: 18px;
  padding: 16px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.65);
  box-shadow: 0 1px 2px rgba(15,23,42,0.05);
}

.balance-card .type-name {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.balance-card .remaining {
  font-size: 1.6rem;
  font-weight: 700;
}

.balance-card .total-info {
  font-size: 0.75rem;
  opacity: 0.8;
}

.balance-sick { background: #FEE2E2; color: #B91C1C; }
.balance-personal { background: #DBEAFE; color: #1D4ED8; }
.balance-annual { background: #D1FAE5; color: #065F46; }
.balance-maternity { background: #F3E8FF; color: #7C3AED; }

/* ============ Login Page ============ */

.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #0f1117 0%, #111d2e 60%, #0d1f0f 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  text-align: center;
  margin-bottom: 8px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--gray-500);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.login-logo {
  text-align: center;
  font-size: 3rem;
  margin-bottom: 12px;
}

/* ============ Approve Page ============ */

.approve-card {
  max-width: 500px;
  margin: 40px auto;
  padding: 32px;
}

.approve-detail {
  margin: 20px 0;
}

.approve-detail .detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.approve-detail .detail-label {
  width: 120px;
  flex-shrink: 0;
  color: var(--gray-500);
  font-size: 0.85rem;
}

.approve-detail .detail-value {
  font-weight: 500;
  color: var(--gray-800);
}

.approve-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.approve-actions .btn {
  flex: 1;
}

.approve-result {
  text-align: center;
  padding: 40px 20px;
}

.approve-result .icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

/* ============ Alerts ============ */

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.alert-success {
  background: var(--success-light);
  color: #065F46;
  border: 1px solid #A7F3D0;
}

.alert-error {
  background: var(--danger-light);
  color: #B91C1C;
  border: 1px solid #FECACA;
}

.alert-warning {
  background: var(--warning-light);
  color: #B45309;
  border: 1px solid #FDE68A;
}

.alert-info {
  background: var(--info-light);
  color: #1D4ED8;
  border: 1px solid #93C5FD;
}

/* ============ Loading ============ */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--gray-400);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ Empty State ============ */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ============ Modal ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--gray-600);
}

/* ============ Utilities ============ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }

/* ============ Responsive ============ */

@media (max-width: 768px) {
  .navbar-inner {
    flex-wrap: wrap;
    padding: 8px 0;
    gap: 6px;
    min-height: auto;
  }
  .navbar-nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .navbar-nav::-webkit-scrollbar { display: none; }
  .navbar-nav a { font-size: 0.78rem; padding: 5px 9px; }
  .navbar-user { margin-left: auto; }
}

@media (max-width: 600px) {
  .container { padding: 12px; }
  .card { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .btn-group { flex-direction: column; }
  .approve-actions { flex-direction: column; }
  .leave-item-body { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .balance-grid { grid-template-columns: repeat(2, 1fr); }
}

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