/**
* Freunde Einladen (Friends Invite) Page - Essential CSS
* 
* CRITICAL: This file contains CSS rules that are REQUIRED for functionality, not just design.
* Deleting or modifying these rules will break button interaction, form visibility, and modal display.
* 
* DO NOT DELETE this file. Designer can create additional custom.css to override styling,
* but these core rules must remain intact.
* 
* === WHY THESE RULES ARE ESSENTIAL ===
* 
* 1. MODAL DISPLAY CONTROL (display: none/block)
*    - JavaScript toggles class "is-open" to show/hide modals
*    - Without display:none default, modals show unwanted on page load
*    - Without display:flex in is-open state, modal never appears
* 
* 2. MESSAGE VISIBILITY (display: block/none)
*    - Error/warning messages hidden by default
*    - display:block makes them visible when needed
*    - Without these, user never sees validation errors
* 
* 3. DROPDOWN MENU POSITIONING (position, z-index)
*    - Action menus must be positioned absolutely/fixed
*    - z-index controls layering over other elements
*    - Without these, dropdown disappears behind content
* 
* 4. FORM LAYOUT (flexbox, grid)
*    - Grid layout for invite list prevents text overlap
*    - Flexbox for buttons controls alignment
*    - Without these, form is unusable
* 
* === DESIGNER: How to Customize ===
* Create your own "frontend-freunde-einladen-custom.css" with:
*   - Colors, fonts, spacing overrides
*   - Background colors, borders, shadows
*   - But DO NOT remove display properties or positioning rules
* 
* Load order in template:
*   1. <link rel="stylesheet" href="/assets/css/frontend-freunde-einladen.css"> (THIS FILE - REQUIRED)
*   2. <link rel="stylesheet" href="/assets/css/frontend-freunde-einladen-custom.css"> (YOUR FILE - OPTIONAL)
*/

/* ========== CRITICAL: MODAL FUNCTIONALITY ========== */

/* Default hidden state - JavaScript will toggle "is-open" class */
.pc-modal {
  display: none;
}

/* WHY: When JavaScript adds .is-open class, modal becomes visible */
/* If you delete this rule, modal will never show, and preview feature breaks */
.pc-modal.is-open {
  display: flex !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

/* Modal content styling - handles scrolling and centering */
.pc-modal .pc-modal-content {
  background: white;
  border-radius: 8px;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  padding: 30px;
}

.pc-modal .pc-modal-content h2 {
  margin-top: 0;
  color: #333;
  margin-bottom: 20px;
}

/* ========== CRITICAL: MESSAGE DISPLAY CONTROL ========== */

/* Messages hidden by default */
.pc-message {
  padding: 15px 20px;
  border-radius: 6px;
  margin-bottom: 25px;
  font-weight: 500;
}

/* WHY: pc_showWarningMessage() adds these classes to make messages visible */
/* Without these CSS rules, error messages from preview/send remain invisible */

.pc-message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
  display: block;
}

.pc-message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  display: block;
}

.pc-message.warning {
  background: #fff3cd;
  color: #664d03;
  border: 1px solid #ffecb5;
  display: block;
}

/* ========== CRITICAL: EMAIL ERROR MESSAGE ========== */

/* WHY: Email validation error hidden by default until needed */
/* pc_validateEmailExists() shows this when user enters duplicate email */
/* Without display: none, error message appears on page load when frontend-loyalty.css is deleted */
.pc-email-error {
  display: none !important;
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  padding: 10px 12px;
  border-radius: 4px;
  margin-top: 5px;
  font-size: 13px;
}

/* Show error when validation detects duplicate */
.pc-email-error.show {
  display: block !important;
}

/* ========== CRITICAL: ERROR MODAL ========== */

/* WHY: Error modals hidden by default, shown only when errors occur */
/* JavaScript dynamically creates error dialogs with inline style display: flex */
/* IMPORTANT: .pc-error-modal is a FULL-SCREEN CONTAINER/OVERLAY, not the content box */
/* The actual content is in .pc-error-modal-content (defined in frontend-loyalty.css) */
/* Without !important, inline style.display='flex' would override CSS rules */
.pc-error-modal {
  display: none !important;
  /* NOTE: position, inset, flex centering from frontend-loyalty.css */
}

/* CRITICAL FIX: Ensure centering works when JavaScript sets inline style */
/* When JS sets style.display='flex', also enforce alignment (higher specificity) */
.pc-error-modal[style*="display: flex"] {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Modal content styling (the white box) */
.pc-error-modal-content {
  border-top: 4px solid #f44336;
  padding: 20px;
  background: #ffffff;
}

.pc-error-modal-content h3 {
  color: #721c24;
  margin-top: 0;
  margin-bottom: 15px;
}

.pc-error-modal-content button {
  background: #f44336;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
}

.pc-error-modal-content button:hover {
  background: #d32f2f;
}

.pc-error-modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
}

.pc-error-modal-close:hover {
  color: #333;
}

/* ========== CRITICAL: DROPDOWN MENU VISIBILITY ========== */

/* Action menu hidden by default */
.pc-action-menu {
  display: none;
}

/* WHY: pc_toggleActionMenu() in JavaScript adds .is-open class to show dropdown */
/* Clicking "Aktionen" button shows this menu with delete/restore options */
/* Without display:block, menu never appears to user */
.pc-action-menu.is-open {
  display: block;
}

/* Menu positioning and styling */
.pc-actions-dropdown {
  position: relative;
  display: inline-block;
}

.pc-action-menu {
  position: fixed;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  z-index: 99999;
  min-width: 180px;
}

.pc-action-menu button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  transition: background-color 0.2s ease;
}

.pc-action-menu button:hover {
  background-color: #f5f5f5;
}

.pc-action-menu button:first-child {
  border-radius: 3px 3px 0 0;
}

.pc-action-menu button:last-child {
  border-radius: 0 0 3px 3px;
}

/* ========== CRITICAL: FORM LAYOUT & BUTTONS ========== */

/* Invite form header */
.pc-invite-header {
  margin-bottom: 30px;
}

.pc-invite-header h2 {
  margin-bottom: 5px;
  color: #333;
  font-size: 28px;
  font-weight: bold;
}

.pc-invite-header p {
  margin: 0;
  color: #666;
  font-size: 16px;
}

/* Button styling - required for all .pc-btn classes */
.pc-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.pc-btn-primary {
  background: #007cba;
  color: white;
}

.pc-btn-primary:hover {
  background: #005a87;
}

.pc-btn-secondary {
  background: #ddd;
  color: #333;
}

.pc-btn-secondary:hover {
  background: #bbb;
}

.pc-btn-cancel {
  padding: 10px 20px;
  background: #ccc;
  color: #333;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.pc-btn-cancel:hover {
  background: #bbb;
}

.pc-btn-danger {
  padding: 12px 20px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.pc-btn-danger:hover {
  background: #c0392b;
}

.pc-btn-danger:disabled {
  background: #ddd;
  color: #999;
  cursor: not-allowed;
}

.pc-btn-danger:disabled:hover {
  background: #ddd;
}

/* Action buttons in invite list */
.pc-btn-actions {
  padding: 6px 12px;
  background-color: #007cba;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.2s ease;
  white-space: nowrap;
}

.pc-btn-actions:hover {
  background-color: #005a87;
}

/* ========== CRITICAL: GRID LAYOUT FOR INVITE LIST ========== */

/* Container wrapper - NO overflow:hidden! */
.pc-invites-grid-wrapper {
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  /* CRITICAL: DO NOT use overflow:hidden - breaks dropdown menu! */
}

.pc-invites-grid {
  display: flex;
  flex-direction: column;
}

/* Grid header row */
.pc-grid-header {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr 1fr 1.2fr;
  gap: 0;
  background-color: #f5f5f5;
  border-bottom: 2px solid #ddd;
  font-weight: 600;
  font-size: 14px;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pc-grid-header .pc-grid-cell {
  padding: 15px;
  text-align: left;
}

/* Grid data rows */
.pc-grid-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr 1fr 1.2fr;
  gap: 0;
  border-bottom: 1px solid #eee;
  align-items: center;
  transition: background-color 0.2s ease;
  position: relative;
}

.pc-grid-row:hover {
  background-color: #f9f9f9;
}

.pc-grid-row:last-child {
  border-bottom: none;
}

.pc-grid-cell {
  padding: 15px;
  font-size: 14px;
  color: #555;
}

/* Mobile: Show labels before cells */
.pc-cell-label {
  display: none;
  font-weight: 600;
  color: #666;
  margin-bottom: 5px;
}

/* Status badges styling */
.status-badge {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.status-date {
  font-size: 11px !important;
  font-weight: 400 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  opacity: 0.8;
}

/* Status badge colors */
.status-badge.created {
  background-color: #e3f2fd;
  color: #1976d2;
}

.status-badge.sent {
  background-color: #f3e5f5;
  color: #7b1fa2;
}

.status-badge.hit {
  background-color: #fff3e0;
  color: #e65100;
}

.status-badge.joined {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.status-badge.revoked {
  background-color: #ffebee;
  color: #c62828;
}

.status-badge.expired {
  background-color: #f0f4c3;
  color: #827717;
}

/* Row styling for specific status */
.pc-grid-row.status-joined {
  background-color: #f0f8f0;
}

/* ========== REFERRAL SECTION ========== */

.pc-referral-section {
  background: #f9f9f9;
  padding: 25px;
  border-radius: 8px;
  margin-bottom: 40px;
  border: 1px solid #e0e0e0;
}

.pc-referral-section h3 {
  margin-top: 0;
  margin-bottom: 8px;
  color: #333;
}

.pc-section-subtitle {
  margin: 0 0 15px 0;
  color: #666;
  font-size: 14px;
}

.pc-referral-content {
  display: flex;
  flex-direction: column;
  gap: 30px;
  align-items: flex-start;
  width: 100%;
}

.pc-referral-link-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pc-referral-link-section .pc-label {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.pc-referral-link-box {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.pc-referral-link {
  flex: 1;
}

/* ========== EMAIL PREVIEW ========== */

.pc-email-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  font-family: Arial, sans-serif;
}

.pc-invite-link-section {
  text-align: center;
  margin: 20px 0;
}

.pc-invite-button {
  background: #667eea;
  color: white;
  padding: 12px 30px;
  text-decoration: none;
  border-radius: 4px;
  display: inline-block;
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.pc-invite-button:hover {
  background: #5568d3;
}

.pc-link-display {
  background: #f5f5f5;
  padding: 10px;
  border-radius: 4px;
  word-break: break-all;
}

.pc-link-display a {
  color: #667eea;
}

.pc-divider {
  border: none;
  border-top: 1px solid #ddd;
  margin: 20px 0;
}

.pc-footer-text {
  font-size: 12px;
  color: #999;
}

/* ========== INVITE SECTIONS ========== */

.pc-invites-history-section {
  margin-top: 40px;
  margin-bottom: 30px;
}

.pc-invites-history-section h3 {
  margin-bottom: 20px;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  padding-bottom: 10px;
  border-bottom: 2px solid #ddd;
}

/* No invites empty state */
.pc-no-invites {
  padding: 40px 20px;
  text-align: center;
  background-color: #f9f9f9;
  border-radius: 4px;
  color: #999;
}

.pc-no-invites p {
  margin: 0;
  font-size: 14px;
}

.pc-invite-status {
  padding: 8px 12px;
  color: #666;
  font-size: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.pc-deleted-invites-section {
  margin-top: 40px;
}

.pc-deleted-invites-section h3 {
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 600;
  color: #666;
  opacity: 0.8;
}

.pc-deleted-invites-grid {
  opacity: 0.7;
}

/* ========== MODAL CHECKBOX ========== */

.pc-modal-checkbox {
  background: #f9f9f9;
  padding: 15px;
  border-radius: 4px;
  margin: 20px 0;
  border-left: 3px solid #667eea;
}

.pc-modal-checkbox label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  cursor: pointer;
}

.pc-modal-checkbox input[type="checkbox"] {
  margin-top: 3px;
  cursor: pointer;
}

.pc-modal-checkbox span {
  color: #555;
  font-size: 13px;
  line-height: 1.5;
}

/* ========== MODAL ACTIONS ========== */

.pc-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ========== EMAIL METADATA & PREVIEW ========== */

.pc-email-metadata {
  background: #f9f9f9;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 1px solid #eee;
}

.pc-email-metadata p {
  margin: 0 0 10px 0;
  color: #666;
}

.pc-email-metadata p:last-child {
  margin-bottom: 0;
}

.pc-email-preview {
  background: white;
  border: 1px solid #ddd;
  padding: 20px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 14px;
}

.pc-button-group {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ========== RESPONSIVE DESIGN ========== */

@media (max-width: 1024px) {
  .pc-grid-header,
  .pc-grid-row {
    grid-template-columns: 0.8fr 1.2fr 0.8fr 0.8fr 1fr;
    gap: 0;
  }

  .pc-grid-header .pc-grid-cell,
  .pc-grid-cell {
    padding: 12px;
    font-size: 13px;
  }
}

/* Mobile responsive - convert grid to block layout */
@media (max-width: 768px) {
  .pc-grid-header {
    display: none;
  }

  .pc-grid-row {
    display: block;
    border: 1px solid #ddd;
    margin-bottom: 15px;
    border-radius: 4px;
    padding: 0;
  }

  .pc-grid-cell {
    display: block;
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
    padding-left: 120px;
  }

  .pc-grid-cell:last-child {
    border-bottom: none;
  }

  .pc-cell-label {
    display: block;
    position: absolute;
    left: 12px;
    top: 12px;
    width: 100px;
  }

  .pc-grid-row:hover {
    background-color: white;
    border-color: #007cba;
  }

  .pc-btn-actions {
    width: 100%;
    margin-bottom: 10px;
  }

  .pc-action-menu {
    position: static;
    border: none;
    box-shadow: none;
    background: #f5f5f5;
    margin-top: 10px;
  }

  .pc-modal-actions {
    flex-direction: column;
  }
}

.pc-form-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  grid-gap: 26px;
  width: 100%;
  margin: 0 auto;
  padding-top: 26px;
  max-width: 320px;
}
.pc-modal .pc-modal-content button.pc-modal-close {
  position: absolute;
  top: 0;
  right: 0;
  border: 1px solid red;
  background: red;
  border-radius: 4px;
  padding: 3px 5px;
  color: #ffffff;
}
.pc-modal-header {
  position: relative;
}

@media (min-width: 768px) {
  .pc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 26px;
    padding-bottom: 26px;
  }
  .pc-form-actions {
    padding-top: 4px;
  }
}

/* ========== EMAIL STATE MACHINE: POPUP MESSAGE ========== */
/* Non-blocking popup notification for transient messages like "waiting for validation" */

.pc-popup-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #d4edda;
  border: 1px solid #28a745;
  border-radius: 4px;
  padding: 15px 20px;
  color: #155724;
  font-size: 14px;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  max-width: 90%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Show state - when JavaScript adds .show class */
.pc-popup-message.show {
  opacity: 1;
}

/* Fade out state - when JavaScript adds .fade-out class before removal */
.pc-popup-message.fade-out {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ========== EMAIL STATE MACHINE: ERROR MODAL ========== */
/* Blocking modal for actual validation errors that need acknowledgment */

.pc-error-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.pc-error-modal-content {
  background: white;
  padding: 30px;
  border-radius: 8px;
  max-width: 500px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-align: center;
}

.pc-error-modal-content h3 {
  color: #c0392b;
  margin-top: 0;
  margin-bottom: 15px;
  font-size: 18px;
}

.pc-error-modal-content p {
  color: #666;
  margin-bottom: 20px;
  line-height: 1.6;
  font-size: 14px;
}

.pc-error-modal-content .pc-btn {
  min-width: 120px;
}

/* ========== BUTTON DISABLED STATE ========== */
/* Visual feedback when buttons are disabled due to invalid email state */
/* Using CSS class instead of HTML disabled to allow clicks for mobile UX */

.pc-btn.pc-btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  /* DO NOT use pointer-events: none - we WANT clicks to trigger handler */
}

/* Visual feedback on hover - button stays grayed */
.pc-btn.pc-btn-disabled:hover {
  opacity: 0.5;
  transform: none;
}

/* Fallback for actual HTML disabled attribute (legacy) */
.pc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== SEND EMAIL ANIMATION ========== */
/* Rotating envelope icon while sending, transitions to checkmark on success */

.pc-send-icon {
  display: inline-block;
  transition: all 0.3s ease;
}

/* Rotating animation while email is being sent */
.pc-send-icon.sending {
  animation: rotate-envelope 2s linear infinite;
}

@keyframes rotate-envelope {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Success state - smooth transition to checkmark */
.pc-send-icon.success {
  animation: none;
  transform: scale(1.1);
}

/* Mobile responsive - slightly smaller icon */
@media (max-width: 768px) {
  .pc-send-icon {
    font-size: 0.95em;
  }
}