/* CSS Variables for consistent theming */
:root {
    --primary-color: #4A90E2; /* Blue */
    --secondary-color: #50E3C2; /* Greenish */
    --text-color: #333;
    --background-color: #f4f7f6;
    --card-background: #ffffff;
    --border-color: #ddd;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --success-color: #28a745;
    --error-color: #dc3545;
    --info-color: #007bff;
}

/* Basic Reset and Box Sizing */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Body and Font Styling */
body {
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Global Container for Content Width */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%; /* Ensure it takes full width on small screens */
}

/* Header Styling */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 0;
    box-shadow: 0 2px 5px var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header .container {
    display: flex;
    flex-direction: row; /* Default desktop layout */
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping for ad slot */
}

header h1 {
    margin-bottom: 0; /* No margin on desktop */
    font-weight: 600;
    font-size: 1.8em;
    text-align: left;
}

/* Navigation Styling */
nav {
    width: auto; /* Allow nav to take natural width on desktop */
    text-align: right;
}

.nav-toggle {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 5px 10px;
}

.nav-links {
    list-style: none;
    display: flex; /* Default desktop layout */
    flex-wrap: wrap;
    justify-content: flex-end; /* Align links to the right on desktop */
    gap: 15px;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 1; /* Visible by default on desktop */
    max-height: none; /* No max-height constraint on desktop */
}

.nav-links li a {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    white-space: nowrap;
    font-size: 0.9em;
}

.nav-links li a:hover,
.nav-links li a.active-link {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Dropdown Menu for Tools */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--primary-color);
    min-width: 200px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
    border-radius: 5px;
    padding: 10px 0;
    left: 50%;
    transform: translateX(-50%); /* Center dropdown under button */
}

.dropdown-content a {
    color: white;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    white-space: nowrap;
}

.dropdown-content a:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.dropdown:hover .dropdown-content {
    display: block;
}


/* Main Content Area */
main {
    flex: 1;
    padding: 20px 0;
}

/* Home Page Specific Styling */
.home-content {
    text-align: center;
    padding-top: 40px;
}

.home-content h2 {
    color: var(--primary-color);
    font-size: 2.5em;
    margin-bottom: 20px;
}

.home-content p {
    font-size: 1.1em;
    margin-bottom: 40px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.tool-grid h3 {
    color: var(--text-color);
    font-size: 2em;
    margin-bottom: 30px;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    padding: 0 20px;
}

.grid-item {
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-light);
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grid-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.grid-item .icon {
    font-size: 3em;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.grid-item h4 {
    font-size: 1.3em;
    margin-bottom: 10px;
    font-weight: 600;
}

.grid-item p {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 0; /* Override default p margin */
}


/* Tool Section Styling (for individual tool pages) */
.tool-section {
    background-color: var(--background-color);
    padding: 30px 0;
    /* This section is always active on its own page, so no display: none */
}

.tool-section h2 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--primary-color);
    font-size: 2em;
    font-weight: 600;
}

.tool-section .note {
    font-size: 0.7em;
    color: #888;
    font-weight: normal;
}

/* Tool Card Styling */
.tool-card {
    background-color: var(--card-background);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 10px var(--shadow-light);
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Input and Textarea Styling */
textarea, input[type="text"], input[type="url"], input[type="number"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

textarea:focus, input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    outline: none;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

/* Button Styling */
button {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.1s ease;
    flex-shrink: 0;
}

button:hover {
    background-color: #3a7bd2;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

/* Stats Display (Character Counter) */
.stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 10px;
    margin-top: 15px;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 8px;
}

.stats p {
    font-size: 1em;
    font-weight: 500;
    color: #555;
}

.stats span {
    font-weight: 600;
    color: var(--primary-color);
}

/* Color Picker Specific */
#colorPicker {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    height: 50px;
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

#colorPicker::-webkit-color-swatch-wrapper {
    padding: 0;
}

#colorPicker::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

#colorPicker::-moz-color-swatch-wrapper {
    padding: 0;
}

#colorPicker::-moz-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.color-display {
    width: 100%;
    height: 80px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 15px;
}

/* Password Generator Specific */
.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.input-group label {
    min-width: 120px;
    font-weight: 500;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    transform: scale(1.2);
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Image to Base64 */
#imageInput {
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    background-color: var(--background-color);
}

#base64ImageOutput {
    min-height: 100px;
    word-break: break-all;
}

#imagePreview {
    border: 1px dashed var(--border-color);
    padding: 5px;
    border-radius: 8px;
}

/* QR Code Generator */
#qrcode canvas, #qrcode img {
    max-width: 100% !important;
    height: auto !important;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

/* JSON Formatter */
.json-output {
    background-color: #f8f8f8;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95em;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 15px;
}

/* Status Messages */
.status-message {
    margin-top: 10px;
    font-weight: 500;
}
.status-message.success {
    color: var(--success-color);
}
.status-message.error {
    color: var(--error-color);
}
.status-message.info {
    color: var(--info-color);
}

/* Footer Styling */
footer {
    background-color: #333;
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 30px;
}

/* Custom Message Box */
#messageBox {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--info-color);
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 15px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    max-width: 90%; /* Responsive width */
    text-align: center;
}

#messageBox.show {
    opacity: 1;
    visibility: visible;
}

#messageBox.success {
    background-color: var(--success-color);
}

#messageBox.error {
    background-color: var(--error-color);
}

#messageBox button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

/* Static Page Content Styling */
.static-page-content {
    padding-top: 40px;
}

.static-page-content h2 {
    color: var(--primary-color);
    font-size: 2.2em;
    margin-bottom: 20px;
    text-align: center;
}

.static-page-content h3 {
    color: var(--text-color);
    font-size: 1.5em;
    margin-top: 30px;
    margin-bottom: 15px;
}

.static-page-content p {
    margin-bottom: 15px;
    font-size: 1.05em;
}

.static-page-content a {
    color: var(--primary-color);
    text-decoration: underline;
}

.contact-card {
    margin-top: 30px;
}

/* Ad Slot Styling */
.ad-slot {
    width: 100%;
    max-width: 728px; /* Common leaderboard ad size */
    height: 90px; /* Common leaderboard ad height */
    background-color: #e0e0e0;
    border: 1px dashed #999;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    color: #666;
    margin: 20px auto; /* Center ads and provide spacing */
    text-align: center;
    flex-shrink: 0;
    overflow: hidden; /* Hide overflow if content is too large */
}
.ad-slot.ad-header {
    margin-top: 15px; /* Adjust margin for header ad */
    margin-bottom: 0;
}
.ad-slot.ad-footer {
    margin-top: 0;
    margin-bottom: 15px; /* Adjust margin for footer ad */
}


/* Responsive Design Media Queries */

/* Tablet and Mobile adjustments */
@media (max-width: 768px) {
    header .container {
        flex-direction: row; /* Keep row for header title and toggle */
        justify-content: space-between;
        align-items: center;
    }

    header h1 {
        font-size: 1.5em;
    }

    .nav-toggle {
        display: block; /* Show hamburger icon */
    }

    .nav-links {
        flex-direction: column;
        width: 100%;
        background-color: var(--primary-color);
        position: absolute;
        left: 0;
        top: 65px; /* Adjust based on header height */
        padding: 10px 0;
        box-shadow: 0 2px 5px var(--shadow-light);
        opacity: 0; /* Hidden by default on mobile */
        max-height: 0;
        overflow: hidden;
        pointer-events: none; /* Disable interaction when hidden */
    }

    .nav-links.active {
        opacity: 1;
        max-height: 500px; /* Max height to reveal all links */
        pointer-events: auto; /* Enable interaction when active */
    }

    .nav-links li {
        width: 100%;
        text-align: center;
    }

    .nav-links li a {
        display: block;
        padding: 12px 0;
        border-radius: 0;
    }

    /* Adjust dropdown for mobile */
    .dropdown-content {
        position: static; /* Remove absolute positioning */
        transform: none;
        width: 100%;
        box-shadow: none;
        padding: 0;
        border-radius: 0;
    }

    .dropdown:hover .dropdown-content {
        display: none; /* Hide on hover for mobile, will be toggled by JS if needed */
    }

    /* Home page grid */
    .grid-container {
        grid-template-columns: 1fr; /* Single column on mobile */
        padding: 0 10px;
    }

    .tool-section h2, .static-page-content h2 {
        font-size: 1.7em;
    }

    .tool-card {
        padding: 20px;
        margin: 0 10px;
    }

    .button-group button {
        width: 100%; /* Full width buttons in groups */
    }

    .stats p {
        width: 48%; /* Two columns for stats */
        text-align: center;
    }

    /* Ad slot adjustments for mobile */
    .ad-slot {
        height: 50px; /* Smaller ad height for mobile */
        font-size: 0.9em;
        margin: 15px auto;
    }
}

/* Smaller Mobile adjustments */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.3em;
    }

    .nav-links {
        top: 55px; /* Adjust if header height changes */
    }

    .tool-section h2, .static-page-content h2 {
        font-size: 1.5em;
    }

    .stats p {
        width: 100%; /* Single column for stats on very small screens */
    }

    .ad-slot {
        height: 40px; /* Even smaller ad height for very small mobile */
        font-size: 0.8em;
        margin: 10px auto;
    }
}
