{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "TPUL Remote Configuration Schema",
  "description": "Schema for validating Terms Popup on User Login remote configuration",
  "type": "object",
  "required": ["TPUL_General_Options", "TPUL_Modal_Options", "TPUL_Display_Options", "TPUL_Woo_Options", "TPUL_Email_Options"],
  "properties": {
    "TPUL_General_Options": {
      "type": "object",
      "required": ["modal_to_show"],
      "properties": {
        "modal_to_show": {
          "type": "string",
          "description": "Type of modal to display"
        }
      }
    },
    "TPUL_Modal_Options": {
      "type": "object",
      "required": ["terms_modal_title", "terms_modal_subtitle", "terms_modal_accept_button", "terms_modal_decline_button", "terms_modal_mandatory_checkbox_text", "terms_modal_content"],
      "properties": {
        "terms_modal_title": {
          "type": "string",
          "description": "Title of the terms modal"
        },
        "terms_modal_subtitle": {
          "type": "string",
          "description": "Subtitle of the terms modal"
        },
        "terms_modal_accept_button": {
          "type": "string",
          "description": "Text for the accept button"
        },
        "terms_modal_accept_redirect": {
          "type": "string",
          "description": "Redirect URL after accepting terms"
        },
        "terms_modal_agreed_text": {
          "type": "string",
          "description": "Text shown after agreeing to terms"
        },
        "terms_modal_decline_button": {
          "type": "string",
          "description": "Text for the decline button"
        },
        "terms_modal_decline_redirect": {
          "type": "string",
          "description": "Redirect URL after declining terms"
        },
        "terms_modal_logout_text": {
          "type": "string",
          "description": "Text shown during logout process"
        },
        "terms_modal_mandatory_checkbox_text": {
          "type": "string",
          "description": "Text for the mandatory checkbox"
        },
        "terms_modal_version": {
          "type": "string",
          "description": "Version of the terms modal"
        },
        "terms_modal_content": {
          "type": "string",
          "description": "HTML content of the terms modal"
        },
        "terms_modal_pageid": {
          "type": "string",
          "description": "Page ID for terms content"
        },
        "terms_modal_content_from_url": {
          "type": "string",
          "format": "uri",
          "description": "URL to fetch terms content from"
        },
        "terms_modal_font_size": {
          "type": "string",
          "description": "Font size for the modal"
        },
        "terms_modal_loginpage_paths": {
          "type": "string",
          "description": "Login page paths where modal should appear"
        },
        "terms_modal_customurls": {
          "type": "string",
          "description": "Custom URLs where modal should appear"
        },
        "terms_modal_for_roles": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "User roles for which modal should appear"
        },
        "terms_modal_designated_test_user": {
          "type": "string",
          "description": "Designated test user for modal"
        },
        "terms_modal_asset_placement": {
          "type": "string",
          "enum": ["styles_in_header", "styles_in_footer"],
          "description": "Where to place CSS assets"
        }
      }
    },
    "TPUL_Display_Options": {
      "type": "object",
      "required": ["terms_modal_theme"],
      "properties": {
        "terms_modal_theme": {
          "type": "string",
          "enum": ["default", "classic", "modern", "corporate"],
          "description": "Theme for the modal"
        },
        "terms_modal_width": {
          "type": "string",
          "description": "Width of the modal"
        },
        "terms_modal_height": {
          "type": "string",
          "description": "Height of the modal"
        },
        "terms_modal_acc_btn_size": {
          "type": "string",
          "description": "Size of the accept button"
        },
        "terms_modal_acc_btn_color": {
          "type": "string",
          "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",
          "description": "Color of the accept button (hex format)"
        },
        "terms_modal_acc_btn_txt_color": {
          "type": "string",
          "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",
          "description": "Text color of the accept button (hex format)"
        },
        "terms_modal_dec_btn_size": {
          "type": "string",
          "description": "Size of the decline button"
        },
        "terms_modal_dec_btn_color": {
          "type": "string",
          "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",
          "description": "Color of the decline button (hex format)"
        },
        "terms_modal_dec_btn_txt_color": {
          "type": "string",
          "pattern": "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$",
          "description": "Text color of the decline button (hex format)"
        }
      }
    },
    "TPUL_Woo_Options": {
      "type": "object",
      "required": ["terms_modal_woo_display_on", "terms_modal_woo_display_user_type", "terms_modal_woo_popup_frequency", "terms_modal_woo_log_out_user"],
      "properties": {
        "terms_modal_woo_display_on": {
          "type": "string",
          "enum": ["product_pages", "checkout", "cart", "custom"],
          "description": "Where to display the modal in WooCommerce"
        },
        "terms_modal_woo_display_on_custom": {
          "type": "string",
          "description": "Custom pages where modal should appear"
        },
        "terms_modal_woo_display_user_type": {
          "type": "string",
          "enum": ["anonymous_only", "logged_in_only", "anonymous_and_logged_in"],
          "description": "User types for which modal should appear"
        },
        "terms_modal_woo_popup_frequency": {
          "type": "string",
          "enum": ["every_time", "once_per_session", "once_per_user"],
          "description": "How often to show the modal"
        },
        "terms_modal_woo_log_out_user": {
          "type": "string",
          "enum": ["keep_user_logged_in", "log_out_user"],
          "description": "Whether to log out user on decline"
        }
      }
    },
    "TPUL_Email_Options": {
      "type": "object",
      "required": ["email_send_to_admins", "email_subject", "email_text_content"],
      "properties": {
        "email_send_to_admins": {
          "type": "string",
          "enum": ["0", "1"],
          "description": "Whether to send emails to admins"
        },
        "email_admin_addr": {
          "type": "string",
          "format": "email",
          "description": "Admin email address"
        },
        "email_subject": {
          "type": "string",
          "description": "Subject line for email notifications"
        },
        "email_text_content": {
          "type": "string",
          "description": "Content of the email notification"
        }
      }
    }
  },
  "additionalProperties": false
}
