<?php
session_start();
if(!isset($_SESSION['clientId'])) {
    header("location:login.php");
    exit();
}
// Determine the correct path based on current directory
$currentDir = basename(dirname($_SERVER['PHP_SELF']));
$pathPrefix = ($currentDir !== 'client') ? '../' : '';
include($pathPrefix . 'connect.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>My Care | Client Portal</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap">
    <?php
    // Determine correct path for assets
    $assetPath = ($currentDir !== 'client') ? '../../' : '../';
    ?>
    <link rel="stylesheet" href="<?= $assetPath; ?>plugins/fontawesome-free/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.datatables.net/1.13.4/css/dataTables.bootstrap4.min.css">
    <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Inter', sans-serif;
            background: #f5f7fa;
            color: #2d3748;
        }
        
        .wrapper {
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }
        
        .main-content {
            flex: 1;
            padding-top: 80px;
        }
        
        /* Custom scrollbar */
        ::-webkit-scrollbar {
            width: 10px;
            height: 10px;
        }
        
        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        }
        
        ::-webkit-scrollbar-thumb {
            background: #1a70b8;
            border-radius: 5px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: #60e438;
        }
        
        /* DataTables styling */
        .dataTables_wrapper .dataTables_paginate .paginate_button.current {
            background: linear-gradient(135deg, #1a70b8 0%, #60e438 100%) !important;
            border-color: #1a70b8 !important;
            color: white !important;
        }
        
        .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
            background: #1a70b8 !important;
            border-color: #1a70b8 !important;
            color: white !important;
        }
        
        /* Button styling */
        .btn-primary {
            background: linear-gradient(135deg, #1a70b8 0%, #60e438 100%);
            border: none;
            transition: all 0.3s ease;
            color: white;
            padding: 10px 24px;
            border-radius: 8px;
            font-weight: 600;
        }
        
        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(26, 112, 184, 0.4);
            color: white;
        }
        
        .btn-secondary {
            background: #e2e8f0;
            color: #4a5568;
            border: none;
            padding: 10px 24px;
            border-radius: 8px;
            font-weight: 600;
            transition: all 0.3s ease;
        }
        
        .btn-secondary:hover {
            background: #cbd5e0;
            color: #2d3748;
        }
        
        .btn-success {
            background: #60e438;
            color: white;
            border: none;
            padding: 10px 24px;
            border-radius: 8px;
            font-weight: 600;
        }
        
        .btn-info {
            background: #1a70b8;
            color: white;
            border: none;
            padding: 8px 16px;
            border-radius: 6px;
            font-weight: 500;
        }
        
        .btn-sm {
            padding: 6px 14px;
            font-size: 14px;
        }
        
        /* Card styling */
        .card {
            border: none;
            box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
            border-radius: 16px;
            background: white;
            margin-bottom: 24px;
        }
        
        .card-header {
            background: white;
            border-bottom: 1px solid #e2e8f0;
            border-radius: 16px 16px 0 0 !important;
            padding: 20px 24px;
        }
        
        .card-body {
            padding: 24px;
        }
        
        /* Form styling */
        .form-control {
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            padding: 10px 14px;
            font-size: 15px;
            transition: all 0.3s ease;
        }
        
        .form-control:focus {
            border-color: #1a70b8;
            box-shadow: 0 0 0 3px rgba(26, 112, 184, 0.1);
            outline: none;
        }
        
        .form-group label {
            font-weight: 600;
            color: #2d3748;
            margin-bottom: 8px;
            font-size: 14px;
        }
        
        .select2-container--default .select2-selection--single {
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            height: 42px;
            padding: 6px;
        }
        
        .select2-container--default .select2-selection--single:focus {
            border-color: #1a70b8;
        }
        
        /* Alert styling */
        .alert {
            border: none;
            border-radius: 12px;
            padding: 14px 18px;
            margin-bottom: 20px;
        }
        
        .alert-success {
            background: #d4f4dd;
            color: #1e7e34;
            border-left: 4px solid #60e438;
        }
        
        .alert-danger {
            background: #fed7d7;
            color: #742a2a;
            border-left: 4px solid #e53e3e;
        }
        
        .alert-warning {
            background: #feebc8;
            color: #744210;
            border-left: 4px solid #ed8936;
        }
        
        .alert-info {
            background: #bee3f8;
            color: #2c5282;
            border-left: 4px solid #1a70b8;
        }
        
        /* Table styling */
        .table {
            width: 100%;
            margin-bottom: 0;
        }
        
        .table thead th {
            background: #f7fafc;
            color: #4a5568;
            font-weight: 600;
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            padding: 14px;
            border-bottom: 2px solid #e2e8f0;
        }
        
        .table tbody td {
            padding: 14px;
            border-bottom: 1px solid #e2e8f0;
            color: #2d3748;
            font-size: 14px;
            vertical-align: middle;
        }
        
        .table tbody tr:hover {
            background: #f7fafc;
        }
        
        /* Badge styling */
        .badge {
            padding: 6px 12px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
            display: inline-block;
        }
        
        .badge-success {
            background: #d4f4dd;
            color: #1e7e34;
        }
        
        .badge-warning {
            background: #feebc8;
            color: #744210;
        }
        
        .badge-info {
            background: #bee3f8;
            color: #2c5282;
        }
        
        .badge-secondary {
            background: #e2e8f0;
            color: #4a5568;
        }
    </style>
</head>
<body>
<div class="wrapper">
