<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Account - Tameer Al Madina</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

<style>
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #F4F6F9;
    font-family: 'Poppins', sans-serif;
    min-height: 100vh;
}

.main-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

aside, .sidebar, [class*="sidebar"] {
    width: 260px;
    min-width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.content-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    background: #F4F6F9;
    min-width: 0;
    width: calc(100% - 260px);
    transition: all 0.3s ease;
}

/* Navbar Layout */
.top-navbar {
    height: 60px;
    background: #FFFFFF;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    border-bottom: 1px solid #EAEAEA;
}

.navbar-left-flex {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mobile-menu-toggle {
    display: none;
    font-size: 20px;
    color: #0A192F;
    cursor: pointer;
    background: #F4F6F9;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid #E2E8F0;
}

.search-container {
    position: relative;
    width: 300px;
}

.search-container input {
    width: 100%;
    padding: 8px 15px 8px 40px;
    background: #F8F9FA;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}

.search-container i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #A0AEC0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-info i.profile-icon {
    font-size: 26px;
    color: #4A5568;
    background: #F4F6F9;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid #E2E8F0;
}

.profile-text h4 {
    font-size: 13px;
    color: #1A202C;
    font-weight: 600;
}

.profile-text p {
    font-size: 11px;
    color: #718096;
}

/* Page Architecture */
.page-container {
    padding: 20px 30px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.form-card {
    background: #FFFFFF;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}

form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.form-banner {
    background: linear-gradient(135deg, #0A192F 0%, #172A45 100%);
    padding: 15px 30px;
    color: #FFFFFF;
    border-bottom: 4px solid #FF6B00;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.banner-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.banner-icon {
    background: rgba(255, 255, 255, 0.1);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 16px;
}

.banner-text h2 {
    font-size: 18px;
    font-weight: 600;
}

.banner-text p {
    font-size: 11px;
    color: #A0AEC0;
}

/* Elegant Segmented Control Tab Switcher inside Banner */
.tab-container {
    display: flex;
    background-color: rgba(255, 255, 255, 0.08);
    padding: 4px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tab-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: #A0AEC0;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn.active {
    background-color: #FF6B00;
    color: #ffffff;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 18px 30px 10px 30px;
    font-size: 14px;
    font-weight: 600;
    color: #0A192F;
}

.section-header i {
    color: #FF6B00;
    font-size: 16px;
}

/* 3 Column Grid Alignment Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 15px 25px;
    padding: 0 30px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 12px;
    font-weight: 500;
    color: #2D3748;
    margin-bottom: 6px;
}

.required {
    color: #E53E3E;
    margin-left: 3px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 15px;
    color: #A0AEC0;
    font-size: 13px;
    z-index: 2;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    height: 38px;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    padding: 5px 15px 5px 40px;
    font-size: 13px;
    color: #4A5568;
    background: #FFFFFF;
    outline: none;
    box-sizing: border-box;
}

.input-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.input-wrapper .select-caret {
    position: absolute;
    right: 15px;
    left: auto;
    color: #A0AEC0;
    font-size: 11px;
    pointer-events: none;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    border-color: #FF6B00;
    box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.1);
    outline: none;
}

.currency-prefix {
    position: absolute;
    left: 38px;
    color: #4A5568;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
    border-right: 1px solid #E2E8F0;
    padding-right: 8px;
}

.input-wrapper input.has-currency-prefix {
    padding-left: 78px;
}

.full-width {
    grid-column: span 3;
}

.hidden-section {
    display: none !important;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 30px 25px 30px;
    margin-top: auto; 
    border-top: 1px solid #F0F2F5;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 22px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.btn-cancel { background: #EDF2F7; color: #4A5568; }
.btn-submit { background: #FF6B00; color: #FFFFFF; }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 998;
}

@media (min-width: 992px) {
    body { overflow: hidden; }
    .page-container { height: calc(100vh - 60px); }
}

@media (max-width: 1024px) and (min-width: 769px) {
    aside, .sidebar, [class*="sidebar"] { width: 240px; min-width: 240px; }
    .content-wrapper { margin-left: 240px; width: calc(100% - 240px); }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .full-width { grid-column: span 2; }
}

@media (max-width: 768px) {
    body { overflow-y: auto !important; }
    .mobile-menu-toggle { display: inline-flex; }
    aside, .sidebar, [class*="sidebar"] { left: -260px !important; }
    aside.active, .sidebar.active, [class*="sidebar"].active { left: 0 !important; }
    .content-wrapper { margin-left: 0 !important; width: 100% !important; }
    .top-navbar { padding: 0 15px; }
    .search-container { width: 140px; }
    .page-container { padding: 10px; }
    .form-banner { padding: 12px 15px; flex-direction: column; align-items: flex-start; gap: 15px; }
    .form-grid { grid-template-columns: 1fr !important; padding: 0 15px; gap: 12px; }
    .full-width { grid-column: span 1; }
    .form-actions { padding: 15px; justify-content: space-between; }
    .btn { flex: 1; justify-content: center; }
}
</style>
</head>
<body>

<div class="sidebar-overlay" id="sidebarOverlay" onclick="toggleMobileSidebar()"></div>

<div class="main-layout">
    
    <?php 
    $sidebar_path = "/home/tameeralmadina/public_html/TAM/sidebar";
    if (file_exists($sidebar_path)) {
        include $sidebar_path;
    } elseif (file_exists($sidebar_path . ".php")) {
        include $sidebar_path . ".php";
    }
    ?>

    <div class="content-wrapper">
        
        <div class="top-navbar">
            <div class="navbar-left-flex">
                <div class="mobile-menu-toggle" onclick="toggleMobileSidebar()">
                    <i class="fa-solid fa-bars"></i>
                </div>
                <div class="search-container">
                    <i class="fa-solid fa-magnifying-glass"></i>
                    <input type="text" placeholder="Search here...">
                </div>
            </div>
            
            <div class="user-profile">
                <div class="profile-info">
                    <i class="fa-solid fa-circle-user profile-icon"></i>
                    <div class="profile-text">
                        <h4>Admin</h4>
                        <p>Administrator</p>
                    </div>
                </div>
            </div>
        </div>

        <div class="page-container">
            <div class="form-card">
                
                <div class="form-banner">
                    <div class="banner-left">
                        <div class="banner-icon">
                            <i class="fa-solid fa-building-columns"></i>
                        </div>
                        <div class="banner-text">
                            <h2>Add Account</h2>
                            <p>Configure bank terminals and operational liquid cash parameters</p>
                        </div>
                    </div>
                    
                    <div class="tab-container">
                        <button type="button" class="tab-btn active" id="bankTab" onclick="switchTab('bank')">
                            <i class="fa-solid fa-landmark"></i> Bank Account
                        </button>
                        <button type="button" class="tab-btn" id="cashTab" onclick="switchTab('cash')">
                            <i class="fa-solid fa-money-bill-wave"></i> Cash / Petty Cash
                        </button>
                    </div>
                </div>

                <form action="save-accounts.php" method="POST" id="accountForm">
                    <input type="hidden" name="form_type" id="formTypeInput" value="bank">

                    <div>
                        <div class="section-header">
                            <i class="fa-solid fa-sliders"></i> Account Details
                        </div>

                        <div id="bankSection" class="form-grid">
                            <div class="form-group">
                                <label>Account Title / Bank Name<span class="required">*</span></label>
                                <div class="input-wrapper">
                                    <i class="fa-solid fa-building"></i>
                                    <input type="text" name="account_title" id="accountTitle" placeholder="e.g. HBL Operational Account" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label>Account Number<span class="required">*</span></label>
                                <div class="input-wrapper">
                                    <i class="fa-solid fa-hashtag"></i>
                                    <input type="text" name="account_number" id="accountNumber" placeholder="e.g. 1234-56789-01-3" required>
                                </div>
                            </div>
                        </div>

                        <div id="cashSection" class="form-grid hidden-section">
                            <div class="form-group">
                                <label>Cash Account Name<span class="required">*</span></label>
                                <div class="input-wrapper">
                                    <i class="fa-solid fa-wallet"></i>
                                    <input type="text" name="account_name" id="accountName" placeholder="e.g. Petty Cash, Cash in Hand">
                                </div>
                            </div>
                        </div>

                        <div class="section-header">
                            <i class="fa-solid fa-scale-balanced"></i> Financial Valuation
                        </div>

                        <div class="form-grid">
                            <div class="form-group">
                                <label>Currency<span class="required">*</span></label>
                                <div class="input-wrapper">
                                    <i class="fa-solid fa-money-bill-transfer"></i>
                                    <select name="currency" id="currencySelect" onchange="updateCurrencyPrefix()" required>
                                        <option value="PKR" selected>PKR - Rs (Pakistani Rupee)</option>
                                        <option value="OMR">OMR (Omani Rial)</option>
                                    </select>
                                    <i class="fa-solid fa-chevron-down select-caret"></i>
                                </div>
                            </div>
                            <div class="form-group">
                                <label>Initial / Opening Balance<span class="required">*</span></label>
                                <div class="input-wrapper">
                                    <i class="fa-solid fa-coins"></i>
                                    <span class="currency-prefix" id="currencyPrefix">Rs</span>
                                    <input type="number" name="initial_balance" id="initialBalance" step="0.01" value="0.00" class="has-currency-prefix" required>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-actions">
                        <a href="view-accounts.php" class="btn btn-cancel">
                            <i class="fa-solid fa-xmark"></i> Cancel
                        </a>
                        <button type="submit" class="btn btn-submit">
                            <i class="fa-regular fa-floppy-disk"></i> Save Account
                        </button>
                    </div>
                </form>

            </div>
        </div>
    </div>
</div>

<script>
function switchTab(type) {
    var bankTab = document.getElementById("bankTab");
    var cashTab = document.getElementById("cashTab");
    var bankSection = document.getElementById("bankSection");
    var cashSection = document.getElementById("cashSection");
    var formTypeInput = document.getElementById("formTypeInput");
    
    var accountTitle = document.getElementById("accountTitle");
    var accountNumber = document.getElementById("accountNumber");
    var accountName = document.getElementById("accountName");

    formTypeInput.value = type;

    if (type === 'bank') {
        bankTab.classList.add("active");
        cashTab.classList.remove("active");
        
        bankSection.classList.remove("hidden-section");
        cashSection.classList.add("hidden-section");
        
        accountTitle.required = true;
        accountNumber.required = true;
        accountName.required = false;
    } else {
        cashTab.classList.add("active");
        bankTab.classList.remove("active");
        
        cashSection.classList.remove("hidden-section");
        bankSection.classList.add("hidden-section");
        
        accountName.required = true;
        accountTitle.required = false;
        accountNumber.required = false;
    }
}

function updateCurrencyPrefix() {
    var currencySelect = document.getElementById("currencySelect");
    var currencyPrefix = document.getElementById("currencyPrefix");

    if (currencySelect.value === "OMR") {
        currencyPrefix.textContent = "OMR";
    } else {
        currencyPrefix.textContent = "Rs";
    }
}

function toggleMobileSidebar() {
    const sidebarElements = document.querySelectorAll('aside, .sidebar, [class*="sidebar"]');
    const overlay = document.getElementById('sidebarOverlay');
    
    sidebarElements.forEach(sidebar => {
        sidebar.classList.toggle('active');
    });
    
    if(sidebarElements[0].classList.contains('active')) {
        overlay.style.display = 'block';
    } else {
        overlay.style.display = 'none';
    }
}
</script>

</body>
</html>