/* ============================================================
   CherryRoad Paywall — Base Styles
   Loads on every frontend page.
   Override CSS custom properties in your theme's Additional CSS
   to rebrand a publication without touching plugin files.

   Example override for a red-branded newspaper:
   :root {
       --crpw-primary:       #c0392b;
       --crpw-primary-dark:  #922b21;
       --crpw-primary-light: #fdedec;
       --crpw-primary-border:#f1948a;
   }
   ============================================================ */

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
    /* Brand */
    --crpw-primary:        #A31F34;
    --crpw-primary-dark:   #8b1a2c;
    --crpw-primary-light:  #fdf2f4;
    --crpw-primary-border: #f5a7b3;

    /* Status */
    --crpw-success:        #15803d;
    --crpw-success-bg:     #dcfce7;
    --crpw-danger:         #ef4444;
    --crpw-danger-bg:      #fee2e2;
    --crpw-warning:        #854d0e;
    --crpw-warning-bg:     #fef9c3;

    /* Neutral */
    --crpw-text:           #111827;
    --crpw-text-muted:     #6b7280;
    --crpw-text-subtle:    #9ca3af;
    --crpw-border:         #e5e7eb;
    --crpw-border-light:   #f3f4f6;
    --crpw-bg:             #ffffff;
    --crpw-bg-subtle:      #f9fafb;
    --crpw-bg-hover:       #fafafa;

    /* Shape */
    --crpw-radius-sm:      6px;
    --crpw-radius:         8px;
    --crpw-radius-lg:      12px;

    /* Type */
    --crpw-font-sm:        .8rem;
    --crpw-font-base:      .875rem;
    --crpw-font-lg:        1rem;
}

/* ============================================================
   Buttons — used on every page
   ============================================================ */
.crpw-btn {
    display: inline-block;
    padding: 11px 24px;
    border-radius: 6px;
    font-size: .9rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: opacity .15s, transform .1s;
    line-height: 1;
    text-align: center;
    box-sizing: border-box;
}

.crpw-btn:hover {
    opacity: .88;
    transform: translateY(-1px);
    text-decoration: none;
}

.crpw-btn-primary {
    background: #A31F34;
    color: #fff !important;
}

.crpw-btn-secondary {
    background: transparent;
    color: #374151;
    border: 1.5px solid #d1d5db;
}

.crpw-btn-ghost {
    background: transparent;
    color: #6b7280;
    border: none;
    font-size: .85rem;
    padding: 8px 16px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.crpw-btn-ghost:hover {
    color: #374151;
    opacity: 1;
    transform: none;
}

.crpw-btn-outline {
    background: transparent;
    border: 2px solid #374151;
    color: #374151 !important;
    padding: 10px 22px;
}

.crpw-btn-outline:hover {
    background: #374151;
    color: #fff !important;
}

.crpw-btn-current {
    background: #f0fdf4;
    color: #15803d;
    border: 2px solid #bbf7d0;
    cursor: default;
}

.crpw-btn-current:hover {
    transform: none;
    opacity: 1;
}

.crpw-btn-full { width: 100%; text-align: center; }

/* ============================================================
   Form elements — used in modals, login, checkout, dashboard
   ============================================================ */
.crpw-form { margin-top: 0; }

.crpw-field { margin-bottom: 18px; }

.crpw-label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
}

.crpw-input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    font-size: .95rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s;
    background: #f9fafb;
}

.crpw-input:focus {
    border-color: #A31F34;
    background: #fff;
}

.crpw-input-wrap {
    position: relative;
}

.crpw-toggle-pw {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    opacity: .6;
}

.crpw-toggle-pw:hover { opacity: 1; }

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

@media (max-width: 480px) {
    .crpw-form-row { grid-template-columns: 1fr; }
}

.crpw-terms-block {
    font-size: .78rem;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.crpw-field-msg {
    font-size: .78rem;
    margin-top: 4px;
    min-height: 18px;
}

.crpw-field-msg.exists    { color: #b91c1c; }
.crpw-field-msg.available { color: #15803d; }

/* ============================================================
   Alerts — used on every page
   ============================================================ */
.crpw-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: .9rem;
    margin-bottom: 18px;
    line-height: 1.5;
}

.crpw-alert-error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.crpw-alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.crpw-alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ============================================================
   Modal shell — used on paywall gate, plans, checkout, dashboard
   ============================================================ */
.crpw-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity .2s ease;
}

.crpw-modal-overlay.crpw-modal-visible { opacity: 1; }
.crpw-modal-overlay[hidden] { display: none !important; }

.crpw-modal {
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px 28px;
    width: 100%;
    max-width: 420px;
    position: relative;
    box-shadow: 0 8px 40px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.06);
    transform: translateY(16px);
    transition: transform .25s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.crpw-modal-overlay.crpw-modal-visible .crpw-modal {
    transform: translateY(0);
}

/* Dark mode — add class="crpw-dark" to body element to enable */
.crpw-dark .crpw-modal { background: #1e1e2e; color: #e2e8f0; }

.crpw-modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: background .15s;
    line-height: 1;
}

.crpw-modal-close:hover { background: #e5e7eb; color: #111; }

.crpw-modal-header {
    text-align: center;
    margin-bottom: 22px;
}

.crpw-modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 8px 0 4px;
}

.crpw-modal-subtitle {
    font-size: .88rem;
    color: #6b7280;
    margin: 0;
}

.crpw-modal-footer {
    text-align: center;
    margin-top: 16px;
    font-size: .83rem;
    color: #6b7280;
}

/* Mobile — bottom sheet */
@media (max-width: 480px) {
    .crpw-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    .crpw-modal {
        max-width: 100%;
        width: 100%;
        border-radius: 20px 20px 0 0;
        padding: 28px 20px 32px;
        transform: translateY(100%);
        max-height: 92vh;
    }
    .crpw-modal-overlay.crpw-modal-visible .crpw-modal {
        transform: translateY(0);
    }
}

/* ============================================================
   Modal tabs — used in plans modal AND paywall free access modal
   ============================================================ */
.crpw-modal-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin: 0 -28px 20px;
    padding: 0 28px;
}

.crpw-modal-tab {
    flex: 1;
    padding: 10px 8px;
    font-size: .82rem;
    font-weight: 600;
    color: #6b7280;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    text-align: center;
    line-height: 1.3;
}

.crpw-modal-tab:hover { color: #374151; }

.crpw-modal-tab--active {
    color: #A31F34;
    border-bottom-color: #A31F34;
}

/* ============================================================
   Subscribe modal — used in plans modal AND paywall free access modal
   ============================================================ */
.crpw-subscribe-modal { max-width: 500px; }

.crpw-selected-plan-summary {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: .85rem;
    color: #1e40af;
    text-align: center;
    margin-bottom: 16px;
    font-weight: 600;
}

/* ============================================================
   Free account success step — used in plans AND paywall modals
   ============================================================ */
.crpw-free-success {
    text-align: center;
    padding: 20px 10px;
}

.crpw-free-success__icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.crpw-free-success__title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 10px;
}

.crpw-free-success__msg {
    color: #6b7280;
    font-size: .9rem;
    margin: 0 0 24px;
    line-height: 1.6;
}

/* ============================================================
   Loading indicator — used in multiple places
   ============================================================ */
.crpw-loading {
    text-align: center;
    color: #6b7280;
    padding: 24px;
    font-style: italic;
}

/* ============================================================
   Login page — standalone login template
   ============================================================ */
.crpw-login-page {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}

.crpw-login-container {
    width: 100%;
    max-width: 440px;
}

.crpw-login-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 40px 36px;
    box-shadow: 0 4px 24px rgba(0,0,0,.07);
}

.crpw-login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.crpw-login-logo img { max-height: 52px; width: auto; }

.crpw-login-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin: 0 0 6px;
}

.crpw-login-subtitle {
    text-align: center;
    color: #6b7280;
    font-size: .9rem;
    margin: 0 0 28px;
}

.crpw-login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: .85rem;
    color: #6b7280;
}

/* Prompt icon — used in modal headers and paywall gate */
.crpw-prompt-icon {
    font-size: 28px;
    margin-bottom: 8px;
    line-height: 1;
}

/* Password hint — shown below password field on signup */
.crpw-password-hint {
    font-size: .78rem;
    color: #6b7280;
    margin: -10px 0 14px;
    line-height: 1.4;
    transition: color .2s;
}

/* ============================================================
   Account Menu — [crpw_account_menu] shortcode
   Loads globally via crpw-base. Zero API calls — reads session cache only.
   ============================================================ */
.crpw-account-menu {
    position: relative;
    display: inline-block;
    font-family: inherit;
}

.crpw-account-menu__trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--crpw-radius-sm);
    font-size: .875rem;
    font-weight: 600;
    color: inherit;
    transition: opacity .15s;
    line-height: 1;
}

.crpw-account-menu__trigger:hover { opacity: .8; }

.crpw-account-menu__chevron {
    transition: transform .2s ease;
    flex-shrink: 0;
}

.crpw-account-menu--open .crpw-account-menu__chevron {
    transform: rotate(180deg);
}

.crpw-account-menu__dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 200px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: var(--crpw-radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 99990;
    overflow: hidden;
    animation: crpw-menu-in .15s ease;
}

.crpw-account-menu__dropdown[hidden] { display: none; }

@keyframes crpw-menu-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.crpw-account-menu__name {
    padding: 10px 14px 8px;
    font-size: .78rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.crpw-account-menu__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: .875rem;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background .1s;
    line-height: 1.2;
}

.crpw-account-menu__item:hover {
    background: #f9fafb;
    color: #111827;
    text-decoration: none;
}

.crpw-account-menu__item--primary {
    color: var(--crpw-primary);
    font-weight: 600;
}

.crpw-account-menu__item--primary:hover {
    background: var(--crpw-primary-light, #fdf2f4);
    color: var(--crpw-primary);
}

.crpw-account-menu__item--logout {
    border-top: 1px solid #f3f4f6;
    color: #6b7280;
    font-size: .85rem;
}

.crpw-account-menu__item--logout:hover {
    background: #fef2f2;
    color: #b91c1c;
}
