/* =================================================================
   OROS CUSTOM CSS
   All custom styles for the OROS Astrology Platform
   ================================================================= */

/* ─── DESIGN TOKENS ─── */
:root {
    --oros-primary: #00519a;    /* Headers, buttons, sidebar */
    --oros-light-blue: #68a8ca; /* Secondary buttons, accents */
    --oros-gold: #e2ae3e;       /* CTAs, highlights */
    --oros-bg: #f8fafc;         /* Backgrounds */
    --oros-white: #ffffff;      /* Cards, chat bubbles */
    --oros-text: #1a1a2e;       /* Body text */
    --oros-text-muted: #6b7280; /* Muted text */
    --oros-danger: #dc2626;     /* Delete buttons */
    --oros-danger-hover: #b91c1c;
    --oros-border: #e5e7eb;     /* Borders */
    --oros-radius: 8px;         /* Border radius */
    --oros-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --oros-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --oros-transition: 0.2s ease;
}

/* ─── UTILITY CLASSES ─── */
.oros-btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--oros-radius);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--oros-transition);
    text-align: center;
}

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

.oros-btn-primary:hover {
    background: #003d7a;
}

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

.oros-btn-danger:hover {
    background: var(--oros-danger-hover);
}

.oros-btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

/* Spinner animation */
.oros-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--oros-border);
    border-top: 4px solid var(--oros-primary);
    border-radius: 50%;
    animation: oros-spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Toast notifications */
.oros-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--oros-primary);
    color: var(--oros-white);
    padding: 12px 20px;
    border-radius: var(--oros-radius);
    box-shadow: var(--oros-shadow-lg);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.oros-toast--visible {
    transform: translateX(0);
}

/* ─── MENU VISIBILITY ─── */
.oros-logged-in-only,
.oros-logged-out-only {
    /* Visibility controlled by functions.php via inline CSS */
}

/* ─── MEMBERSHIP PAGES ─── */
.oros-history-login-prompt {
    text-align: center;
    padding: 40px 20px;
    background: var(--oros-bg);
    border-radius: var(--oros-radius);
    margin: 20px 0;
}

/* ─── SIMPLE MEMBERSHIP: login, register, password reset ───
   SWPM ships minimal swpm.common.css; these rules match OROS tokens.
   Divi 5 sets .et_pb_text to text-align:start (inline / critical CSS), which
   breaks margin:auto centering — use flex + !important below (restores “perfect” layout).
   Scope: .swpm-login-widget-form, .swpm-pw-reset-widget-form, etc. */

/* Center the text module when it contains SWPM (overrides D5 text-align:start) */
.et_pb_text:has(.swpm-login-widget-form),
.et_pb_text:has(.swpm-pw-reset-widget-form),
.et_pb_text:has(.swpm-registration-widget-form) {
    text-align: center !important;
}

.et_pb_text_inner:has(.swpm-login-widget-form),
.et_pb_text_inner:has(.swpm-pw-reset-widget-form),
.et_pb_text_inner:has(.swpm-registration-widget-form) {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Headings above the form */
.et_pb_text_inner:has(.swpm-login-widget-form) h1,
.et_pb_text_inner:has(.swpm-login-widget-form) h2,
.et_pb_text_inner:has(.swpm-pw-reset-widget-form) h1,
.et_pb_text_inner:has(.swpm-registration-widget-form) h1 {
    width: 100%;
    text-align: center;
}

/* Shortcode sometimes wrapped in <p> — don’t let it steal width */
.et_pb_text_inner:has(.swpm-login-widget-form) > p,
.et_pb_text_inner:has(.swpm-pw-reset-widget-form) > p,
.et_pb_text_inner:has(.swpm-registration-widget-form) > p {
    width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Login page (Divi block layout): keep single column visually centered */
.page-id-591 .et_pb_row:has(.swpm-login-widget-form),
.page-id-591 .et_pb_section:has(.swpm-login-widget-form) {
    justify-content: center;
}

.page-id-591 .et_pb_column:has(.swpm-login-widget-form) {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Join / registration page (membership-join) */
.page-id-589 .et_pb_row:has(.swpm-registration-widget-form),
.page-id-589 .et_pb_section:has(.swpm-registration-widget-form) {
    justify-content: center;
}

.page-id-589 .et_pb_column:has(.swpm-registration-widget-form) {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.swpm-login-widget-form,
.swpm-pw-reset-widget-form,
.swpm-registration-widget-form {
    width: 100%;
    max-width: 28rem;
    margin: 1.5rem 0;
    padding: 2rem 1.75rem;
    background: var(--oros-white);
    border: 1px solid var(--oros-border);
    border-radius: var(--oros-radius);
    box-shadow: var(--oros-shadow);
    color: var(--oros-text);
    text-align: left;
    flex-shrink: 0;
}

.swpm-login-form-inner {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.swpm-login-widget-form .swpm-label,
.swpm-login-widget-form label.swpm-label,
.swpm-pw-reset-widget-form .swpm-label,
.swpm-registration-widget-form .swpm-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--oros-text);
    margin-bottom: 0.35rem;
}

.swpm-login-widget-form .swpm-username-label,
.swpm-login-widget-form .swpm-password-label {
    margin-top: 0.75rem;
}

.swpm-login-widget-form .swpm-username-label:first-child,
.swpm-login-widget-form .swpm-login-form-inner > .swpm-username-label:first-of-type {
    margin-top: 0;
}

.swpm-login-widget-form input.swpm-text-field,
.swpm-login-widget-form input[type="text"].swpm-text-field,
.swpm-login-widget-form input[type="password"].swpm-text-field,
.swpm-pw-reset-widget-form input[type="text"],
.swpm-pw-reset-widget-form input[type="password"],
.swpm-registration-widget-form input[type="text"],
.swpm-registration-widget-form input[type="password"],
.swpm-registration-widget-form input[type="email"] {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--oros-border);
    border-radius: var(--oros-radius);
    font-size: 1rem;
    line-height: 1.4;
    background: var(--oros-white);
    color: var(--oros-text);
    transition: border-color var(--oros-transition), box-shadow var(--oros-transition);
}

.swpm-login-widget-form input.swpm-text-field:focus,
.swpm-pw-reset-widget-form input:focus,
.swpm-registration-widget-form input:focus {
    outline: none;
    border-color: var(--oros-primary);
    box-shadow: 0 0 0 3px rgba(0, 81, 154, 0.15);
}

.swpm-username-input,
.swpm-password-input {
    margin-bottom: 0 !important;
}

.swpm-login-widget-form .swpm-remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0 0.5rem;
    font-size: 0.9rem;
    color: var(--oros-text-muted);
}

.swpm-login-widget-form .swpm-login-submit {
    margin: 1.25rem 0 1rem !important;
}

.swpm-login-widget-form input.swpm-login-form-submit,
.swpm-login-widget-form input[type="submit"].swpm-login-form-submit {
    width: 100%;
    padding: 0.75rem 1.25rem !important;
    border: none !important;
    border-radius: var(--oros-radius) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    background: var(--oros-primary) !important;
    color: var(--oros-white) !important;
    transition: background var(--oros-transition);
}

.swpm-login-widget-form input.swpm-login-form-submit:hover,
.swpm-login-widget-form input[type="submit"].swpm-login-form-submit:hover {
    background: #003d7a !important;
}

/* Registration — primary button (table + v2 markup; matches Log In) */
.swpm-registration-widget-form .swpm-registration-submit-section,
.swpm-registration-widget-form .swpm-registration-submit-section.swpm-form-row {
    margin-top: 1.25rem !important;
    text-align: center;
    width: 100%;
}

.swpm-registration-widget-form input.swpm-registration-submit,
.swpm-registration-widget-form input[type="submit"].swpm-registration-submit,
.swpm-registration-widget-form input[type="submit"][name="swpm_registration_submit"],
.swpm-registration-widget-form button.swpm-registration-submit-button,
.swpm-registration-widget-form button.swpm-submit.swpm-registration-submit-button {
    width: 100%;
    max-width: 28rem;
    padding: 0.75rem 1.25rem !important;
    border: none !important;
    border-radius: var(--oros-radius) !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    font-family: inherit;
    cursor: pointer;
    background: var(--oros-primary) !important;
    color: var(--oros-white) !important;
    transition: background var(--oros-transition);
    line-height: 1.4 !important;
}

.swpm-registration-widget-form input.swpm-registration-submit:hover,
.swpm-registration-widget-form input[type="submit"].swpm-registration-submit:hover,
.swpm-registration-widget-form button.swpm-registration-submit-button:hover,
.swpm-registration-widget-form button.swpm-submit.swpm-registration-submit-button:hover {
    background: #003d7a !important;
}

.swpm-forgot-pass-link,
.swpm-join-us-link {
    margin-top: 0.75rem;
    font-size: 0.95rem;
    text-align: center;
}

.swpm-forgot-pass-link a,
.swpm-join-us-link a,
.swpm-login-widget-form a.swpm-login-form-pw-reset-link,
.swpm-login-widget-form a.swpm-login-form-register-link {
    color: var(--oros-primary) !important;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.swpm-forgot-pass-link a:hover,
.swpm-join-us-link a:hover {
    color: #003d7a !important;
}

.swpm-login-widget-action-msg,
.swpm-login-action-msg {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--oros-radius);
    font-size: 0.95rem;
}

.swpm-red-error-text,
.swpm-login-widget-form .swpm-red-error-text {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--oros-danger) !important;
}

.swpm-green-success-text {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857 !important;
}

/* =================================================================
   GAME SIDEBAR HISTORY STYLES
   ================================================================= */

.oros-game-sidebar {
    width: 100%;
    background: var(--oros-white);
    border: 1px solid var(--oros-border);
    border-radius: var(--oros-radius);
    box-shadow: var(--oros-shadow);
    overflow: hidden;
}

.oros-game-sidebar__header {
    padding: 14px 16px;
    background: linear-gradient(180deg, #f8fbff 0%, #f3f7fc 100%);
    border-bottom: 1px solid var(--oros-border);
}

.oros-game-sidebar__title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
    font-weight: 700;
    color: var(--oros-primary);
}

.oros-game-sidebar__body {
    padding: 14px 16px;
}

.oros-game-sidebar__loading,
.oros-game-sidebar__empty {
    text-align: center;
    padding: 18px 8px;
}

.oros-game-sidebar__loading p,
.oros-game-sidebar__empty p {
    margin: 10px 0 0;
    color: var(--oros-text-muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.oros-game-sidebar__list {
    display: grid;
    gap: 10px;
}

/* Generic list card support for JS-rendered history items */
.oros-game-sidebar__item {
    background: #f8fafc;
    border: 1px solid var(--oros-border);
    border-radius: var(--oros-radius);
    padding: 10px 12px;
}

.oros-game-sidebar__item-title {
    margin: 0 0 4px;
    color: var(--oros-text);
    font-size: 0.93rem;
    font-weight: 600;
}

.oros-game-sidebar__item-meta {
    margin: 0;
    color: var(--oros-text-muted);
    font-size: 0.82rem;
}

.oros-game-sidebar__actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--oros-border);
}

.oros-game-sidebar__link {
    display: block;
    width: 100%;
    text-align: center;
    padding: 10px 12px;
    border-radius: var(--oros-radius);
    background: var(--oros-primary);
    color: var(--oros-white) !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    transition: background var(--oros-transition);
}

.oros-game-sidebar__link:hover {
    background: #003d7a;
}

/* =================================================================
   HISTORY PAGE STYLES
   ================================================================= */

.oros-history {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Filter Bar */
.oros-history__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.oros-history__filter-btn {
    padding: 8px 16px;
    border: 2px solid var(--oros-primary);
    background: transparent;
    color: var(--oros-primary);
    border-radius: var(--oros-radius);
    cursor: pointer;
    font-size: 14px;
    transition: var(--oros-transition);
}

.oros-history__filter-btn:hover,
.oros-history__filter-btn.active {
    background: var(--oros-primary);
    color: var(--oros-white);
}

/* Sort Controls */
.oros-history__sort {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.oros-history__sort label {
    font-weight: 500;
    color: var(--oros-text);
}

.oros-history__sort select {
    padding: 8px 12px;
    border: 1px solid var(--oros-border);
    border-radius: var(--oros-radius);
    background: var(--oros-white);
    font-size: 14px;
}

/* Loading/Empty States */
.oros-history__loading,
.oros-history__empty {
    text-align: center;
    padding: 40px 20px;
}

.oros-history__loading p,
.oros-history__empty p {
    color: var(--oros-text-muted);
    margin-bottom: 20px;
}

/* Record Cards */
.oros-history__list {
    display: grid;
    gap: 16px;
}

.oros-history__card {
    background: var(--oros-white);
    border: 1px solid var(--oros-border);
    border-radius: var(--oros-radius);
    padding: 20px;
    box-shadow: var(--oros-shadow);
    transition: var(--oros-transition);
}

.oros-history__card:hover {
    box-shadow: var(--oros-shadow-lg);
    transform: translateY(-2px);
}

.oros-history__card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.oros-history__card-type {
    display: flex;
    align-items: center;
    gap: 8px;
}

.oros-history__type-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--oros-white);
    font-size: 12px;
    font-weight: bold;
}

.oros-history__type-icon--natal { background: var(--oros-primary); }
.oros-history__type-icon--synastry { background: var(--oros-light-blue); }
.oros-history__type-icon--horary { background: var(--oros-gold); }
.oros-history__type-icon--electional { background: #10b981; }
.oros-history__type-icon--eventnatal { background: #8b5cf6; }

.oros-history__type-label {
    font-weight: 600;
    color: var(--oros-text);
}

.oros-history__badge {
    background: var(--oros-gold);
    color: var(--oros-white);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.oros-history__card-date {
    color: var(--oros-text-muted);
    font-size: 14px;
}

.oros-history__card-summary {
    margin-bottom: 16px;
    color: var(--oros-text);
    font-size: 14px;
}

.oros-history__card-summary p {
    margin: 4px 0;
}

.oros-history__card-actions {
    display: flex;
    gap: 8px;
}

/* Modal */
.oros-history__modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.oros-history__modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.oros-history__modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--oros-white);
    border-radius: var(--oros-radius);
    box-shadow: var(--oros-shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    width: 800px;
}

.oros-history__modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--oros-text-muted);
    z-index: 1;
}

.oros-history__modal-close:hover {
    color: var(--oros-text);
}

/* Detail View */
.oros-history__detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--oros-primary);
    margin-bottom: 20px;
    padding: 20px;
    border-bottom: 1px solid var(--oros-border);
}

.oros-history__detail-loading {
    text-align: center;
    padding: 40px;
}

.oros-history__detail-chart {
    margin-bottom: 30px;
}

.oros-history__detail-chart h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--oros-text);
}

.oros-history__chart-wrapper {
    text-align: center;
    padding: 20px;
    background: var(--oros-bg);
    border-radius: var(--oros-radius);
}

.oros-history__detail-input,
.oros-history__detail-interpretation,
.oros-history__detail-chat {
    margin-bottom: 30px;
    padding: 0 20px;
}

.oros-history__detail-input h3,
.oros-history__detail-interpretation h3,
.oros-history__detail-chat h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--oros-text);
}

.oros-history__input-list {
    display: grid;
    gap: 8px;
}

.oros-history__input-list dt {
    font-weight: 600;
    color: var(--oros-text);
}

.oros-history__input-list dd {
    margin: 0 0 8px 0;
    color: var(--oros-text-muted);
}

.oros-history__interpretation-text {
    line-height: 1.6;
    color: var(--oros-text);
}

.oros-history__chat-msg {
    display: flex;
    margin-bottom: 12px;
    gap: 8px;
}

.oros-history__chat-msg--assistant {
    justify-content: flex-start;
}

.oros-history__chat-msg--user {
    justify-content: flex-end;
}

.oros-history__chat-sender {
    font-size: 18px;
    margin-top: 2px;
}

.oros-history__chat-bubble {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: var(--oros-radius);
    line-height: 1.4;
}

.oros-history__chat-msg--assistant .oros-history__chat-bubble {
    background: var(--oros-bg);
    color: var(--oros-text);
}

.oros-history__chat-msg--user .oros-history__chat-bubble {
    background: var(--oros-primary);
    color: var(--oros-white);
}

.oros-history__no-chat {
    color: var(--oros-text-muted);
    font-style: italic;
}

/* Error states */
.oros-error {
    color: var(--oros-danger);
    padding: 20px;
    text-align: center;
}

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

@media (max-width: 768px) {
    .oros-history {
        padding: 10px;
    }

    .oros-history__filters {
        justify-content: center;
    }

    .oros-history__card {
        padding: 15px;
    }

    .oros-history__card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .oros-history__card-actions {
        flex-direction: column;
    }

    .oros-history__modal-content {
        width: 95vw;
        max-height: 95vh;
    }

    .oros-history__card-actions .oros-btn {
        width: 100%;
    }
}

/* =================================================================
   CHAT: typing indicator (assistant dots) + Divi overrides
   ================================================================= */

/* ---- Chat: “assistant is typing” (animated dots) ---- */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  margin: 0.35rem 0;
  max-width: 85%;
  border-radius: 12px;
  background: rgba(0, 81, 154, 0.08);
  color: #00519a;
  font-size: 0.95rem;
  line-height: 1.4;
}

/* Row sits after last message in #chat-messages (not over the bubble) */
.chat-messages .typing-indicator {
  flex-shrink: 0;
  margin-top: 0.5rem;
  align-self: flex-start;
}

.typing-indicator--dots {
  min-height: 2rem;
}

.typing-indicator.visible {
  display: flex;
}

.typing-indicator.hidden {
  display: none !important;
}

.oros-typing-label {
  font-style: italic;
  opacity: 0.9;
}

.oros-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.oros-typing-dots > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: orosTypingBounce 1.2s ease-in-out infinite;
}

.oros-typing-dots > span:nth-child(2) {
  animation-delay: 0.15s;
}

.oros-typing-dots > span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes orosTypingBounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ---- Divi / Code module: beat .typing-indicator.hidden { display:none !important } ---- */
.oros-results-panel .typing-indicator.visible,
.oros-results-panel #typing-indicator.visible {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
}

/* When visible, dots + label still need flex (some page CSS used display:block on .visible) */
.oros-results-panel .oros-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.oros-results-panel .oros-typing-dots > span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: orosTypingBounce 1.2s ease-in-out infinite;
}

.oros-results-panel .oros-typing-dots > span:nth-child(2) {
  animation-delay: 0.15s;
}

.oros-results-panel .oros-typing-dots > span:nth-child(3) {
  animation-delay: 0.3s;
}

.oros-results-panel .chat-messages .typing-indicator {
  margin-top: 0.5rem;
  align-self: flex-start;
}
