#!/bin/bash
CSS_FILE="/var/www/html/IDHI/edital.css"
SRC="/var/www/html/IDHI/index.css"

cat > "$CSS_FILE" << 'CSS_START'
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

p {
    text-align: justify;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}
CSS_START

echo "" >> "$CSS_FILE"
# Extract NAVBAR section
awk '/\/\* ===== NAVBAR ===== \*\//{flag=1} /\/\* ===== HERO ===== \*\//{flag=0; print ""; next} flag' "$SRC" >> "$CSS_FILE"

# Extract FOOTER section
awk '/\/\* ===== FOOTER ===== \*\//{flag=1} /\/\* ===== RESPONSIVE ===== \*\//{flag=0; print ""; next} flag' "$SRC" >> "$CSS_FILE"

# If drop down menu missing
DROPDOWN=$(grep "\.dropdown-menu {" /var/www/html/IDHI/index.css)
if [ -z "$DROPDOWN" ]; then
    awk '/\/\* ===== DROPDOWN MENU ===== \*\//{flag=1} /\/\*/{if(flag && !match($0, /DROPDOWN/)){flag=0}} flag' /var/www/html/IDHI/educacao.css >> "$CSS_FILE"
fi

# Extract RESPONSIVE section for navbar/footer
awk '/\/\* ===== RESPONSIVE ===== \*\//{flag=1} flag' "$SRC" >> "$CSS_FILE"
