/* PakWebGlobal Smart Popup — Frontend CSS v2.0
   Matches original HTML prototype exactly */

* {
    box-sizing: border-box;
}

/* ===== CSS VARIABLES (overridable by admin) ===== */
:root {
    --pwgspp-primary:   #0d6efd;
    --pwgspp-primary-h: #0b5ed7;
    --pwgspp-btn-color: #ffffff;
    --pwgspp-bg-hover:  #eef3ff;
    --pwgspp-radius-lg: 20px;
    --pwgspp-radius-md: 12px;
    --pwgspp-radius-sm: 10px;
    --pwgspp-shadow:    0 20px 40px rgba(0, 0, 0, 0.2);
    --pwgspp-z:         2147483647;
}

/* ===== FLOATING BUTTON ===== */
#pwgspp-floating-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--pwgspp-primary);
    color: #fff;
    border: none;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: var(--pwgspp-z);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    line-height: 1;
    padding: 0;
}

#pwgspp-floating-btn:hover {
    background: var(--pwgspp-primary-h);
    transform: scale(1.07);
}

#pwgspp-floating-btn:active {
    transform: scale(0.96);
}

/* ===== POPUP WRAPPER ===== */
#pwgspp-popup {
    position: fixed;
    right: 20px;
    bottom: 100px;
    width: 400px;
    max-width: 95%;
    background: #fff;
    border-radius: var(--pwgspp-radius-lg);
    overflow: hidden;
    box-shadow: var(--pwgspp-shadow);
    display: none;
    flex-direction: column;
    z-index: var(--pwgspp-z);
    animation: pwgsppPopupAnim 0.3s ease;
}

@keyframes pwgsppPopupAnim {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== HEADER ===== */
#pwgspp-header {
    background: var(--pwgspp-primary);
    color: #fff;
    padding: 18px;
    text-align: center;
    flex-shrink: 0;
    position: relative;
}

#pwgspp-logo {
    width: 140px;
    height: auto;
    margin-bottom: 8px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#pwgspp-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: #fff;
    font-family: Arial, sans-serif;
}

#pwgspp-close-btn {
    position: absolute;
    top: 12px;
    right: 14px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

#pwgspp-close-btn:hover {
    background: rgba(255, 255, 255, 0.30);
}

/* ===== CONTENT AREA ===== */
#pwgspp-content {
    padding: 20px;
    max-height: 550px;
    overflow-y: auto;
    font-family: Arial, sans-serif;
    color: #111;
    scroll-behavior: smooth;
}

#pwgspp-content::-webkit-scrollbar {
    width: 4px;
}

#pwgspp-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* ===== SECTION TITLE ===== */
.pwgspp-section-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #111;
    font-family: Arial, sans-serif;
}

/* ===== BUTTONS ===== */
.pwgspp-menu-btn,
.pwgspp-lang-btn {
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    border: none;
    border-radius: var(--pwgspp-radius-md);
    cursor: pointer;
    font-size: 16px;
    background: var(--pwgspp-bg-hover);
    color: #111;
    transition: background 0.2s, color 0.2s;
    text-align: left;
    font-family: Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    display: block;
}

.pwgspp-menu-btn:hover,
.pwgspp-lang-btn:hover {
    background: var(--pwgspp-primary);
    color: #fff;
}

.pwgspp-submit-btn {
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    border: none;
    border-radius: var(--pwgspp-radius-md);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    background: var(--pwgspp-primary);
    color: var(--pwgspp-btn-color);
    transition: background 0.2s, transform 0.15s;
    font-family: Arial, sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.pwgspp-submit-btn:hover {
    background: var(--pwgspp-primary-h);
    transform: translateY(-1px);
}

.pwgspp-submit-btn:active {
    transform: translateY(0);
}

.pwgspp-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading dots */
.pwgspp-dots {
    display: none;
    gap: 3px;
    align-items: center;
}

.pwgspp-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pwgsppBounce 1.2s ease-in-out infinite;
}

.pwgspp-dots span:nth-child(2) { animation-delay: 0.15s; }
.pwgspp-dots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes pwgsppBounce {
    0%, 80%, 100% { transform: scale(0.65); opacity: 0.5; }
    40%            { transform: scale(1);    opacity: 1; }
}

/* ===== FORM ELEMENTS ===== */
#pwgspp-content input[type="text"],
#pwgspp-content input[type="email"],
#pwgspp-content input[type="tel"],
#pwgspp-content input[type="url"],
#pwgspp-content input[type="number"],
#pwgspp-content select,
#pwgspp-content textarea {
    width: 100%;
    padding: 12px;
    border-radius: var(--pwgspp-radius-sm);
    border: 1px solid #ccc;
    margin-top: 10px;
    font-size: 15px;
    font-family: Arial, sans-serif;
    color: #111;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    display: block;
    box-sizing: border-box;
}

#pwgspp-content input:focus,
#pwgspp-content select:focus,
#pwgspp-content textarea:focus {
    border-color: var(--pwgspp-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

#pwgspp-content select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='18'%3E%3Cpath fill='%23666' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    cursor: pointer;
}

#pwgspp-content textarea {
    resize: vertical;
    min-height: 80px;
}

/* Invalid fields */
#pwgspp-content input.pwgspp-invalid,
#pwgspp-content select.pwgspp-invalid {
    border-color: #dc3545;
    background: #fff5f5;
}

/* ===== VALIDATION ERROR ===== */
.pwgspp-field-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
    margin-left: 2px;
    display: none;
    font-family: Arial, sans-serif;
}

/* ===== CHECKBOX GROUP ===== */
.pwgspp-checkbox-group {
    margin-top: 15px;
}

.pwgspp-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 15px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    color: #111;
}

.pwgspp-checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--pwgspp-primary);
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}

/* ===== PORTFOLIO ITEM ===== */
.pwgspp-portfolio-item {
    background: #f4f7fb;
    padding: 14px;
    border-radius: var(--pwgspp-radius-md);
    margin-top: 12px;
}

.pwgspp-portfolio-item strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #111;
    margin-bottom: 4px;
    font-family: Arial, sans-serif;
}

.pwgspp-portfolio-item a {
    color: var(--pwgspp-primary);
    text-decoration: none;
    font-size: 13px;
    word-break: break-all;
    font-family: Arial, sans-serif;
}

.pwgspp-portfolio-item a:hover {
    text-decoration: underline;
}

/* ===== ABOUT TEXT ===== */
.pwgspp-about-text {
    font-size: 15px;
    line-height: 1.7;
    color: #333;
    font-family: Arial, sans-serif;
}

.pwgspp-about-text p { margin-bottom: 12px; }
.pwgspp-about-text strong { color: var(--pwgspp-primary); }

/* ===== CONTACT ITEMS ===== */
.pwgspp-contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: #f4f7fb;
    border-radius: var(--pwgspp-radius-md);
    margin-top: 12px;
    text-decoration: none;
    color: #111;
    font-family: Arial, sans-serif;
    transition: background 0.2s;
}

.pwgspp-contact-item:hover {
    background: #e3ecff;
}

.pwgspp-contact-icon {
    font-size: 22px;
    width: 36px;
    text-align: center;
    flex-shrink: 0;
}

.pwgspp-contact-info strong {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 2px;
}

.pwgspp-contact-info span {
    font-size: 14px;
    font-weight: 600;
    color: var(--pwgspp-primary);
}

/* ===== SUCCESS ===== */
.pwgspp-success {
    text-align: center;
    padding: 20px 10px;
    font-family: Arial, sans-serif;
}

.pwgspp-success-icon {
    font-size: 60px;
    margin-bottom: 12px;
    display: block;
    animation: pwgsppSuccessIn 0.5s ease both;
}

@keyframes pwgsppSuccessIn {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.pwgspp-success h3 {
    color: var(--pwgspp-primary);
    margin-bottom: 10px;
    font-size: 20px;
    font-weight: 700;
}

.pwgspp-success p {
    color: #555;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

/* ===== LOADING SPINNER ===== */
.pwgspp-loading {
    text-align: center;
    padding: 24px 0;
    color: #888;
    font-size: 14px;
    font-family: Arial, sans-serif;
}

.pwgspp-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--pwgspp-primary);
    border-radius: 50%;
    animation: pwgsppSpin 0.7s linear infinite;
    margin: 0 auto 10px;
}

@keyframes pwgsppSpin {
    to { transform: rotate(360deg); }
}

/* ===== RTL / URDU ===== */
.pwgspp-rtl {
    direction: rtl;
    text-align: right;
}

.pwgspp-rtl .pwgspp-section-title,
.pwgspp-rtl .pwgspp-menu-btn,
.pwgspp-rtl .pwgspp-lang-btn,
.pwgspp-rtl .pwgspp-about-text,
.pwgspp-rtl .pwgspp-checkbox-group label {
    font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', Arial, sans-serif;
    line-height: 1.9;
}

.pwgspp-rtl .pwgspp-section-title { font-size: 16px; }

.pwgspp-rtl #pwgspp-content select {
    background-position: left 10px center;
    padding-right: 12px;
    padding-left: 32px;
}

/* ===== MOBILE ===== */
@media (max-width: 480px) {
    #pwgspp-popup {
        right: 10px;
        left: 10px;
        bottom: 90px;
        width: auto;
        max-width: none;
        border-radius: 16px;
    }

    #pwgspp-floating-btn {
        right: 16px;
        bottom: 16px;
        width: 62px;
        height: 62px;
        font-size: 26px;
    }

    #pwgspp-content {
        max-height: calc(100vh - 180px);
    }

    .pwgspp-section-title {
        font-size: 16px;
    }

    .pwgspp-menu-btn,
    .pwgspp-lang-btn,
    .pwgspp-submit-btn {
        font-size: 15px;
        padding: 13px;
    }
}

@media (max-width: 360px) {
    #pwgspp-floating-btn { width: 56px; height: 56px; font-size: 24px; }
    .pwgspp-section-title { font-size: 15px; }
    .pwgspp-menu-btn, .pwgspp-lang-btn { font-size: 14px; }
}

/* ===== POSITION CONTROLS FROM ADMIN SETTINGS ===== */
#pwgspp-popup-root.pwgspp-pos-bottom_left #pwgspp-floating-btn { left: 20px; right: auto; bottom: 20px; top: auto; }
#pwgspp-popup-root.pwgspp-pos-bottom_left #pwgspp-popup { left: 20px; right: auto; bottom: 100px; top: auto; }
#pwgspp-popup-root.pwgspp-pos-top_right #pwgspp-floating-btn { right: 20px; left: auto; top: 20px; bottom: auto; }
#pwgspp-popup-root.pwgspp-pos-top_right #pwgspp-popup { right: 20px; left: auto; top: 100px; bottom: auto; }
#pwgspp-popup-root.pwgspp-pos-top_left #pwgspp-floating-btn { left: 20px; right: auto; top: 20px; bottom: auto; }
#pwgspp-popup-root.pwgspp-pos-top_left #pwgspp-popup { left: 20px; right: auto; top: 100px; bottom: auto; }
#pwgspp-popup-root.pwgspp-pos-custom #pwgspp-floating-btn { right: var(--pwgspp-custom-x); bottom: var(--pwgspp-custom-y); left: auto; top: auto; }
#pwgspp-popup-root.pwgspp-pos-custom #pwgspp-popup { right: var(--pwgspp-custom-x); bottom: calc(var(--pwgspp-custom-y) + 80px); left: auto; top: auto; }

/* Smaller frontend titles to avoid double-line oversized headings */
#pwgspp-content .pwgspp-section-title,
#pwgspp-content h2,
#pwgspp-content h3 {
    font-size: 16px !important;
    line-height: 1.25 !important;
}

@media (max-width: 480px) {
    #pwgspp-content .pwgspp-section-title,
    #pwgspp-content h2,
    #pwgspp-content h3 { font-size: 15px !important; }
    #pwgspp-popup-root.pwgspp-pos-top_right #pwgspp-popup,
    #pwgspp-popup-root.pwgspp-pos-top_left #pwgspp-popup { top: 90px; }
}
