'use client';

import { Box, Container, Typography, Paper } from '@mui/material';
import Link from 'next/link';
import { AppShell } from '@/components/layouts/AppShell/AppShell';
import { ProtectedRoute } from '@/components/common/ProtectedRoute';

export default function EULAPage() {
  const lastUpdated = 'October 4, 2025';

  return (
    <ProtectedRoute>
      <AppShell>
        <Container maxWidth="md" sx={{ py: 4 }}>
      <Paper elevation={0} sx={{ p: 4, border: 1, borderColor: 'divider' }}>
        <Typography variant="h3" component="h1" gutterBottom>
          End User License Agreement (EULA)
        </Typography>

        <Typography variant="body2" color="text.secondary" paragraph>
          Last Updated: {lastUpdated}
        </Typography>

        <Box sx={{ mt: 4 }}>
          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            1. License Grant
          </Typography>
          <Typography paragraph>
            Subject to your compliance with this End User License Agreement ("EULA"), ParentFlow grants you a limited,
            non-exclusive, non-transferable, revocable license to use the ParentFlow mobile application (the "App")
            for your personal, non-commercial use.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            2. License Restrictions
          </Typography>
          <Typography paragraph>
            You agree NOT to:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>Copy, modify, or create derivative works of the App</li>
              <li>Reverse engineer, decompile, or disassemble the App</li>
              <li>Remove or alter any copyright, trademark, or proprietary notices</li>
              <li>Rent, lease, loan, sell, or sublicense the App</li>
              <li>Use the App for any commercial purpose without authorization</li>
              <li>Use the App in any way that violates applicable laws or regulations</li>
              <li>Use automated tools or bots to access the App</li>
              <li>Interfere with or disrupt the App's servers or networks</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            3. Intellectual Property Rights
          </Typography>
          <Typography paragraph>
            The App and all its components, including but not limited to software code, design, graphics, text, and user interface,
            are owned by ParentFlow and are protected by copyright, trademark, and other intellectual property laws.
          </Typography>
          <Typography paragraph>
            This EULA does not grant you any ownership rights to the App. All rights not expressly granted are reserved by ParentFlow.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            4. User Data and Privacy
          </Typography>
          <Typography paragraph>
            Your use of the App is subject to our{' '}
            <Link href="/legal/privacy" style={{ color: 'inherit', fontWeight: 'bold' }}>
              Privacy Policy
            </Link>
            , which explains how we collect, use, and protect your information.
          </Typography>
          <Typography paragraph>
            You retain ownership of all data you input into the App, including activity logs, photos, and personal information.
            By using the App, you grant us a license to process your data to provide the Service.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            5. Updates and Modifications
          </Typography>
          <Typography paragraph>
            We may release updates, patches, or new versions of the App from time to time. These updates may:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>Add new features or functionality</li>
              <li>Fix bugs or security vulnerabilities</li>
              <li>Improve performance</li>
              <li>Remove or modify existing features</li>
            </ul>
          </Typography>
          <Typography paragraph>
            By continuing to use the App after an update, you accept the updated version and any changes to this EULA.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            6. Medical Disclaimer
          </Typography>
          <Typography paragraph sx={{ fontWeight: 'bold', color: 'error.main' }}>
            THE APP IS NOT A MEDICAL DEVICE AND DOES NOT PROVIDE MEDICAL ADVICE.
          </Typography>
          <Typography paragraph>
            The App's tracking features and AI assistant provide general information and insights only. They are not a substitute
            for professional medical advice, diagnosis, or treatment. Always seek the advice of qualified healthcare providers
            with questions regarding your child's health.
          </Typography>
          <Typography paragraph>
            <strong>In medical emergencies, call your local emergency number immediately.</strong>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            7. AI Features and Limitations
          </Typography>
          <Typography paragraph>
            The App includes AI-powered features (such as the parenting assistant) that use machine learning models.
            You acknowledge that:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>AI responses may not always be accurate or complete</li>
              <li>AI cannot replace professional judgment or expertise</li>
              <li>You use AI features at your own risk</li>
              <li>We are not liable for decisions made based on AI recommendations</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            8. Third-Party Services
          </Typography>
          <Typography paragraph>
            The App may integrate with or link to third-party services (e.g., cloud storage, analytics, payment processors).
            Your use of these third-party services is governed by their own terms and privacy policies.
          </Typography>
          <Typography paragraph>
            We are not responsible for the availability, content, or practices of third-party services.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            9. Termination
          </Typography>

          <Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
            9.1 Termination by You
          </Typography>
          <Typography paragraph>
            You may terminate this EULA at any time by:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>Deleting your account through the App settings</li>
              <li>Uninstalling the App from all your devices</li>
              <li>Ceasing all use of the App</li>
            </ul>
          </Typography>

          <Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
            9.2 Termination by Us
          </Typography>
          <Typography paragraph>
            We may terminate or suspend your license to use the App immediately if you:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>Violate any terms of this EULA</li>
              <li>Engage in illegal or harmful activities</li>
              <li>Fail to pay subscription fees (if applicable)</li>
              <li>Pose a security risk to the App or other users</li>
            </ul>
          </Typography>

          <Typography variant="h6" gutterBottom sx={{ mt: 2 }}>
            9.3 Effect of Termination
          </Typography>
          <Typography paragraph>
            Upon termination:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>Your license to use the App ends immediately</li>
              <li>You must uninstall the App from all devices</li>
              <li>Your data will be deleted in accordance with our Privacy Policy</li>
              <li>Provisions of this EULA that should survive termination will remain in effect</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            10. Disclaimers and Warranties
          </Typography>
          <Typography paragraph sx={{ fontWeight: 'bold' }}>
            THE APP IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTIES OF ANY KIND.
          </Typography>
          <Typography paragraph>
            TO THE MAXIMUM EXTENT PERMITTED BY LAW, WE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>Warranties of merchantability</li>
              <li>Warranties of fitness for a particular purpose</li>
              <li>Warranties of non-infringement</li>
              <li>Warranties that the App will be error-free or uninterrupted</li>
              <li>Warranties regarding data accuracy or completeness</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            11. Limitation of Liability
          </Typography>
          <Typography paragraph sx={{ fontWeight: 'bold' }}>
            TO THE MAXIMUM EXTENT PERMITTED BY LAW:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>WE SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES</li>
              <li>WE SHALL NOT BE LIABLE FOR ANY LOSS OF DATA, REVENUE, PROFITS, OR BUSINESS OPPORTUNITIES</li>
              <li>OUR TOTAL LIABILITY SHALL NOT EXCEED THE AMOUNT YOU PAID US IN THE 12 MONTHS PRECEDING THE CLAIM, OR $100, WHICHEVER IS GREATER</li>
            </ul>
          </Typography>
          <Typography paragraph>
            Some jurisdictions do not allow limitations on liability, so these limitations may not apply to you.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            12. Indemnification
          </Typography>
          <Typography paragraph>
            You agree to indemnify, defend, and hold harmless ParentFlow, its officers, directors, employees, contractors,
            and agents from any claims, damages, losses, or expenses (including attorney's fees) arising from:
          </Typography>
          <Typography component="div" paragraph>
            <ul>
              <li>Your use or misuse of the App</li>
              <li>Your violation of this EULA</li>
              <li>Your violation of any laws or regulations</li>
              <li>Your violation of third-party rights</li>
            </ul>
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            13. Export Compliance
          </Typography>
          <Typography paragraph>
            The App may be subject to export control laws and regulations. You agree to comply with all applicable export
            and import laws and not to export, re-export, or transfer the App in violation of such laws.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            14. Governing Law and Dispute Resolution
          </Typography>
          <Typography paragraph>
            This EULA is governed by the laws of [Your Jurisdiction], without regard to conflict of law principles.
          </Typography>
          <Typography paragraph>
            Any disputes arising from this EULA will be resolved through binding arbitration in accordance with the
            American Arbitration Association rules, except where prohibited by law.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            15. Severability
          </Typography>
          <Typography paragraph>
            If any provision of this EULA is found to be invalid or unenforceable, that provision will be limited or eliminated
            to the minimum extent necessary, and the remaining provisions will remain in full force and effect.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            16. Entire Agreement
          </Typography>
          <Typography paragraph>
            This EULA, together with our{' '}
            <Link href="/legal/terms" style={{ color: 'inherit', fontWeight: 'bold' }}>
              Terms of Service
            </Link>{' '}
            and{' '}
            <Link href="/legal/privacy" style={{ color: 'inherit', fontWeight: 'bold' }}>
              Privacy Policy
            </Link>
            , constitutes the entire agreement between you and ParentFlow regarding the App.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            17. Changes to This EULA
          </Typography>
          <Typography paragraph>
            We may update this EULA from time to time to reflect changes in the App or legal requirements. We will notify you
            of material changes by email or through the App. Your continued use of the App after changes constitutes acceptance
            of the updated EULA.
          </Typography>

          <Typography variant="h5" gutterBottom sx={{ mt: 3 }}>
            18. Contact Us
          </Typography>
          <Typography paragraph>
            If you have questions about this EULA, please contact us:
          </Typography>
          <Typography component="div" paragraph>
            <strong>Email:</strong> hello@parentflow.com<br />
            <strong>Address:</strong> Serbota 3, Bucharest, Romania
          </Typography>

          <Box sx={{ mt: 4, pt: 3, borderTop: 1, borderColor: 'divider' }}>
            <Typography variant="h6" gutterBottom>
              Acceptance of EULA
            </Typography>
            <Typography paragraph>
              BY CLICKING "I ACCEPT" DURING APP SETUP, CREATING AN ACCOUNT, OR CONTINUING TO USE THE APP, YOU ACKNOWLEDGE
              THAT YOU HAVE READ, UNDERSTOOD, AND AGREE TO BE BOUND BY THIS EULA.
            </Typography>
            <Typography paragraph>
              IF YOU DO NOT AGREE TO THIS EULA, DO NOT USE THE APP.
            </Typography>
          </Box>

          <Box sx={{ mt: 4, pt: 3, borderTop: 1, borderColor: 'divider' }}>
            <Typography variant="body2" color="text.secondary">
              Related Legal Documents:
            </Typography>
            <Box sx={{ display: 'flex', gap: 2, mt: 1, flexWrap: 'wrap' }}>
              <Link href="/legal/privacy" style={{ textDecoration: 'none' }}>
                <Typography color="primary" sx={{ '&:hover': { textDecoration: 'underline' } }}>
                  Privacy Policy
                </Typography>
              </Link>
              <Link href="/legal/terms" style={{ textDecoration: 'none' }}>
                <Typography color="primary" sx={{ '&:hover': { textDecoration: 'underline' } }}>
                  Terms of Service
                </Typography>
              </Link>
              <Link href="/legal/cookies" style={{ textDecoration: 'none' }}>
                <Typography color="primary" sx={{ '&:hover': { textDecoration: 'underline' } }}>
                  Cookie Policy
                </Typography>
              </Link>
            </Box>
          </Box>
        </Box>
      </Paper>
    </Container>
      </AppShell>
    </ProtectedRoute>
  );
}
