/* Base Styles and Variables */
:root {
    --primary-color: #3498db;
    --secondary-color: #2980b9;
    --text-color: #333;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --header-bg: #ffffff;
    --footer-bg: #f1f1f1;
    --hover-color: #e8f4fc;
    --border-color: #e0e0e0;
    --future-bg: #f5f5f5;
    --future-text: #888;
    --transition: all 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #4fa3e0;
    --secondary-color: #3498db;
    --text-color: #f0f0f0;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --header-bg: #1a1a1a;
    --footer-bg: #1a1a1a;
    --hover-color: #2c3e50;
    --border-color: #333;
    --future-bg: #252525;
    --future-text: #aaa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: var(--transition);
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Header Styles */
header {
    background-color: var(--header-bg);
    padding: 1.5rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    transition: var(--transition);
}

header .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 2.2rem;
}

.subtitle {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

/* Theme Toggle Switch */
.theme-toggle {
    display: flex;
    align-items: center;
    margin-top: 1rem;
}

.light-icon, .dark-icon {
    margin: 0 10px;
    color: var(--text-color);
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(30px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Main Content Styles */
main {
    padding: 2rem 0;
}

/* Styles for Calculator Forms and Results */
.calculator-form {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--card-shadow);
}

/* Styles for the grid of tools on the index page */
.tools-grid {
    display: grid;
    /* Adjusted minmax to allow more columns */
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* Reduced from 250px */
    gap: 20px;
    margin-top: 30px;
}

.tool-card {
    background-color: var(--card-bg);
    border-radius: 8px;
    /* Slightly reduced padding */
    padding: 12px; /* Reduced from 15px */
    transition: transform 0.3s, box-shadow 0.3s;
    text-decoration: none;
    color: var(--text-color);
    box-shadow: var(--card-shadow);
    display: flex; /* Use flexbox for internal layout */
    flex-direction: column; /* Stack icon, title, and description */
    align-items: center; /* Center content horizontally */
    text-align: center; /* Center text */
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.tool-icon {
    /* Slightly reduced icon size */
    font-size: 1.6rem; /* Reduced from 1.8rem */
    color: var(--primary-color);
    margin-bottom: 8px; /* Adjusted margin */
}

.tool-card h3 {
    margin: 4px 0; /* Adjusted margin */
    font-size: 1rem; /* Slightly reduced font size */
}

.tool-card p {
    /* Increased font size slightly */
    font-size: 0.9rem; /* Increased from 0.8rem */
    color: var(--text-secondary);
    flex-grow: 1; /* Allow description to take available space */
}

/* Add or adjust styles for text-secondary if not already present */
body:not([data-theme="dark"]) .tool-card p {
    color: #666; /* Example light mode secondary text color */
}

[data-theme="dark"] .tool-card p {
    color: #bdc3c7; /* Example dark mode secondary text color */
}

.tool-card.future {
    background-color: var(--future-bg);
    color: var(--future-text);
}

.tool-card.future .tool-icon {
    color: var(--future-text);
}

/* Footer Styles */
footer {
    background-color: var(--footer-bg);
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    transition: var(--transition);
}

footer .container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.disclaimer, .credit, .social-share {
    text-align: center;
}

.disclaimer h3, .social-share h3 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.disclaimer p {
    font-size: 0.85rem;
}

.credit p {
    font-style: italic;
}

.social-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    text-decoration: none;
    transition: var(--transition);
}

.social-btn:hover {
    transform: scale(1.1);
}

.linkedin {
    background-color: #0077b5;
}

.facebook {
    background-color: #3b5998;
}

.twitter {
    background-color: #1da1f2;
}

.whatsapp {
    background-color: #25d366;
}

.reddit {
    background-color: #ff4500;
}

/* Tool Page Template Styles */
.tool-container {
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    margin: 2rem 0;
}

.tool-container h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.back-button {
    display: inline-block;
    margin-bottom: 1rem;
    color: var(--primary-color);
    text-decoration: none;
}

.back-button i {
    margin-right: 0.5rem;
}

/* Responsive Styles */
@media (min-width: 768px) {
    header .container {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .theme-toggle {
        margin-top: 0;
    }
    
    footer .container {
        grid-template-columns: 1fr 1fr 1fr;
        text-align: left;
    }
    
    .social-buttons {
        justify-content: flex-start;
    }
    
    .credit {
        text-align: center;
    }
    
    .social-share {
        text-align: right;
    }
    
    .social-buttons {
        justify-content: flex-end;
    }
}

@media (max-width: 767px) {
    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .tools-grid {
        grid-template-columns: 1fr;
    }
}

.intro-section {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    box-shadow: var(--card-shadow);
}

.intro-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.intro-section p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.intro-section ul {
    margin: 15px 0;
    padding-left: 20px;
}

.intro-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Dark Theme Styles */
body.dark-theme {
    background-color: #1a1a1a; /* Dark background */
    color: #e0e0e0; /* Light text color */
}

body.dark-theme header {
    background-color: #2a2a2a;
    border-bottom: 1px solid #444;
}

body.dark-theme h1,
body.dark-theme h2,
body.dark-theme h3,
body.dark-theme p,
body.dark-theme li {
    color: #e0e0e0;
}

body.dark-theme .subtitle {
    color: #bbb;
}

body.dark-theme .container {
    background-color: #1a1a1a;
}

body.dark-theme .intro-section {
    background-color: #2a2a2a;
    border: 1px solid #444;
}

body.dark-theme .category-section {
    background-color: #2a2a2a;
    border: 1px solid #444;
}

body.dark-theme .tool-card {
    background-color: #333;
    border: 1px solid #555;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

body.dark-theme .tool-card:hover {
    background-color: #444;
    border-color: #777;
}

body.dark-theme .tool-card h3 {
    color: #e0e0e0;
}

body.dark-theme .tool-card p {
    color: #ccc;
}

body.dark-theme .tool-icon {
    color: #88aaff; /* A lighter color for icons in dark mode */
}

body.dark-theme footer {
    background-color: #2a2a2a;
    border-top: 1px solid #444;
    color: #e0e0e0;
}

body.dark-theme .disclaimer h3,
body.dark-theme .social-share h3 {
    color: #e0e0e0;
}

/* Styles for the theme toggle switch itself in dark mode */
body.dark-theme .switch .slider {
    background-color: #555;
}

body.dark-theme .switch input:checked + .slider {
    background-color: #66bb6a; /* Green for checked state */
}

body.dark-theme .switch input:checked + .slider:before {
    background-color: #eee;
}

body.dark-theme .light-icon,
body.dark-theme .dark-icon {
    color: #e0e0e0; /* Adjust icon colors for visibility */
}

body.dark-theme .light-icon {
    color: #888; /* Dim the light icon when dark theme is active */
}

body.dark-theme .dark-icon {
    color: #e0e0e0; /* Highlight the dark icon when dark theme is active */
}

/* Styles for the Back to Home Page button */
.back-to-home-btn {
    display: inline-flex; /* Use flexbox for alignment of icon and text */
    align-items: center;
    gap: 8px; /* Space between icon and text */
    margin-bottom: 20px; /* Space below the button */
    padding: 10px 20px;
    background-color: var(--primary-color); /* Use primary color for background */
    color: #ffffff; /* White text color */
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.back-to-home-btn:hover {
    background-color: var(--secondary-color); /* Darker shade on hover */
    transform: translateY(-2px); /* Slight lift effect */
}

.back-to-home-btn i {
    font-size: 1em; /* Ensure icon size matches text */
}

/* Dark Theme adjustments for the button */
body.dark-theme .back-to-home-btn {
    background-color: #6a9955; /* A distinct color for dark theme */
    color: #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

body.dark-theme .back-to-home-btn:hover {
    background-color: #5a8844; /* Darker shade on hover in dark theme */
}