/* ============================================
   Football Federation Voting Platform
   Shared Design System
   ============================================ */

/* --- Design Tokens --- */
:root {
  /* Brand Colors */
  --color-primary: #E23636;
  --color-primary-light: #E25050;
  --color-primary-lighter: #F25A5A;
  --color-primary-bg: rgba(226, 54, 54, 0.1);
  --color-primary-bg-subtle: rgba(226, 54, 54, 0.05);
  --color-primary-shadow: #E2363640;

  /* Neutral Colors */
  --color-text-primary: #171a1f;
  --color-text-secondary: #565d6d;
  --color-text-tertiary: #9095a0;
  --color-bg-white: #ffffff;
  --color-bg-light: #fafafb;
  --color-bg-lighter: #f3f4f6;
  --color-border: #dee1e6;

  /* Status Colors */
  --color-warning: #D97706;
  --color-warning-bg: #FFFBEB;
  --color-success-bg: #e5fbe1;
  --color-info-bg: #e7f5fa;
  --color-error-bg: #fbe5e8;
  --color-light-red-bg: #fdf2f2;
  --color-light-purple-bg: #fce1fc;

  /* Shadows */
  --shadow-sm: 0px 1px 2.5px 0px #171a1f12, 0px 0px 2px 0px #171a1f14;
  --shadow-md: 0px 2px 4px 0px #171a1f17, 0px 0px 2px 0px #171a1f14;
  --shadow-primary: 0px 4px 7px 0px var(--color-primary-shadow), 0px 0px 2px 0px var(--color-primary-shadow);

  /* Typography */
  --font-family: 'Cairo', sans-serif;

  /* Spacing */
  --sidebar-width: 255px;
  --header-height: 64px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

/* --- Base Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background-color: var(--color-bg-lighter);
  color: var(--color-text-primary);
  direction: rtl;
  line-height: 1.45;
}

/* --- Visily Export Fix --- */
[data-type="PAGE"] {
  margin: 0 auto;
}

/* Fix zero-sized Visily containers: make wrapper overflow visible
   so content isn't clipped before JS computes proper dimensions */
.w-\[0px\].h-\[0px\] > [data-role="CONTAINER_CHILDREN_WRAPPER"],
.w-\[0px\] > [data-role="CONTAINER_CHILDREN_WRAPPER"],
.h-\[0px\] > [data-role="CONTAINER_CHILDREN_WRAPPER"] {
  overflow: visible !important;
}

/* Restore overflow-hidden on pill/progress-bar containers that need clipping */
.rounded-\[9999px\] > [data-role="CONTAINER_CHILDREN_WRAPPER"] {
  overflow: hidden !important;
}

/* Ensure the body allows horizontal scroll for fixed-width Visily pages */
body {
  min-width: -webkit-fill-available;
  min-width: 0;
  overflow-x: auto;
}

/* Admin pages: ensure full 1440px layout is visible */
[data-type="PAGE"].w-\[1440px\] {
  min-width: 1440px;
}

/* Voter pages: center the mobile layout */
[data-type="PAGE"].w-\[390px\],
[data-type="PAGE"][style*="width: 390px"] {
  margin: 0 auto;
}

/* Fix sidebar button hover states for navigation */
button[data-type="BUTTON"] {
  cursor: pointer;
  transition: opacity 0.15s ease;
}
button[data-type="BUTTON"]:hover {
  opacity: 0.85;
}

/* Keyboard accessibility and consistent focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(226, 54, 54, 0.2);
}

/* Fix clipped text in absolutely positioned spans */
[data-type="TEXT"] {
  max-width: none;
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-light);
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* --- Shared Layout Components --- */

/* Admin Header */
.admin-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--color-bg-white);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.admin-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-header .brand-name {
  color: var(--color-primary);
  font-size: 20px;
  font-weight: 700;
  line-height: 20px;
}

.admin-header .brand-icon {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-header .header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Admin Sidebar */
.admin-sidebar {
  position: fixed;
  top: var(--header-height);
  right: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--color-bg-white);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  z-index: 90;
  overflow-y: auto;
}

.admin-sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: right;
  font-family: var(--font-family);
}

.admin-sidebar .nav-item:hover {
  background: var(--color-bg-light);
  color: var(--color-text-primary);
}

.admin-sidebar .nav-item.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  font-weight: 600;
}

.admin-sidebar .nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.admin-sidebar .nav-spacer {
  flex: 1;
}

.admin-sidebar .nav-item.logout {
  color: var(--color-primary);
  margin-top: auto;
}

/* Main Content Area */
.admin-content {
  margin-top: var(--header-height);
  margin-right: var(--sidebar-width);
  padding: 32px;
  min-height: calc(100vh - var(--header-height));
}

/* Voter Layout (Mobile) */
.voter-page {
  max-width: 390px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--color-bg-white);
  position: relative;
  overflow: hidden;
}

.voter-header {
  height: var(--header-height);
  background: var(--color-bg-white);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* --- Shared UI Components --- */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 32px;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-weight: 700;
  font-size: 16px;
  line-height: 26px;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-bg-white);
  box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
  background: var(--color-primary-light);
}

.btn-outline {
  background: var(--color-bg-white);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-outline:hover {
  background: var(--color-bg-light);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: 8px 16px;
}

.btn-ghost:hover {
  background: var(--color-bg-light);
}

.btn-lg {
  height: 56px;
  font-size: 18px;
  line-height: 28px;
  border-radius: var(--radius-md);
}

.btn-sm {
  height: 36px;
  padding: 6px 16px;
  font-size: 14px;
  line-height: 22px;
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.card-sm {
  padding: 16px;
  border-radius: var(--radius-sm);
}

/* Form Controls */
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 22px;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 22px;
  color: var(--color-text-secondary);
  background: var(--color-bg-white);
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  border-color: var(--color-primary);
}

.form-input::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.5;
}

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

/* Badges / Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 27px;
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
}

.badge-red {
  background: var(--color-error-bg);
  color: var(--color-primary);
}

.badge-green {
  background: var(--color-success-bg);
  color: #1a7431;
}

.badge-blue {
  background: var(--color-info-bg);
  color: #1a6891;
}

.badge-purple {
  background: var(--color-light-purple-bg);
  color: #7c3aed;
}

.badge-orange {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 20px;
}

.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.alert-info {
  background: var(--color-info-bg);
  color: #1a6891;
}

/* Avatar */
.avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
}

.avatar-xs { width: 24px; height: 24px; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 56px; height: 56px; }
.avatar-xl { width: 80px; height: 80px; }

/* Dividers */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 0;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: right;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.data-table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--color-text-secondary);
  border-bottom: 1px solid var(--color-border);
}

.data-table tr:hover td {
  background: var(--color-bg-light);
}

/* Page Title */
.page-title {
  font-size: 30px;
  font-weight: 700;
  line-height: 36px;
  letter-spacing: -0.75px;
  color: var(--color-text-primary);
  margin: 0;
}

.page-subtitle {
  font-size: 16px;
  font-weight: 400;
  line-height: 26px;
  color: var(--color-text-secondary);
  margin: 8px 0 0;
}

/* Icon Container */
.icon-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.icon-circle-primary {
  background: var(--color-primary-bg);
}

.icon-circle-primary-solid {
  background: var(--color-primary);
  color: white;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
}

.pagination-info {
  font-size: 14px;
  color: var(--color-text-secondary);
}

.pagination-controls {
  display: flex;
  gap: 8px;
}

/* Utility: hide on specific layouts */
@media (max-width: 768px) {
  .admin-sidebar { display: none; }
  .admin-content { margin-right: 0; }
}

/* Better small-screen handling for fixed-width exports */
@media (max-width: 1500px) {
  body {
    min-width: 0;
    overflow-x: hidden;
  }

  [data-type="PAGE"].w-\[1440px\] {
    width: min(100%, 1440px) !important;
    min-width: 0;
    transform-origin: top center;
  }
}

@media (max-width: 420px) {
  [data-type="PAGE"].w-\[390px\] {
    width: 100% !important;
    min-width: 0;
  }

  [data-type="PAGE"] {
    margin-inline: auto;
  }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
