/* Arabic Learning App - Subscription Integration Styles */
/* Production-ready styles for Azure deployment */

/* Shared dashboard-style page layout */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo h1 {
    margin: 0;
    color: #ffffff;
    font-size: 2rem;
    font-weight: 700;
}

nav .nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

nav .nav-menu li {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    display: inline-block;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-1px);
}

.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 34px 20px 50px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 22px;
}

#user-menu {
    min-width: 220px;
}

#user-menu .user-dropdown {
    min-width: 220px;
}

/* Modal Styles */
.subscription-modal,
.payment-modal {
    display: block;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.subscription-modal-content,
.payment-modal-content {
    background-color: #ffffff;
    margin: 3% auto;
    padding: 30px;
    border: none;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 700px;
    position: relative;
    animation: modalSlideIn 0.4s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.close {
    color: #999;
    float: right;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
    margin: -10px -10px 0 0;
    padding: 10px;
}

.close:hover {
    color: #333;
    transform: scale(1.1);
}

/* User Menu Styles */
.user-menu {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.user-dropdown {
    background: white;
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    min-width: 200px;
}

.user-greeting {
    font-weight: bold;
    color: #333;
    display: block;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.user-menu-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-btn {
    background: none;
    border: none;
    padding: 8px 12px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
    font-size: 0.95rem;
}

.menu-btn:hover {
    background-color: #f8f9fa;
}

.menu-btn.logout {
    color: #dc3545;
}

.menu-btn.logout:hover {
    background-color: #fff5f5;
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

.auth-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.auth-btn.register {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

/* Subscription Status */
.subscription-status-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.subscription-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.subscription-status.active {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.subscription-status.inactive {
    background: white;
    color: #333;
    border: 2px solid #e9ecef;
}

.upgrade-link {
    background: none;
    border: none;
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

.upgrade-link:hover {
    color: #764ba2;
}

/* Pricing Options */
.pricing-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 30px;
}

.plan {
    background: linear-gradient(135deg, #f8f9ff 0%, #e8ecff 100%);
    padding: 30px 25px;
    border-radius: 20px;
    text-align: center;
    transition: all 0.4s ease;
    border: 3px solid transparent;
    position: relative;
}

.plan:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.2);
}

.plan.featured {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    transform: scale(1.05);
}

.plan.featured::before {
    content: "🌟 Most Popular";
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff6b6b;
    color: white;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
}

.plan.featured:hover {
    transform: scale(1.05) translateY(-8px);
}

.plan h3 {
    margin: 0 0 15px 0;
    font-size: 1.6rem;
    font-weight: 700;
}

.price {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 20px 0;
    color: #667eea;
}

.price span {
    font-size: 1rem;
    font-weight: normal;
}

.plan.featured .price {
    color: white;
}

.savings {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    margin: 15px 0;
    display: inline-block;
    font-weight: 600;
}

.plan ul {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    text-align: left;
}

.plan li {
    padding: 8px 0;
    font-size: 0.95rem;
    opacity: 0.9;
}

.plan.featured li {
    opacity: 1;
}

.subscribe-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    transition: all 0.3s ease;
    margin-top: 20px;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subscribe-btn:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.plan.featured .subscribe-btn {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.plan.featured .subscribe-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Payment Form */
.payment-modal-content {
    max-width: 500px;
}

.plan-summary {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 25px;
}

.plan-summary p:first-child {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
    margin: 0 0 5px 0;
}

#payment-form {
    margin-top: 25px;
}

#card-element {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    border: 2px solid #e9ecef;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

#card-element:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#card-errors {
    color: #dc3545;
    font-size: 0.9rem;
    margin-bottom: 15px;
    min-height: 20px;
}

#submit-payment {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 18px 30px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    width: 100%;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#submit-payment:hover:not(:disabled) {
    background: linear-gradient(135deg, #764ba2, #667eea);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

#submit-payment:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Auth Form Styles */
#auth-form input {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

#auth-form input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#auth-form button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
    margin-top: 15px;
    transition: all 0.3s ease;
}

#auth-form button:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
    transform: translateY(-2px);
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.auth-switch a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Premium Feature Styles */
.premium-feature,
.premium-content {
    position: relative;
    transition: all 0.3s ease;
}

.premium-locked {
    opacity: 0.7;
    cursor: pointer;
    filter: grayscale(30%);
}

.premium-locked::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: inherit;
    pointer-events: none;
}

.premium-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    z-index: 2;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Lesson Card Styles */
.lesson-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin: 15px 0;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    border: 2px solid #f8f9fa;
}

.lesson-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
    border-color: #e9ecef;
}

.lesson-card.premium-locked {
    background: linear-gradient(135deg, #fafbff, #f0f3ff);
    border-color: #e8ecff;
}

/* Practice Counter */
.practice-counter-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.practice-counter {
    background: white;
    padding: 15px 20px;
    border-radius: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 2px solid #e9ecef;
}

.practice-counter.warning {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

.practice-counter.danger {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.upgrade-btn-small {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    margin-left: 10px;
}

/* Premium Prompt Modal */
.premium-prompt {
    text-align: center;
    max-width: 400px;
}

.premium-prompt-content {
    padding: 20px 0;
}

.premium-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.premium-actions {
    margin-top: 25px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.premium-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.premium-btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.premium-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.premium-btn.secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 2px solid #e9ecef;
}

.premium-btn.secondary:hover {
    background: #e9ecef;
}

/* Feature Interfaces */
.feature-interface {
    display: none;
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    margin: 25px 0;
    border: 2px solid #f8f9fa;
}

/* Arabic Text Specific */
.arabic-text {
    font-family: 'Amiri', 'Scheherazade', 'Times New Roman', serif;
    font-size: 1.3rem;
    line-height: 2;
    text-align: right;
    direction: rtl;
    color: #333;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .logo h1 {
        text-align: center;
        font-size: 1.8rem;
    }

    nav .nav-menu {
        justify-content: center;
        flex-wrap: wrap;
    }

    #user-menu {
        min-width: 0;
    }

    #user-menu .user-dropdown {
        min-width: 0;
        width: 100%;
    }

    .dashboard-container {
        padding: 22px 14px 35px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .pricing-options {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .subscription-modal-content,
    .payment-modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 20px;
    }

    /* Better modal centering and spacing on mobile */
    .subscription-modal {
        display: flex;
        align-items: flex-start;
        justify-content: center;
        padding-top: 16px;
        -webkit-overflow-scrolling: touch;
    }

    .subscription-modal-content {
        box-sizing: border-box;
        width: calc(100% - 32px);
        max-width: 720px;
        padding: 18px;
        margin: 12px auto;
        z-index: 10001;
        border-radius: 14px;
    }

    .plan {
        width: 100%;
        padding: 18px 16px;
        margin: 0;
    }

    .pricing-options {
        gap: 16px;
    }

    /* Make sure Stripe buy button / iframe fills the available width */
    stripe-buy-button,
    .stripe-buy-button,
    .subscription-modal stripe-buy-button,
    .subscription-modal .stripe-buy-button {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 10px 0 !important;
    }

    .subscription-modal .stripe-buy-button>* {
        width: 100% !important;
    }

    .plan.featured {
        transform: none;
        margin-top: 20px;
    }

    .plan.featured:hover {
        transform: translateY(-5px);
    }

    .user-menu,
    .subscription-status-container {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        margin: 10px;
    }

    .practice-counter-container {
        position: relative;
        bottom: auto;
        right: auto;
        margin: 20px;
        text-align: center;
    }

    .premium-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .plan {
        padding: 20px 15px;
    }

    .price {
        font-size: 2rem;
    }

    .subscribe-btn {
        padding: 12px 20px;
        font-size: 1rem;
    }

    /* Small phones: reduce modal padding and respect safe area inset */
    .subscription-modal-content,
    .payment-modal-content {
        padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-left)) calc(18px + env(safe-area-inset-bottom));
        width: calc(100% - 20px);
        margin: 8px auto;
        border-radius: 12px;
    }

    .subscription-modal {
        padding-top: 8px;
    }
}