/*
 * SmartCampus TN — Custom CSS
 * Extends TailwindCSS with shared component styles and RTL support.
 */

/* Alpine.js — hide until JS initializes */
[x-cloak] { display: none !important; }

/* HTMX indicator — hidden by default, shown when htmx-request class is present */
.htmx-indicator { opacity: 0; transition: opacity 0.15s ease-in-out; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ── Sidebar nav items ────────────────────────────────────────────────────── */
.sc-nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;        /* gap-2.5 */
  padding: 0.5rem 0.75rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;  /* text-sm */
  font-weight: 500;
  color: #64748b;       /* slate-500 */
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}

.sc-nav-item:hover {
  background-color: #f1f5f9; /* slate-100 */
  color: #1e293b;             /* slate-800 */
}

.sc-nav-active {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 600;
  background-color: #eef2ff; /* primary-50 */
  color: #4f46e5;            /* primary-600 */
  text-decoration: none;
}

/* ── RTL support (Arabic) ─────────────────────────────────────────────────── */
[dir="rtl"] .sc-nav-item,
[dir="rtl"] .sc-nav-active {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .font-arabic {
  font-family: 'Cairo', 'Segoe UI', sans-serif;
}

/* ── HTMX loading state ───────────────────────────────────────────────────── */
.htmx-request #htmx-indicator {
  opacity: 1;
}

.htmx-request.htmx-indicator {
  opacity: 1;
}

/* ── Table utilities ──────────────────────────────────────────────────────── */
.sc-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8; /* slate-400 */
  padding: 0.75rem 1.25rem;
  background-color: #f8fafc; /* slate-50 */
}

.sc-table td {
  padding: 0.875rem 1.25rem;
  color: #334155; /* slate-700 */
  border-bottom: 1px solid #f1f5f9; /* slate-100 */
}

/* ── Form inputs ──────────────────────────────────────────────────────────── */
.sc-input {
  width: 100%;
  padding: 0.625rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid #e2e8f0; /* slate-200 */
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.sc-input:focus {
  border-color: #818cf8;     /* primary-400 */
  box-shadow: 0 0 0 3px #eef2ff; /* primary-50 */
}

/* ── Button variants ──────────────────────────────────────────────────────── */
.sc-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  background-color: #4f46e5;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background-color 0.15s;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.sc-btn-primary:hover {
  background-color: #4338ca;
}

.sc-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.625rem;
  background-color: #f1f5f9;
  color: #475569;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s;
}

.sc-btn-secondary:hover {
  background-color: #e2e8f0;
}

/* ── Card ─────────────────────────────────────────────────────────────────── */
.sc-card {
  background: white;
  border-radius: 1rem;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.05);
  padding: 1.25rem;
}

/* ── Badge / status pill ──────────────────────────────────────────────────── */
.sc-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Focus-visible ring — keyboard navigation indicator ──────────────────── */
/* Applied globally to interactive elements for accessibility (WCAG 2.4.7)   */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #6366f1;   /* primary-500 */
  outline-offset: 2px;
  border-radius: 0.375rem;
}

/* Remove default outline only when focus-visible is supported */
@supports selector(:focus-visible) {
  a:focus:not(:focus-visible),
  button:focus:not(:focus-visible) {
    outline: none;
  }
}

/* ── Skip to content — visually hidden until focused ─────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only:focus {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 9999;
  width: auto;
  height: auto;
  clip: auto;
  white-space: normal;
  padding: 0.75rem 1.25rem;
  background: #4f46e5;
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.625rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
