/* Basic Resets and Global Styles */
:root {
    --color-background: #FFFFFF;
    --color-text: #333333;
    --color-accent: #10B981;
    --color-footer-bg: #2D3748;
    --color-footer-text: #FFFFFF;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif; /* Primary font */
    color: var(--color-text);
    background-color: var(--color-background);
    line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif; /* Headings font */
    color: var(--color-text);
    margin-bottom: 0.5em;
}

a {
    color: var(--color-text);
    text-decoration: none;
}

a:hover {
    color: var(--color-accent);
}

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

/* Buttons */
.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 12px 25px;
    border-radius: 5px;
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--color-accent);
    color: var(--color-background);
}

.btn-primary:hover {
    background-color: #0e9f6e; /* Slightly darker green */
}

.btn-secondary {
    background-color: var(--color-accent);
    color: var(--color-background);
    font-size: 0.9em;
    padding: 8px 15px;
}

.btn-secondary:hover {
    background-color: #0e9f6e;
}

/* Header */
header {
    background: linear-gradient(90deg, #a1c4fd, #c2e9fb); /* A fresh, attractive gradient */
    padding: 20px 0;
    border-bottom: 1px solid #8ecae6; /* Complementary border */
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8em;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap; /* Ensure logo stays on one line */
}

.logo-methong {
    color: var(--color-accent);
}

header nav ul {
    list-style: none;
    display: flex;
}

header nav ul li {
    margin-left: 30px;
}

header nav ul li a {
    font-weight: 600;
    position: relative;
    padding-bottom: 5px;
}

header nav ul li a.active::after,
header nav ul li a:hover::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: var(--color-accent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

header nav ul li a.active::after {
    transform: scaleX(1);
}

header nav ul li a:hover::after {
    transform: scaleX(1);
}

/* Dropdown Menu */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none; /* Default: hidden */
    position: absolute;
    background-color: var(--color-background);
    min-width: 600px; /* Adjust width for 3 columns */
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 5px;
    padding: 10px;
    left: 50%; /* Start from the middle of the parent */
    transform: translateX(-50%); /* Center horizontally */
    top: 100%; /* Position below the button */
    /* grid-template-columns and gap will be applied when display: grid */
}

.dropdown-content a {
    color: var(--color-text);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    font-weight: 400;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
    color: var(--color-accent);
}

.dropdown:hover .dropdown-content {
    display: grid; /* Show as grid on hover */
    grid-template-columns: repeat(3, 1fr); /* 3 columns */
    gap: 10px; /* Gap between grid items */
}

/* Hamburger Menu for Mobile */
.hamburger-menu {
    display: none; /* Hidden by default on larger screens */
    flex-direction: column;
    cursor: pointer;
    padding: 10px;
}

.hamburger-menu .bar {
    width: 25px;
    height: 3px;
    background-color: var(--color-text);
    margin: 4px 0;
    transition: 0.4s;
}

/* Responsive Navigation */
@media (max-width: 767px) {
    .main-nav {
        display: flex;
        justify-content: flex-end;
        width: 100%;
    }

    .nav-links {
        display: none; /* Hide navigation links by default on small screens */
        flex-direction: column;
        width: 100%;
        background-color: var(--color-background);
        position: absolute;
        top: 70px; /* Adjust based on header height */
        left: 0;
        padding: 20px 0;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    .nav-links.active {
        display: flex; /* Show when active */
    }

    .nav-links li {
        margin: 10px 0;
        text-align: center;
    }

    .hamburger-menu {
        display: flex; /* Show hamburger menu on small screens */
    }

    .header-content {
        flex-direction: row; /* Keep logo and hamburger on one row */
        justify-content: space-between;
        align-items: center;
    }
}

/* Hero Section */
.hero-section {
    background: linear-gradient(270deg, #e0f7fa, #bbdefb, #e0f7fa); /* Subtle gradient */
    background-size: 600% 600%;
    animation: AnimateBackground 15s ease infinite;
    padding: 80px 0;
    text-align: center;
}

@keyframes AnimateBackground {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.hero-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.hero-text {
    max-width: 600px;
}

.hero-text h1 {
    font-size: 3.5em;
    line-height: 1.1;
    margin-bottom: 10px;
}

.hero-text h2 {
    font-size: 2em;
    color: #555;
    margin-bottom: 20px;
}

.hero-text p {
    font-size: 1.1em;
    margin-bottom: 30px;
    color: #666;
}

.hero-icon-container {
    display: flex;
    gap: 30px;
    font-size: 5em;
    color: var(--color-accent);
    justify-content: center;
    align-items: center;
    padding: 20px;
    border-radius: 10px;
    background-color: #f9f9f9;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

.hero-icon {
    transition: transform 0.3s ease;
}

.hero-icon:hover {
    transform: scale(1.1);
}

main {
    background-color: #f8f9fa; /* Fallback color */
    background-image: linear-gradient(to top, #e3eeff 0%, #f3e7e9 99%, #e3eeff 100%);
    background-size: 400% 400%;
    animation: AnimateMainBackground 25s ease infinite;
}

@keyframes AnimateMainBackground {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Tool Sections */
.tools-section {
    padding: 30px 0;
    border-bottom: 1px solid #eee;
}

.tools-section:last-of-type {
    border-bottom: none;
}

.tools-section h2 {
    font-size: 2.2em;
    margin-bottom: 20px;
    text-align: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.section-divider {
    color: var(--color-accent);
    font-size: 1.2em;
    margin-right: 10px;
}

/* Tool Card */
.tool-card {
    background: linear-gradient(135deg, #ffffff, #f0f8ff); /* Light, subtle gradient */
    background-size: 200% 200%;
    animation: AnimateToolCardBackground 10s ease infinite alternate;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 25px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

@keyframes AnimateToolCardBackground {
    0% {
        background-position: 0% 50%;
    }
    100% {
        background-position: 100% 50%;
    }
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.tool-card h3 {
    font-size: 1.2em;
    font-weight: 700;
    margin-bottom: 8px;
}

.tool-icon {
    font-size: 3.5em;
    color: var(--color-accent);
    margin-bottom: 15px;
}

.tool-card p {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 15px;
    flex-grow: 1;
}

/* Tool Grids */
.tool-grid {
    display: grid;
    gap: 20px;
}

.grid-3-col {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid-4-col {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* Footer */
footer {
    background: linear-gradient(90deg, #a1c4fd, #c2e9fb); /* Same as header for consistency */
    color: var(--color-text); /* Changed to black */
    padding: 60px 0 20px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-col .logo {
    margin-bottom: 15px;
}

.footer-col .logo a {
    color: #000000; /* Make 'TOOLS' text black */
}

.footer-col p {
    font-size: 0.9em;
    line-height: 1.8;
    color: var(--color-text); /* Changed to black */
}

.footer-col h4 {
    color: var(--color-text); /* Changed to black */
    font-size: 1.2em;
    margin-bottom: 20px;
}

.footer-col ul {
    list-style: none;
}

.footer-col ul li {
    margin-bottom: 10px;
}

.footer-col ul li a {
    color: var(--color-text); /* Changed to black */
    font-size: 0.95em;
    transition: color 0.3s ease;
}

.footer-col ul li a:hover {
    color: var(--color-accent);
}

.footer-bottom {
    border-top: 1px solid rgba(0, 0, 0, 0.1); /* Adjusted border color */
    padding-top: 20px;
    text-align: center;
}

.footer-bottom p {
    font-size: 0.85em;
    color: var(--color-text); /* Changed to black */
}

/* Responsive Design */
@media (min-width: 768px) {
    .hero-content {
        flex-direction: row; /* Two columns on larger screens */
        text-align: left;
    }

    .hero-text {
        flex: 1;
        padding-right: 40px;
    }

    .hero-image {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .hero-text h1 {
        font-size: 4.5em;
    }

    .hero-text h2 {
        font-size: 2.5em;
    }

    .tools-section h2 {
        justify-content: flex-start; /* Align section titles to left on larger screens */
    }
}

@media (max-width: 767px) {
    .header-content {
        flex-direction: row; /* Keep logo and hamburger on one row */
        justify-content: space-between;
        align-items: center;
    }

    header nav ul {
        margin-top: 0; /* Remove top margin for mobile nav */
        flex-wrap: nowrap; /* Prevent wrapping */
        justify-content: flex-end; /* Align to right */
    }

    header nav ul li {
        margin: 0 10px; /* Adjust margin for mobile nav items */
    }

    .hero-section {
        padding: 50px 0;
    }

    .hero-text h1 {
        font-size: 2.8em;
    }

    .hero-text h2 {
        font-size: 1.6em;
    }

    .hero-image {
        margin-top: 30px;
    }

    .tools-section {
        padding: 20px 0;
    }

    .tools-section h2 {
        font-size: 1.6em;
        margin-bottom: 20px;
    }

    .tool-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Allow flexible columns on mobile */
    }

    .tool-card {
        padding: 10px; /* Smaller padding for mobile */
    }

    .tool-card h3 {
        font-size: 1em; /* Smaller heading font size */
    }

    .tool-card p {
        font-size: 0.75em; /* Smaller paragraph font size */
    }

    .tool-icon {
        font-size: 2.5em; /* Adjust icon size for mobile */
        margin-bottom: 10px;
    }

    .tool-card {
        padding: 10px;
    }

    .tool-card h3 {
        font-size: 1em;
    }

    .tool-card p {
        font-size: 0.75em;
    }

    .tool-icon {
        font-size: 2.5em;
        margin-bottom: 10px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .footer-col ul {
        padding-left: 0;
    }

    /* Mobile specific dropdown adjustments */
    @media (max-width: 767px) {
        .dropdown-content {
            display: none; /* Hide dropdown content on mobile */
        }
    }
}

@media (max-width: 480px) {
    .hero-text h1 {
        font-size: 2.2em;
    }

    .hero-text h2 {
        font-size: 1.4em;
    }

    .btn-primary {
        padding: 10px 20px;
        font-size: 0.9em;
    }

    .tool-card {
        padding: 15px;
    }

    .tool-card h3 {
        font-size: 1.2em;
    }

    .tool-card p {
        font-size: 0.9em;
    }

    .btn-secondary {
        padding: 6px 12px;
        font-size: 0.8em;
    }
}

/* Image preview container */
.image-preview {
  width: 80%;
  max-width: 600px;
  margin: 20px auto;
}

/* Converted result image */
.converted-result {
  width: 90%;
  max-width: 800px;
  height: auto;
  object-fit: contain;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 10px;
}

/* File upload section */
.upload-container {
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* New combined tool container */
.image-tool-container {
    background-color: var(--color-background);
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px; /* Reduced gap for a more compact look */
    align-items: center;
    max-width: 900px; /* Limit width for better aesthetics */
    margin: 0 auto; /* Center the container */
}

.image-tool-container h1 {
    margin-bottom: 10px; /* Reduced margin */
}

.drag-drop-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 30px; /* Reduced padding */
    text-align: center;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.3s ease;
}

.preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* Reduced gap */
    margin-top: 15px; /* Reduced margin */
    justify-content: center;
    width: 100%;
}

.options-section {
    width: 100%;
    margin-top: 15px; /* Reduced margin */
    padding-top: 15px; /* Reduced padding */
    border-top: 1px solid #eee;
    text-align: center;
}

.action-buttons {
    margin-top: 20px; /* Reduced margin */
    display: flex;
    gap: 10px; /* Reduced gap */
    flex-wrap: wrap;
    justify-content: center;
}

.result-box {
    margin-top: 20px; /* Reduced margin */
    padding: 15px; /* Reduced padding */
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 1.1em;
    color: var(--color-text);
    text-align: center;
    width: 100%;
}

.converted-images-section {
    width: 100%;
    margin-top: 20px; /* Reduced margin */
    padding-top: 20px; /* Reduced padding */
    border-top: 1px solid #eee;
    text-align: center;
}

.converted-images-section h2 {
    margin-bottom: 15px; /* Reduced margin */
}

.converted-preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px; /* Reduced gap */
    margin-top: 15px; /* Reduced margin */
    justify-content: center;
    width: 100%;
}

/* Responsive adjustments for tool pages */
@media (max-width: 992px) {
    .tool-content-wrapper {
        flex-direction: column; /* Stack input and output vertically on smaller screens */
    }
    .converter-container.input-section,
    .output-display-area {
        width: 100%; /* Take full width when stacked */
    }
}

@media (max-width: 767px) {
    .tool-page-content {
        padding: 50px 15px;
    }
    .tool-page-content h1 {
        font-size: 2em;
    }
    .converter-container {
        padding: 20px;
    }
    .drag-drop-area {
        padding: 20px;
    }
    .preview-area {
        gap: 10px;
    }
    .image-preview {
        width: 120px; /* Adjusted for mobile */
        height: 120px; /* Adjusted for mobile */
    }
    .action-buttons {
        flex-direction: column;
    }
    .output-display-area {
        padding: 20px;
    }
    .converted-preview-area .image-preview {
        max-width: 300px;
    }
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1001; /* Sit on top */
    padding-top: 50px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.9); /* Black w/ opacity */
}

.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
}

.modal-content, #caption {
    animation-name: zoom;
    animation-duration: 0.6s;
}

@keyframes zoom {
    from {transform: scale(0)}
    to {transform: scale(1)}
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
}

.close-modal:hover,
.close-modal:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

@media only screen and (max-width: 700px){
    .modal-content {
        width: 100%;
    }
}

/* Styles from png-to-jpeg.html */
.tool-page-content {
    padding: 80px 20px;
    max-width: 900px;
    margin: 0 auto;
    min-height: calc(100vh - 200px); /* Adjust based on header/footer height */
}
.tool-page-content h1 {
    text-align: center;
    margin-bottom: 40px;
    font-size: 2.8em;
    color: var(--color-text);
}
.converter-container {
    background-color: var(--color-background);
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}
.drag-drop-area {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.3s ease;
}
.drag-drop-area.highlight {
    border-color: var(--color-accent);
}
.drag-drop-area p {
    margin-top: 10px;
    color: #666;
}
.file-input-btn {
    background-color: var(--color-accent);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    display: inline-block;
    margin-top: 15px;
}
.file-input-btn:hover {
    background-color: #0e9f6e;
}
#fileInput {
    display: none;
}
.preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
    width: 100%;
}
.image-preview {
    position: relative;
    width: 350px; /* Increased size */
    height: 350px; /* Increased size */
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    display: flex;
    flex-direction: column; /* Stack items vertically */
    justify-content: center;
    align-items: center;
    padding: 10px; /* Add some padding */
}
.converted-preview-area {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; /* Increased gap for better spacing */
    margin-top: 30px;
    justify-content: center;
    width: 100%;
}
.image-preview img {
    max-width: 100%;
    max-height: 280px; /* Limit image height within the preview */
    object-fit: contain; /* Ensure image fits without cropping */
    margin-bottom: 10px; /* Space between image and button */
}
.image-preview .btn-primary {
    margin-top: auto; /* Push button to the bottom */
}
.image-preview .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.8em;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}
.options-section {
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-align: center;
}
.options-section label {
    margin-right: 10px;
}
.options-section input[type="number"] {
    width: 80px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
}
.action-buttons {
    margin-top: 30px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}
.result-box {
    margin-top: 30px;
    padding: 20px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 1.1em;
    color: var(--color-text);
    text-align: center;
    width: 100%;
}
@media (max-width: 767px) {
    .tool-page-content {
        padding: 50px 15px;
    }
    .tool-page-content h1 {
        font-size: 2em;
    }
    .converter-container {
        padding: 20px;
    }
    .drag-drop-area {
        padding: 20px;
    }
    .preview-area {
        gap: 10px;
    }
    .image-preview {
        width: 120px; /* Adjusted for mobile */
        height: 120px; /* Adjusted for mobile */
    }
    .action-buttons {
        flex-direction: column;
    }
    .output-display-area {
        padding: 20px;
    }
    .converted-preview-area .image-preview {
        max-width: 300px;
    }
}

/* New CSS for blog post icons */
.blog-post-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px; /* Same height as the original image */
    background-color: #f0f0f0; /* Light background for the icon area */
    font-size: 5em; /* Large icon size */
    color: var(--color-accent); /* Use accent color for icons */
    border-bottom: 1px solid #eee; /* Separator like the image */
}

/* Custom styles for larger image previews and block-level download button */
.image-preview {
    width: 400px !important; /* Even larger size */
    height: 400px !important; /* Even larger size */
    padding: 10px;
}

.image-preview img {
    max-height: 320px !important; /* Adjusted for even larger preview */
}

.image-preview .btn-primary {
    display: block !important; /* Make button take full width */
    width: 100% !important;
    margin-top: 10px !important; /* Add some space above the button */
}

.download-button-block {
    display: block !important;
    margin-top: 15px !important;
    width: 100%;
    text-align: center;
}

/* Larger modal image */
.modal-content {
    max-width: 95% !important;
    width: 95% !important;
}