<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@yield('title', 'Seller Dashboard') - The Mini Port</title>
    
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="color-scheme" content="light only">
    
    <style>
        :root {
            color-scheme: light only;
            --sidebar-width: 280px;
            --sidebar-collapsed: 80px;
            --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            --dark-gradient: linear-gradient(180deg, #1a1f36 0%, #0d1025 100%);
            --card-shadow: 0 4px 20px rgba(0,0,0,0.08);
            --hover-shadow: 0 8px 30px rgba(0,0,0,0.12);
        }
        
        * { box-sizing: border-box; }
        
        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
            min-height: 100vh;
            font-size: 14px;
            color: #212529; /* Force dark text */
            overflow-x: hidden;
        }
        
        /* Premium Sidebar */
        .seller-sidebar {
            position: fixed;
            top: 0;
            left: 0;
            width: var(--sidebar-width);
            height: 100vh;
            background: var(--dark-gradient);
            z-index: 1000;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            overflow-y: auto;
            overflow-x: hidden;
        }
        
        .seller-sidebar::-webkit-scrollbar { width: 4px; }
        .seller-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
        
        .sidebar-brand {
            padding: 1.5rem;
            background: rgba(255,255,255,0.03);
            border-bottom: 1px solid rgba(255,255,255,0.06);
            display: flex;
            align-items: center;
            gap: 12px;
        }
        .sidebar-brand-logo {
            width: 44px;
            height: 44px;
            border-radius: 12px;
            background: var(--primary-gradient);
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 700;
            color: #fff;
            font-size: 1.2rem;
            flex-shrink: 0;
            overflow: hidden;
        }
        .sidebar-brand-logo img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .sidebar-brand-text h6 {
            color: #fff;
            margin: 0;
            font-weight: 600;
            font-size: 0.95rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 160px;
        }
        .sidebar-brand-text small {
            color: rgba(255,255,255,0.5);
            font-size: 0.7rem;
        }
        
        /* Plan Badge */
        .sidebar-plan-badge {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 3px 8px;
            border-radius: 20px;
            font-size: 0.65rem;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        .sidebar-plan-badge.premium { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: #fff; }
        .sidebar-plan-badge.basic { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); }
        
        /* Navigation */
        .nav-section {
            padding: 1rem 0;
        }
        .nav-section-title {
            color: rgba(255,255,255,0.35);
            font-size: 0.65rem;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            font-weight: 600;
            padding: 0.5rem 1.5rem;
            margin-bottom: 0.25rem;
        }
        .nav-item {
            position: relative;
        }
        .nav-link {
            color: rgba(255,255,255,0.65);
            padding: 0.7rem 1.5rem;
            display: flex;
            align-items: center;
            gap: 12px;
            transition: all 0.2s ease;
            text-decoration: none;
            font-size: 0.85rem;
            font-weight: 500;
            border-left: 3px solid transparent;
        }
        .nav-link i {
            font-size: 1.1rem;
            width: 22px;
            text-align: center;
            transition: transform 0.2s;
        }
        .nav-link:hover {
            color: #fff;
            background: rgba(255,255,255,0.05);
        }
        .nav-link:hover i {
            transform: scale(1.1);
        }
        .nav-link.active {
            color: #fff;
            background: linear-gradient(90deg, rgba(102,126,234,0.2) 0%, transparent 100%);
            border-left-color: #667eea;
        }
        .nav-link .badge {
            margin-left: auto;
            font-size: 0.65rem;
            padding: 3px 6px;
        }
        
        /* Main Content */
        .seller-main {
            margin-left: var(--sidebar-width);
            min-height: 100vh;
            transition: margin-left 0.3s;
        }
        
        /* Premium Topbar */
        .seller-topbar {
            background: rgba(255,255,255,0.95);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            padding: 0.75rem 1.5rem;
            box-shadow: 0 1px 3px rgba(0,0,0,0.03);
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: sticky;
            top: 0;
            z-index: 100;
            border-bottom: 1px solid rgba(0,0,0,0.04);
        }
        
        .topbar-left {
            display: flex;
            align-items: center;
            gap: 1rem;
        }
        .topbar-breadcrumb {
            font-size: 0.8rem;
            color: #64748b;
        }
        .topbar-breadcrumb a { color: #667eea; text-decoration: none; }
        
        .topbar-right {
            display: flex;
            align-items: center;
            gap: 0.75rem;
        }
        
        /* Notification Bell */
        .topbar-icon {
            width: 40px;
            height: 40px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #f1f5f9;
            color: #64748b;
            transition: all 0.2s;
            position: relative;
            cursor: pointer;
            border: none;
        }
        .topbar-icon:hover {
            background: #e2e8f0;
            color: #334155;
        }
        .topbar-icon .notification-dot {
            position: absolute;
            top: 8px;
            right: 8px;
            width: 8px;
            height: 8px;
            background: #ef4444;
            border-radius: 50%;
            border: 2px solid #fff;
        }
        
        /* Profile Dropdown */
        .profile-dropdown {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 6px 12px 6px 6px;
            border-radius: 50px;
            background: #f1f5f9;
            cursor: pointer;
            transition: all 0.2s;
            border: none;
        }
        .profile-dropdown:hover {
            background: #e2e8f0;
        }
        .profile-avatar {
            width: 34px;
            height: 34px;
            border-radius: 50%;
            background: var(--primary-gradient);
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            font-weight: 600;
            font-size: 0.85rem;
            overflow: hidden;
        }
        .profile-avatar img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        .profile-info {
            text-align: left;
            line-height: 1.2;
        }
        .profile-info strong {
            font-size: 0.8rem;
            color: #1e293b;
            display: block;
        }
        .profile-info small {
            font-size: 0.7rem;
            color: #64748b;
        }
        
        /* Mobile Toggle */
        .sidebar-toggle {
            display: none;
            width: 40px;
            height: 40px;
            border-radius: 12px;
            background: #f1f5f9;
            border: none;
            color: #64748b;
        }
        
        @media (max-width: 991px) {
            .seller-sidebar {
                transform: translateX(-100%);
            }
            .seller-sidebar.show {
                transform: translateX(0);
            }
            .seller-main {
                margin-left: 0;
            }
            .sidebar-toggle {
                display: flex;
                align-items: center;
                justify-content: center;
            }
            .sidebar-overlay {
                position: fixed;
                top: 0;
                left: 0;
                width: 100%;
                height: 100%;
                background: rgba(0,0,0,0.5);
                z-index: 999;
                opacity: 0;
                visibility: hidden;
                transition: all 0.3s;
            }
            .sidebar-overlay.show {
                opacity: 1;
                visibility: visible;
            }
            .profile-info { display: none; }
        }
        
        /* Content Wrapper */
        .content-wrapper {
            padding: 1.5rem;
        }
        
        /* Utility Classes */
        .gradient-text {
            background: var(--primary-gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .card {
            border: none;
            border-radius: 16px;
            box-shadow: var(--card-shadow);
            transition: all 0.3s ease;
        }
        .card:hover {
            box-shadow: var(--hover-shadow);
            transform: translateY(-2px);
        }
        .card-header {
            background: transparent;
            border-bottom: 1px solid rgba(0,0,0,0.05);
            padding: 1rem 1.25rem;
        }
        
        /* Alert Styling */
        .alert {
            border: none;
            border-radius: 12px;
        }

        /* Global Premium Styles */
        /* Welcome Banner */
        .welcome-banner {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 20px;
            padding: 2rem;
            color: #fff;
            margin-bottom: 1.5rem;
        }
        .welcome-banner h2 { color: #fff; font-weight: 700; }
        .welcome-banner p { color: rgba(255,255,255,0.9); margin-bottom: 0; }
        
        /* Gradient Button */
        .btn-primary-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border: none;
            color: #fff;
            padding: 0.6rem 1.5rem;
            border-radius: 10px;
            font-weight: 500;
            transition: all 0.3s;
        }
        .btn-primary-gradient:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(102,126,234,0.4);
            color: #fff;
        }

        /* Page Header */
        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            flex-wrap: wrap;
            gap: 1rem;
        }
        .page-title { font-weight: 700; color: #1e293b; margin-bottom: 0; }
        
        /* Stat Cards */
        .stat-card {
            border-radius: 16px;
            padding: 1.25rem;
            color: #fff;
            display: flex;
            align-items: flex-start;
            gap: 1rem;
            transition: all 0.3s;
            height: 100%;
        }
        .stat-card:hover { transform: translateY(-4px); }
        .stat-card-primary { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
        .stat-card-success { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
        .stat-card-warning { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
        .stat-card-info { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
        
        .stat-icon {
            width: 48px;
            height: 48px;
            background: rgba(255,255,255,0.2);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.4rem;
            flex-shrink: 0;
        }
        .stat-value { font-size: 1.8rem; font-weight: 700; display: block; line-height: 1; }
        .stat-label { font-size: 0.8rem; opacity: 0.9; display: block; margin-bottom: 0.25rem; }
        
        /* Avatar */
        .avatar-circle {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            font-size: 0.9rem;
            flex-shrink: 0;
        }

        /* Table Styling */
        .table-hover tbody tr:hover {
            background-color: rgba(102,126,234,0.02);
        }
        .table thead th {
            font-weight: 600;
            text-transform: uppercase;
            font-size: 0.75rem;
            letter-spacing: 0.5px;
            color: #64748b;
            background: #f8fafc;
            border-bottom: 1px solid #e2e8f0;
            padding: 1rem;
        }
        .table td {
            padding: 1rem;
            vertical-align: middle;
            color: #334155;
        }
    </style>
    @stack('styles')
</head>
<body>
    @php
        $seller = Auth::user()->seller ?? null;
        $currentRoute = Route::currentRouteName();
        $hasPremiumPlan = $seller && $seller->plan && $seller->plan->price_inr > 0;
    @endphp

    <!-- Sidebar Overlay -->
    <div class="sidebar-overlay" id="sidebarOverlay"></div>

    <!-- Sidebar -->
    <nav class="seller-sidebar" id="sellerSidebar">
        <div class="sidebar-brand">
            <div class="sidebar-brand-logo">
                @if($seller && $seller->logo)
                    <img src="{{ asset('storage/' . $seller->logo) }}" alt="Logo">
                @else
                    {{ strtoupper(substr($seller->company_name ?? 'S', 0, 1)) }}
                @endif
            </div>
            <div class="sidebar-brand-text">
                <h6>{{ Str::limit($seller->company_name ?? 'Seller', 18) }}</h6>
                <span class="sidebar-plan-badge {{ $hasPremiumPlan ? 'premium' : 'basic' }}">
                    <i class="bi bi-{{ $hasPremiumPlan ? 'gem' : 'person' }}"></i>
                    {{ $seller->plan->name ?? 'Free' }}
                </span>
            </div>
        </div>
        
        <div class="nav-section">
            <div class="nav-section-title">Main Menu</div>
            <a href="{{ route('seller.dashboard') }}" class="nav-link {{ $currentRoute == 'seller.dashboard' ? 'active' : '' }}">
                <i class="bi bi-grid-1x2-fill"></i> Dashboard
            </a>
            <a href="{{ route('seller.products.index') }}" class="nav-link {{ str_contains($currentRoute, 'products') ? 'active' : '' }}">
                <i class="bi bi-box-seam-fill"></i> Products
                @if($seller)<span class="badge bg-secondary">{{ $seller->products()->count() }}</span>@endif
            </a>
            <a href="{{ route('seller.inquiries.index') }}" class="nav-link {{ str_contains($currentRoute, 'inquiries') ? 'active' : '' }}">
                <i class="bi bi-envelope-fill"></i> Inquiries
            </a>
            <a href="{{ route('seller.quotes.index') }}" class="nav-link {{ str_contains($currentRoute, 'quotes') ? 'active' : '' }}">
                <i class="bi bi-chat-square-quote-fill"></i> Quotes
            </a>
            <a href="{{ route('seller.rfqs') }}" class="nav-link {{ $currentRoute == 'seller.rfqs' ? 'active' : '' }}">
                <i class="bi bi-megaphone-fill"></i> Buy Leads
            </a>
        </div>
        
        <div class="nav-section">
            <div class="nav-section-title">Promotions</div>
            <a href="{{ route('seller.promotions.index') }}" class="nav-link {{ str_contains($currentRoute, 'promotions.') && !str_contains($currentRoute, 'packages') ? 'active' : '' }}">
                <i class="bi bi-megaphone-fill"></i> My Promotions
            </a>
            <a href="{{ route('seller.promotions.packages') }}" class="nav-link {{ str_contains($currentRoute, 'promotions.packages') ? 'active' : '' }}">
                <i class="bi bi-star-fill"></i> Promote Products
            </a>
        </div>
        
        <div class="nav-section">
            <div class="nav-section-title">Microsite</div>
            <a href="{{ route('seller.microsite.settings') }}" class="nav-link {{ str_contains($currentRoute, 'microsite.settings') ? 'active' : '' }}">
                <i class="bi bi-palette-fill"></i> Settings
            </a>
            <a href="{{ route('seller.banners.index') }}" class="nav-link {{ str_contains($currentRoute, 'banners') ? 'active' : '' }}">
                <i class="bi bi-images"></i> Banners
            </a>
            <a href="{{ route('seller.microsite.testimonials') }}" class="nav-link {{ str_contains($currentRoute, 'testimonials') ? 'active' : '' }}">
                <i class="bi bi-chat-heart-fill"></i> Testimonials
            </a>
            <a href="{{ route('seller.microsite.faqs') }}" class="nav-link {{ str_contains($currentRoute, 'faqs') ? 'active' : '' }}">
                <i class="bi bi-question-circle-fill"></i> FAQs
            </a>
            <a href="{{ route('seller.microsite.analytics') }}" class="nav-link {{ str_contains($currentRoute, 'microsite.analytics') ? 'active' : '' }}">
                <i class="bi bi-bar-chart-fill"></i> Analytics
            </a>
        </div>
        
        <div class="nav-section">
            <div class="nav-section-title">Account</div>
            <a href="{{ route('seller.profile') }}" class="nav-link {{ $currentRoute == 'seller.profile' ? 'active' : '' }}">
                <i class="bi bi-person-fill"></i> Profile
            </a>
            <a href="{{ route('seller.verification.index') }}" class="nav-link {{ str_contains($currentRoute, 'verification') ? 'active' : '' }}">
                <i class="bi bi-shield-check"></i> Verification Center
            </a>
            <a href="{{ route('seller.subscription.index') }}" class="nav-link {{ str_contains($currentRoute, 'subscription') ? 'active' : '' }}">
                <i class="bi bi-gem"></i> Subscription
            </a>
            @if($seller && $seller->slug)
                <a href="{{ route('seller.public.profile', $seller->slug) }}" target="_blank" class="nav-link">
                    <i class="bi bi-box-arrow-up-right"></i> View Microsite
                </a>
            @endif
        </div>
        
        <div class="nav-section" style="margin-top: auto; padding-bottom: 1.5rem;">
            <a href="{{ route('logout') }}" class="nav-link text-danger" 
               onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                <i class="bi bi-box-arrow-left"></i> Logout
            </a>
            <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">@csrf</form>
        </div>
    </nav>

    <!-- Main Content -->
    <div class="seller-main">
        <!-- Topbar -->
        <div class="seller-topbar">
            <div class="topbar-left">
                <button class="sidebar-toggle" id="sidebarToggle">
                    <i class="bi bi-list fs-5"></i>
                </button>
                <div class="topbar-breadcrumb d-none d-md-block">
                    <a href="{{ route('seller.dashboard') }}">Dashboard</a> / @yield('title', 'Overview')
                </div>
            </div>
            
            <div class="topbar-right">
                <!-- Notification Bell -->
                @include('partials.notification-bell')
                
                <!-- Profile Dropdown -->
                <div class="dropdown">
                    <button class="profile-dropdown" type="button" data-bs-toggle="dropdown">
                        <div class="profile-avatar">
                            @if($seller && $seller->logo)
                                <img src="{{ asset('storage/' . $seller->logo) }}" alt="Profile">
                            @else
                                {{ strtoupper(substr(Auth::user()->name, 0, 1)) }}
                            @endif
                        </div>
                        <div class="profile-info">
                            <strong>{{ Str::limit(Auth::user()->name, 15) }}</strong>
                            <small>{{ $seller->company_name ? 'Seller' : 'User' }}</small>
                        </div>
                        <i class="bi bi-chevron-down text-muted ms-1" style="font-size: 0.7rem;"></i>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-end shadow-lg border-0" style="min-width: 200px;">
                        <li class="px-3 py-2 border-bottom">
                            <small class="text-muted">Signed in as</small>
                            <div class="fw-bold text-truncate">{{ Auth::user()->email }}</div>
                        </li>
                        <li><a class="dropdown-item py-2" href="{{ route('seller.profile') }}"><i class="bi bi-person me-2"></i>Profile</a></li>
                        <li><a class="dropdown-item py-2" href="{{ route('seller.subscription.index') }}"><i class="bi bi-gem me-2"></i>Subscription</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li>
                            <a class="dropdown-item py-2 text-danger" href="{{ route('logout') }}"
                               onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                                <i class="bi bi-box-arrow-left me-2"></i>Logout
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        
        <!-- Content -->
        <div class="content-wrapper">
            @if(session('success'))
                <div class="alert alert-success alert-dismissible fade show d-flex align-items-center" role="alert">
                    <i class="bi bi-check-circle-fill me-2"></i>{{ session('success') }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            @endif
            @if(session('error'))
                <div class="alert alert-danger alert-dismissible fade show d-flex align-items-center" role="alert">
                    <i class="bi bi-x-circle-fill me-2"></i>{{ session('error') }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            @endif
            
            @yield('content')
        </div>
    </div>

    <!-- Scripts -->
    <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- Alpine.js -->
    <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
    
    <script>
        // Sidebar Toggle
        document.getElementById('sidebarToggle')?.addEventListener('click', function() {
            document.getElementById('sellerSidebar').classList.toggle('show');
            document.getElementById('sidebarOverlay').classList.toggle('show');
        });
        document.getElementById('sidebarOverlay')?.addEventListener('click', function() {
            document.getElementById('sellerSidebar').classList.remove('show');
            this.classList.remove('show');
        });
    </script>
    
    @stack('scripts')
</body>
</html>
