/*
Theme Name: GaadiWaadi
Theme URI: https://gaadiwaadi.example
Author: GaadiWaadi
Description: A fast, premium WooCommerce theme for car accessories.
Version: 1.0.0
Text Domain: gaadiwaadi// Enqueue WordPress Media Uploader scripts on taxonomy pages
function gaadiwaadi_enqueue_media($hook) {
    if ($hook === 'edit-tags.php' || $hook === 'term.php') {
        wp_enqueue_media();
        add_action('admin_footer', 'gaadiwaadi_taxonomy_media_script');
    }
}
add_action('admin_enqueue_scripts', 'gaadiwaadi_enqueue_media');

// Add Image field to the "Add New Category" form
function gaadiwaadi_add_category_image_field() {
    ?>
    <div class="form-field term-group">
        <label for="category-image-id"><?php _e('Category Picture', 'gaadiwaadi'); ?></label>
        <input type="hidden" id="category-image-id" name="category_image_id" value="">
        <div id="category-image-wrapper"></div>
        <p>
            <button type="button" class="button button-secondary gaadiwaadi_upload_btn" id="gaadiwaadi_upload_btn">Upload/Add Image</button>
            <button type="button" class="button button-secondary gaadiwaadi_remove_btn" id="gaadiwaadi_remove_btn" style="display:none;">Remove Image</button>
        </p>
    </div>
    <?php
}
add_action('category_add_form_fields', 'gaadiwaadi_add_category_image_field', 10, 2);

// Add Image field to the "Edit Category" form
function gaadiwaadi_edit_category_image_field($term) {
    $image_id = get_term_meta($term->term_id, 'category_image_id', true);
    ?>
    <tr class="form-field term-group-wrap">
        <th scope="row"><label for="category-image-id"><?php _e('Category Picture', 'gaadiwaadi'); ?></label></th>
        <td>
            <input type="hidden" id="category-image-id" name="category_image_id" value="<?php echo esc_attr($image_id); ?>">
            <div id="category-image-wrapper">
                <?php if ($image_id) : ?>
                    <?php echo wp_get_attachment_image($image_id, 'thumbnail'); ?>
                <?php endif; ?>
            </div>
            <p style="margin-top:10px;">
                <button type="button" class="button button-secondary gaadiwaadi_upload_btn" id="gaadiwaadi_upload_btn">
                    <?php echo $image_id ? __('Change Image', 'gaadiwaadi') : __('Upload/Add Image', 'gaadiwaadi'); ?>
                </button>
                <button type="button" class="button button-secondary gaadiwaadi_remove_btn" id="gaadiwaadi_remove_btn" style="<?php echo $image_id ? '' : 'display:none;'; ?>">
                    <?php _e('Remove Image', 'gaadiwaadi'); ?>
                </button>
            </p>
        </td>
    </tr>
    <?php
}
add_action('category_edit_form_fields', 'gaadiwaadi_edit_category_image_field', 10, 2);

// Save the term metadata
function gaadiwaadi_save_category_image($term_id) {
    if (isset($_POST['category_image_id'])) {
        if (!empty($_POST['category_image_id'])) {
            update_term_meta($term_id, 'category_image_id', absint($_POST['category_image_id']));
        } else {
            delete_term_meta($term_id, 'category_image_id');
        }
    }
}
add_action('created_category', 'gaadiwaadi_save_category_image', 10, 2);
add_action('edited_category', 'gaadiwaadi_save_category_image', 10, 2);

// Media Modal JavaScript in Admin Footer
function gaadiwaadi_taxonomy_media_script() {
    ?>
    <script>
    jQuery(document).ready(function($) {
        var frame;
        $(document).on('click', '.gaadiwaadi_upload_btn', function(e) {
            e.preventDefault();
            if (frame) {
                frame.open();
                return;
            }
            frame = wp.media({
                title: 'Select or Upload Category Picture',
                button: { text: 'Use this picture' },
                multiple: false
            });
            frame.on('select', function() {
                var attachment = frame.state().get('selection').first().toJSON();
                $('#category-image-id').val(attachment.id);
                var imgUrl = attachment.sizes && attachment.sizes.thumbnail ? attachment.sizes.thumbnail.url : attachment.url;
                $('#category-image-wrapper').html('<img src="' + imgUrl + '" style="max-width:150px;height:auto;display:block;margin-bottom:8px;"/>');
                $('.gaadiwaadi_remove_btn').show();
            });
            frame.open();
        });

        $(document).on('click', '.gaadiwaadi_remove_btn', function(e) {
            e.preventDefault();
            $('#category-image-id').val('');
            $('#category-image-wrapper').html('');
            $(this).hide();
            $('.gaadiwaadi_upload_btn').text('Upload/Add Image');
        });
    });
    </script>
    <?php
}

*/

:root{--ink:#111318;--muted:#69707c;--paper:#f7f7f5;--line:#e5e6e3;--red:#ef382f;--orange:#ff6b32;--lime:#d9ff45;--white:#fff;--radius:22px;--shadow:0 18px 50px rgba(16,19,24,.10)}
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:var(--paper);color:var(--ink);font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;line-height:1.5}a{text-decoration:none;color:inherit}.wrap{width:min(1180px,calc(100% - 40px));margin:auto}.topline{background:var(--ink);color:#f9f9f7;font-size:12px;font-weight:700;letter-spacing:.03em}.topline .wrap{min-height:38px;display:flex;align-items:center;justify-content:space-between}.topline span:last-child{opacity:.65}.site-header{background:rgba(247,247,245,.92);border-bottom:1px solid var(--line);position:sticky;top:0;z-index:30;backdrop-filter:blur(15px)}.head-inner{min-height:76px;display:flex;align-items:center;justify-content:space-between;gap:25px}.brand{font-weight:900;font-size:25px;letter-spacing:-1.5px;display:flex;align-items:center;gap:9px}.brand-mark{background:var(--red);width:28px;height:28px;border-radius:8px;display:grid;place-items:center;color:#fff;font-size:15px;transform:skew(-8deg)}.main-nav{display:flex;gap:25px;font-weight:750;font-size:14px}.main-nav a:hover,.main-nav .current{color:var(--red)}.head-actions{display:flex;align-items:center;gap:14px;font-size:14px;font-weight:750}.search-btn{border:0;background:transparent;font-size:19px;cursor:pointer}.cart-pill{background:var(--ink);color:#fff;padding:10px 14px;border-radius:99px}.hero{padding:54px 0 70px;overflow:hidden}.hero-card{background:var(--ink);color:#fff;border-radius:32px;min-height:510px;position:relative;overflow:hidden;display:grid;grid-template-columns:1fr 1.04fr;align-items:center;padding:64px}.hero-card:after{content:"";position:absolute;width:700px;height:700px;border-radius:50%;background:radial-gradient(circle,rgba(239,56,47,.6),transparent 65%);right:-180px;top:-190px}.eyebrow{display:inline-flex;gap:8px;align-items:center;color:var(--lime);font-weight:800;font-size:12px;letter-spacing:.1em;text-transform:uppercase}.eyebrow i{width:8px;height:8px;background:var(--lime);border-radius:50%}.hero h1{font-size:clamp(45px,5vw,75px);line-height:.94;letter-spacing:-.065em;margin:19px 0 22px;max-width:580px;position:relative;z-index:1}.hero h1 em{font-style:normal;color:var(--lime)}.hero p{max-width:450px;color:#b8bcc4;font-size:17px;margin-bottom:32px;position:relative;z-index:1}.button{display:inline-flex;align-items:center;gap:12px;background:var(--red);color:#fff;padding:14px 21px;border-radius:10px;font-size:14px;font-weight:850;position:relative;z-index:1;transition:.2s}.button:hover{background:var(--orange);transform:translateY(-2px)}.button.alt{background:#fff;color:var(--ink);margin-left:9px}.hero-art{align-self:stretch;position:relative;z-index:2}.car{position:absolute;right:-18px;top:107px;width:540px;height:245px;background:linear-gradient(145deg,#ff5246 0%,#c40f18 46%,#57080e 100%);border-radius:150px 240px 52px 50px;transform:skewX(-8deg);box-shadow:inset -15px -20px 25px rgba(0,0,0,.3),0 45px 50px rgba(0,0,0,.4)}.car:before{content:"";position:absolute;background:linear-gradient(150deg,#b5e5f1,#1d3441 58%,#05070a);width:244px;height:99px;top:-62px;left:129px;border-radius:78px 132px 8px 8px;transform:skewX(8deg)}.car:after{content:"";position:absolute;background:#ffedc1;width:105px;height:38px;border-radius:50px 10px 10px 4px;right:10px;top:73px;box-shadow:-392px 43px 0 -4px #cb0915}.wheel{position:absolute;border:14px solid #15171d;background:radial-gradient(circle,#bbb 0 20%,#282b30 22% 48%,#101216 50%);width:100px;height:100px;border-radius:50%;bottom:-49px;z-index:3;box-shadow:0 0 0 5px #08090a}.wheel.one{left:94px}.wheel.two{right:75px}.speed{position:absolute;right:-52px;top:75px;color:transparent;width:420px;height:140px;border-top:2px solid rgba(217,255,69,.6);border-radius:100%;transform:rotate(-12deg);opacity:.75}.trust{display:grid;grid-template-columns:repeat(3,1fr);gap:1px;background:var(--line);border:1px solid var(--line);border-radius:16px;overflow:hidden;margin-top:25px}.trust div{background:var(--white);padding:19px 24px;font-size:13px;font-weight:750}.trust b{display:block;font-size:17px;margin-bottom:1px}.section{padding:82px 0}.section-label{font-size:12px;color:var(--red);font-weight:900;letter-spacing:.12em;text-transform:uppercase}.section-title{font-size:clamp(33px,4vw,52px);line-height:1;letter-spacing:-.055em;margin:10px 0 0}.section-top{display:flex;justify-content:space-between;align-items:end;margin-bottom:34px}.text-link{font-size:14px;font-weight:800;text-decoration:underline;text-underline-offset:5px}.categories{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}.category{background:#e9ebed;border-radius:var(--radius);padding:22px;min-height:245px;position:relative;overflow:hidden}.category:nth-child(2){background:#fbd74f}.category:nth-child(3){background:#c9eaf4}.category:nth-child(4){background:#e3d4fc}.category h3{font-size:19px;letter-spacing:-.04em;margin:0;position:relative;z-index:1}.category p{font-size:13px;margin:4px 0;color:rgba(0,0,0,.55);position:relative;z-index:1}.category-icon{position:absolute;right:-6px;bottom:-8px;font-size:116px;line-height:1;filter:drop-shadow(0 15px 12px rgba(0,0,0,.18));transform:rotate(-13deg)}.products{display:grid;grid-template-columns:repeat(4,1fr);gap:18px}.product{background:#fff;border:1px solid var(--line);border-radius:18px;overflow:hidden;transition:.2s}.product:hover{transform:translateY(-5px);box-shadow:var(--shadow)}.product-image{height:207px;display:grid;place-items:center;position:relative;overflow:hidden;background:#eef0f1;font-size:94px}.product:nth-child(2) .product-image{background:#252a31}.product:nth-child(3) .product-image{background:#eae3d4}.product:nth-child(4) .product-image{background:#e2eef0}.sale{position:absolute;left:12px;top:12px;background:var(--red);color:white;border-radius:5px;padding:5px 8px;font-size:11px;font-weight:850}.product-info{padding:15px}.rating{color:#f29d24;font-size:12px;letter-spacing:1px}.product h3{font-size:15px;letter-spacing:-.02em;margin:7px 0 5px}.price{font-weight:900;font-size:15px}.price del{font-size:12px;color:var(--muted);font-weight:600;margin-left:5px}.vehicle-finder{background:var(--lime);border-radius:30px;padding:51px 55px;display:grid;grid-template-columns:1fr 1.1fr;gap:50px;align-items:center}.vehicle-finder h2{font-size:43px;line-height:.96;letter-spacing:-.06em;margin:11px 0}.vehicle-finder p{font-size:15px;max-width:400px}.finder-form{background:#fff;padding:15px;border-radius:16px;display:grid;grid-template-columns:1fr 1fr auto;gap:8px;box-shadow:0 14px 25px rgba(39,60,0,.12)}.finder-form select{border:1px solid #ddd;border-radius:8px;background:#fff;padding:0 11px;font:inherit;font-size:13px;min-width:0}.finder-form button{border:0;border-radius:8px;background:var(--ink);color:#fff;padding:13px 18px;font-weight:800;cursor:pointer}.why-grid{display:grid;grid-template-columns:1.4fr 1fr 1fr;gap:18px}.story{background:var(--ink);color:white;border-radius:var(--radius);padding:38px;min-height:300px;position:relative;overflow:hidden}.story h2{font-size:38px;line-height:1;letter-spacing:-.055em;max-width:340px;margin:10px 0}.story p{color:#a9afb9;max-width:320px;font-size:14px}.story:after{content:"✦";font-size:250px;color:var(--red);position:absolute;right:-35px;bottom:-100px;opacity:.8}.benefit{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:30px}.benefit .icon{font-size:34px}.benefit h3{font-size:20px;letter-spacing:-.04em;margin:28px 0 7px}.benefit p{font-size:14px;color:var(--muted);margin:0}.newsletter{padding:75px 0;background:#eceeeb}.newsletter .wrap{display:flex;justify-content:space-between;align-items:center;gap:30px}.newsletter h2{font-size:39px;line-height:1;letter-spacing:-.055em;margin:0}.newsletter p{margin:8px 0 0;color:var(--muted)}.email-form{display:flex;background:#fff;border:1px solid #ddd;border-radius:10px;padding:5px;min-width:390px}.email-form input{border:0;outline:0;flex:1;padding:0 12px;font:inherit;font-size:14px}.email-form button{border:0;background:var(--red);color:white;border-radius:7px;padding:13px 17px;font-weight:800;cursor:pointer}.site-footer{background:var(--ink);color:#fff;padding:57px 0 25px}.footer-grid{display:grid;grid-template-columns:1.5fr repeat(3,1fr);gap:40px}.footer-grid p{color:#9aa1aa;font-size:14px;max-width:270px}.footer-grid h4{font-size:13px;text-transform:uppercase;letter-spacing:.1em;color:#8c949f}.footer-grid a{display:block;color:#d5d8dc;font-size:14px;margin:10px 0}.footer-bottom{border-top:1px solid #30343b;margin-top:45px;padding-top:20px;color:#8c949f;font-size:12px;display:flex;justify-content:space-between}.customize-partial-edit-shortcut button{background:var(--red)!important}
@media(max-width:800px){.main-nav{display:none}.topline span:last-child{display:none}.head-actions .search-btn{display:none}.hero{padding:20px 0 42px}.hero-card{padding:42px 28px;display:block;min-height:600px}.hero-art{height:230px}.car{transform:scale(.68) skewX(-8deg);transform-origin:right top;top:60px;right:-55px}.trust{grid-template-columns:1fr}.trust div{padding:13px 18px}.categories,.products{grid-template-columns:repeat(2,1fr)}.vehicle-finder,.why-grid{grid-template-columns:1fr}.finder-form{grid-template-columns:1fr}.newsletter .wrap,.footer-grid{grid-template-columns:1fr;display:grid}.email-form{min-width:0;width:100%}.section{padding:55px 0}.section-top{align-items:start;gap:15px}.section-title{font-size:37px}.footer-grid{gap:20px}}
@media(max-width:460px){.wrap{width:min(100% - 28px,1180px)}.head-actions{gap:7px}.brand{font-size:21px}.cart-pill{padding:8px 10px}.categories,.products{grid-template-columns:1fr}.hero h1{font-size:46px}.button.alt{display:none}.vehicle-finder{padding:35px 26px}.vehicle-finder h2{font-size:35px}}
.category-hero-icon{position:absolute;right:10px;top:58px;font-size:230px;line-height:1;filter:drop-shadow(0 25px 22px rgba(0,0,0,.35));transform:rotate(-12deg)}.category-note{margin-top:22px;color:var(--muted);font-size:14px}.contact-grid{display:grid;grid-template-columns:1fr 1fr;gap:70px;margin-top:42px;max-width:940px}.contact-lead{font-size:19px;line-height:1.5;margin:0 0 28px}.contact-card{display:grid;gap:4px;border-top:1px solid var(--line);padding:17px 0}.contact-card b{font-size:13px;text-transform:uppercase;letter-spacing:.08em}.contact-card a,.contact-card span{color:var(--muted)}.contact-form{background:#fff;border:1px solid var(--line);border-radius:18px;padding:25px;display:grid;gap:16px}.contact-form label{font-size:13px;font-weight:800;display:grid;gap:7px}.contact-form input,.contact-form textarea{font:inherit;border:1px solid #d9dbdd;border-radius:8px;padding:12px;resize:vertical}.contact-form .button{border:0;justify-content:center;cursor:pointer}@media(max-width:800px){.contact-grid{grid-template-columns:1fr;gap:30px}.category-hero-icon{font-size:175px;right:0;top:25px}}
.directory-intro{color:var(--muted);font-size:18px;margin:15px 0 38px}.directory-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}.directory-card{background:#fff;border:1px solid var(--line);border-radius:18px;padding:25px}.directory-icon{font-size:42px}.directory-card h2{font-size:25px;letter-spacing:-.045em;margin:10px 0 15px}.directory-card ul{list-style:none;margin:0;padding:0;border-top:1px solid var(--line)}.directory-card li{border-bottom:1px solid var(--line)}.directory-card li a{padding:11px 0;display:flex;justify-content:space-between;font-size:14px;font-weight:650}.directory-card li a:hover{color:var(--red)}.directory-card li span{color:var(--red)}@media(max-width:800px){.directory-grid{grid-template-columns:repeat(2,1fr)}}@media(max-width:460px){.directory-grid{grid-template-columns:1fr}}
