/* Base styles (Mobile-First) */
body {
    margin: 0;
    padding: 0;
    background-color: #f4f4f4; /* Light background */
    font-size: 16px; /* Base font size for scaling */
    transition: font-size 0.2s ease; /* Smooth transition */
}

.app-container {
    font-family: sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 10px; /* Reduced padding for mobile */
    box-sizing: border-box;
}

.app-header {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #2348a6;
    color: rgb(233, 230, 230);
    padding: 10px 10px; /* Slightly more padding */
    border-radius: 8px 8px 0 0;
}

.app-header h1 {
    font-size: 1.25em; /* 20px -> 1.25em */
    margin: 0;
    text-align: center;
}

/* Header Info Icon */
.app-header .title-wrapper {
    display: flex;
    align-items: center; 
    gap: 10px; 
    flex-wrap: wrap; /* Allow controls to wrap on tiny screens */
    justify-content: center;
}

.info-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4em; /* Slightly larger icon */
    color: #4ac7f2;
    padding: 0;
    margin: 0; 
    transition: color 0.2s;
    flex-shrink: 0; /* Prevents icon from shrinking */
}

.info-icon:hover {
    color: #92e0ff;
}

/* --- NEW FONT CONTROLS --- */
.font-controls {
    display: flex;
    gap: 5px;
}

.font-button {
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em; /* 14.4px */
    font-weight: bold;
    line-height: 1;
    padding: 2px 6px;
    transition: background-color 0.2s;
}

.font-button:hover {
    background-color: #ddd;
}
/* --- END FONT CONTROLS --- */


/* Search Bar */
.search-container {
    display: flex;
    flex-direction: column; /* Stack input and button on mobile */
    margin: 15px 0;
    gap: 10px; /* Spacing between input and button */
}

.search-container input[type="text"] {
    flex-grow: 1;
    width: 100%; /* Full width on mobile */
    padding: 10px;
    border: 1px solid #3c3c3c;
    border-radius: 5px;
    font-size: 1em; /* 16px -> 1em */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

.search-container button {
    width: 100%; /* Full width button on mobile */
    padding: 10px 15px;
    background-color: #bebfc0;
    color: rgb(202, 10, 209);
    border: none;
    border-radius: 5px;
    font-size: 1.125em; /* 18px -> 1.125em */
    cursor: pointer;
    margin-left: 0; /* Remove left margin for stacking */
    font-weight: bold;
    box-sizing: border-box;
}

.search-container button:hover {
    outline: 2px solid rgb(213, 94, 201);
}

/* Navigation Buttons */
.navigation-container {
    display: flex;
    width: 100%;
    gap: 8px; /* Reduced gap */
    margin-top: 12px;
    flex-wrap: nowrap; /* Prevents wrapping */
}

.navigation-container button {
    flex-grow: 1;
    min-width: 100px; /* Ensures buttons don't get too small */
    padding: 10px 5px; /* More vertical padding */
    border: none;
    background-color: #f0f0f0;
    font-size: 0.8125em; /* 13px -> 0.8125em */
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-radius: 12px;
    line-height: 1.2; /* Better text flow */
}

.navigation-container button:hover {
    background-color: hsl(0, 0%, 88%);
    outline: 2px solid rgb(213, 94, 201);
}

.navigation-container button:focus {
    outline: 2px solid rgb(162, 162, 162);
}

.navigation-container button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Results Section */
.results-container {
    margin-top: 20px;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.results-container h2 {
    font-size: 1.375em; /* 22px -> 1.375em */
    margin-bottom: 15px;
    border-bottom: 2px solid #eee;
    padding-bottom: 5px;
}

.meaning-block strong {
    font-size: 1.1em;
    display: block;
    margin: 10px 0 5px 0;
    color: #2348a6;
}

.meaning-block ul {
    list-style-type: disc;
    padding-left: 20px;
    margin-bottom: 15px;
}

.meaning-block li {
    margin-bottom: 5px;
    line-height: 1.4;
}


/* Popups (General) */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Darker overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.popup-content {
    background-color: white;
    padding: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    max-height: 90vh; /* Better fit on smaller screens */
    overflow-y: auto;
    width: 95%; /* Wider on mobile */
    max-width: 450px; /* Reduced max width */
    border-radius: 8px;
    position: relative;
    box-sizing: border-box;
}

.popup h3 {
    margin-bottom: 15px;
    font-size: 1.125em; /* 18px -> 1.125em */
}

.popup ul {
    list-style-type: none;
    padding: 0;
}

.popup li {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
}

.popup li a {
    text-decoration: none;
    color: #2348a6;
    display: block;
}

.popup button.close-button {
    margin-top: 0;
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 5px 10px;
    background-color: #ddd;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875em; /* 14px -> 0.875em */
}

.popup button.close-button:hover {
    background-color: #b8ebc1;
}

/* Info Popup */
.info-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); 
    display: flex; 
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.info-popup {
    background: white;
    padding: 20px; /* Reduced padding */
    border-radius: 8px;
    max-width: 90%; /* Wider on mobile */
    width: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    color: #333;
}

.info-popup h3 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    font-size: 1.2em;
}

.info-popup p {
    margin-bottom: 10px; /* Reduced margin */
    line-height: 1.4;
    font-size: 0.9em;
}

.info-popup button {
    display: block;
    margin-top: 15px;
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    background-color: #6c757d; 
    color: white;
    cursor: pointer;
    float: right; 
    font-size: 0.9em;
}

.info-popup button:hover {
    background-color: #5a6268;
}

/* Grammar Icon/Group */
.gram-group {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}

.grammar-icon {
    background: none;
    border: none;
    color: #007BFF;
    cursor: pointer;
    font-size: 1.1em; /* Adjusted size */
    padding: 0;
    flex-shrink: 0;
}

.grammar-icon:hover {
    color: #0056b3;
}

/* --- Media Query for Larger Screens (Tablets/Desktops) --- */
@media (min-width: 600px) {
    .app-container {
        padding: 20px;
    }
    
    .app-header .title-wrapper {
        flex-wrap: nowrap; /* Un-wrap on larger screens */
    }

    .app-header h1 {
        font-size: 1.5em; /* 24px -> 1.5em */
    }

    /* Search Bar: Horizontal layout on wider screens */
    .search-container {
        flex-direction: row;
        gap: 10px;
    }

    .search-container input[type="text"] {
        width: 70%; /* Back to original proportions */
    }

    .search-container button {
        width: 30%; /* Back to original proportions */
        font-size: 1.25em; /* 20px -> 1.25em */
        margin-left: 0; /* Ensures consistent gap */
    }

    /* Navigation: Horizontal layout on wider screens */
    .navigation-container {
        flex-wrap: nowrap;
        gap: 10px;
    }

    .navigation-container button {
        padding: 8px;
        font-size: 0.875em; /* 14px -> 0.875em */
        min-width: 0;
    }

    /* Popups: Slightly larger max width */
    .popup-content {
        max-width: 500px;
        width: 90%;
    }
}

/* === NEW ICON STYLES FOR SELECTIVE DISPLAY === */

.def-info-icon {
    /* Style for a colorful, distinct icon */
    background: none;
    border: 1px solid #007bff; /* Light blue border */
    border-radius: 50%; /* Makes it circular */
    cursor: pointer;
    font-size: 0.8em; /* Smaller, neat icon */
    color: #007bff; /* Standard blue for "info" */
    margin-left: 8px;
    padding: 1px 3px;
    line-height: 1; 
    vertical-align: middle;
    transition: background-color 0.2s, color 0.2s;
    font-weight: bold;
}

.def-info-icon:hover {
    background-color: #e6f7ff; /* Light blue background on hover */
    color: #0056b3; /* Darker blue text */
}

/* Alignment fix for list items in the Grammar Modal */
#grammar-info-content li {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
    display: flex; /* Aligns the key, value, and icon horizontally */
    align-items: center; /* Vertically center content */
}

#grammar-info-content li strong {
    min-width: 100px; /* Ensures key column has a minimum width for alignment */
    display: inline-block;
    flex-shrink: 0; /* Prevents key from shrinking */
    margin-right: 5px;
}

.def-value {
    flex-grow: 1; /* Allows the value span to take available space */
}

/* --- NEW STYLE FOR SYN/TRANSLATION ICON --- */
.syn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8em; /* Relative to the H2 font size */
    padding-left: 8px; /* Spacing from the text */
    vertical-align: middle;
    transition: opacity 0.2s;
}

.syn-icon:hover {
    opacity: 0.7; /* Simple hover effect */
}

/* --- NEW STYLES FOR PARSED SYN-MODAL CONTENT --- */
#syn-info-content p {
    margin: 0 0 10px 0;
    line-height: 1.4;
}

#syn-info-content p:last-child {
    margin-bottom: 0;
}

#syn-info-content p strong {
    color: #333;
    margin-right: 8px;
}