/* Core Variables */
:root {
    --primary-color: #4361ee;
    --secondary-color: #3f37c9;
    --accent-color: #4895ef;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --success-color: #4cc9f0;
    --danger-color: #f72585;
    --border-radius: 8px;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* Dark Theme Variables */
body.dark-theme {
    --light-color: #212529;
    --dark-color: #f8f9fa;
    --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base Body Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
    transition: var(--transition);
}

/* Reusable Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    font-weight: bold;
}

.logo i {
    margin-right: 10px;
    font-size: 1.5rem; /* Icon size remains constant */
}

/* Site Title (h1) adjustment - NEW Adjusted values */
.site-title {
    font-size: 1.4rem; /* Desktop default size (between 1.5rem and 1.3rem) */
    margin: 0; /* Remove default h1 margin */
    white-space: nowrap; /* Keep title on one line if possible */
    overflow: hidden; /* Hide overflow if nowrap causes issues on tiny screens */
    text-overflow: ellipsis; /* Add ellipsis if text overflows */
}


nav ul {
    display: flex;
    list-style: none;
}

nav li {
    margin-left: 1.5rem;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

nav a:hover {
    opacity: 0.8;
}

.mobile-menu-btn {
    display: none; /* Default: hidden on desktop */
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Main Content Styles */
main {
    padding: 2rem 0;
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.hero p {
    font-size: 1.2rem;
    max-width: 700px;
    margin: 0 auto 2rem;
    color: var(--dark-color);
}

.tool-container {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: var(--transition);
}

body.dark-theme .tool-container {
    background: #343a40;
}

/* Text Area */
.text-input-container {
    margin-bottom: 2rem;
}

#text-input {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: var(--transition);
}

body.dark-theme #text-input {
    background-color: #2d3439;
    color: #f8f9fa;
    border-color: #495057;
}

/* Control Buttons */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.option-group {
    display: flex;
    align-items: center;
}

.option-group label {
    margin-left: 0.5rem;
    cursor: pointer;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #f1f3f5;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

body.dark-theme .stat-card {
    background: #2d3439;
}

.stat-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: #6c757d;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* Character Distribution */
.distribution-container {
    margin-top: 2rem;
}

.distribution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.distribution-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: #f1f3f5;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

body.dark-theme .distribution-card {
    background: #2d3439;
}

.distribution-card .label {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.distribution-card .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color);
}

/* Keyword Counter */
.keyword-counter {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #dee2e6;
}

body.dark-theme .keyword-counter {
    border-top: 1px solid #495057;
}

.keyword-counter input {
    flex-grow: 1;
    min-width: 200px;
    padding: 0.7rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1rem;
}

body.dark-theme .keyword-counter input {
    background-color: #2d3439;
    color: #f8f9fa;
    border-color: #495057;
}

/* Theme Toggle */
#themeToggle {
    background: none;
    border: none;
    color: white; /* Changed to white for better contrast on primary-color header */
    font-size: 1.3rem;
    cursor: pointer;
    transition: var(--transition);
}

body.dark-theme #themeToggle {
    color: var(--light-color); /* Light color in dark mode */
}

/* Ad Container */
.ad-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    min-height: 100px; /* Minimum height for ad slot */
    background: #f8f9fa;
    border-radius: var(--border-radius);
    padding: 1rem;
}

body.dark-theme .ad-container {
    background: #2d3439;
}

.ad-placeholder-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 15px auto;
    box-sizing: border-box;
    max-width: 970px; /* Maximum width for standard ad units */
}

.ad-placeholder-label {
    color: #777;
    font-size: 0.9rem;
    margin-bottom: 5px;
    text-align: center;
    width: 100%;
}

.ad-placeholder-box {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f0f0f0;
    border: 1px dashed #ccc;
    color: #666;
    text-align: center;
    padding: 20px;
    width: 100%;
    min-height: 90px; /* Standard ad unit height */
    box-sizing: border-box;
    border-radius: var(--border-radius);
    overflow: hidden;
    position: relative;
}

.ad-placeholder-box ins.adsbygoogle {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 50px; /* Minimum height for responsive ads */
}

.ad-placeholder-box img,
.ad-placeholder-box iframe {
    max-width: 100% !important;
    height: auto !important;
    display: block;
}

/* FAQ Section */
.faq-section {
    margin: 3rem 0;
}

.faq-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

.faq-item {
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: var(--transition);
}

body.dark-theme .faq-item {
    border-color: #495057;
}

.faq-question {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

body.dark-theme .faq-question {
    background: #2d3439;
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    padding: 0 1.5rem;
    background: white;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

body.dark-theme .faq-answer {
    background: #343a40;
}

.faq-item.active .faq-answer {
    max-height: 1000px; /* Increased max-height to ensure content fits */
    padding: 1rem 1.5rem 2rem;
}

/* Footer */
footer {
    background: var(--dark-color);
    color: white;
    padding: 3rem 0 2rem;
}

body.dark-theme footer {
    background: #121416;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-column h3 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.footer-column h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 3px;
    background: var(--accent-color);
}

.footer-column ul {
    list-style: none;
}

.footer-column li {
    margin-bottom: 0.7rem;
}

.footer-column a {
    color: #adb5bd;
    text-decoration: none;
    transition: var(--transition);
}

.footer-column a:hover {
    color: white;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #495057;
    color: #adb5bd;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block; /* Show hamburger icon on mobile */
    }

    /* Adjust site title for smaller screens */
    .site-title {
        font-size: 1.2rem; /* Updated: Medium size for tablets and larger phones */
    }

    nav ul {
        display: none; /* Hide menu by default on mobile */
        position: absolute;
        top: 100%; /* Position below header */
        left: 0;
        right: 0;
        background: var(--primary-color);
        flex-direction: column;
        padding: 1rem 0;
        box-shadow: var(--box-shadow); /* Add shadow to menu when open */
    }

    nav ul.active {
        display: flex; /* Show menu when active class is added by JS */
    }

    nav li {
        margin: 0.7rem 0;
        text-align: center;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Adjusted for smaller screens */
    }
    
    .distribution-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .keyword-counter {
        flex-direction: column;
        align-items: stretch;
    }

    /* Ad Placeholder specific responsive adjustments for mobile */
    .ad-placeholder-container {
        max-width: 320px !important; /* Standard mobile banner width */
        margin: 5px auto !important;
    }
    .ad-placeholder-box {
        min-height: 50px;
        padding: 10px;
        font-size: 0.8rem;
    }
    .ad-placeholder-label {
        font-size: 0.8rem;
    }
    .ad-placeholder-box ins.adsbygoogle {
        min-height: 50px; /* Adjust min-height for mobile ads */
    }
}

@media (max-width: 480px) {
    /* Further adjust site title for very small screens */
    .site-title {
        font-size: 1rem; /* Updated: Medium size for very small phones */
    }
    .stats-grid {
        grid-template-columns: 1fr; /* Stack stats on very small screens */
    }
    .distribution-grid {
        grid-template-columns: 1fr; /* Stack distribution cards on very small screens */
    }
}