/* Critical styles to prevent layout flash - modified to work with responsive design */
@media screen and (min-width: 921px) {
    /* Only apply these styles on larger screens */
    .special-chars-tabs {
        display: flex !important;
        flex-direction: column !important;
        width: 220px !important;
    }
}

.special-chars-tab {
    text-align: left !important;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: #f9f9f9;
    margin: 0;
    padding: 0;
}

.special-chars-container {
    width: 900px;
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
}

/* Recently used section - at the top */
.recently-used {
    width: 880px;
    height: 40px;
    display: flex;
    align-items: center;
    margin: 10px 10px 0 10px;
    padding: 15px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    justify-content: space-between;
    max-width: calc(100% - 20px);
    box-sizing: border-box;
    order: 1;
    flex-basis: 100%;
}

.recently-used-chars {
    display: flex;
    flex-wrap: wrap;
    margin-left: 15px;
}

.clear-recent {
    background-color: #e0e0e0;
    border: none;
    border-radius: 4px;
    padding: 8px 15px;
    cursor: pointer;
    margin-left: auto;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.clear-recent:hover {
    background-color: #d0d0d0;
}

/* Main container for tabs and panel - aligned with Recently Used */
.special-chars-main {
    display: flex;
    width: 880px; /* Match the width of Recently Used */
    margin: 10px;
    box-sizing: border-box;
    order: 2;
}

/* Categories panel */
.special-chars-tabs {
    width: 220px; /* Slightly increased width */
    background-color: #ffffff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    height: auto;
    margin: 0;
}

.special-chars-tab {
    cursor: pointer;
    padding: 10px 8px;
    margin: 3px 0;
    border-radius: 5px;
    background: none;
    border: none;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
}

.special-chars-tab:hover {
    background-color: #f0f0f0;
}

.special-chars-tab.active {
    background-color: #e0e0e0;
    font-weight: 600;
}

.special-chars-content {
    flex: 1;
    margin-left: 10px;
    margin-right: 0;
}

.special-chars-panel {
    display: none;
    width: 650px;
    min-height: 560px; /* Set minimum height to match category panel */
    max-height: 560px; /* Set maximum height to match category panel */
    overflow-y: auto;
    background-color: #ffffff;
    border-radius: 12px;
    padding: 20px 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.special-chars-panel.active {
    display: block;
}

.special-chars-grid {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: flex-start;
    width: 100%;
    /* Add padding to ensure last row of characters is visible */
    padding-bottom: 10px;
}

.special-char-item {
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid #ccc;
    border-radius: 5px;
    margin: 4px;
    position: relative;
    transition: all 0.2s ease;
    background: #f9f9f9;
    flex: 0 0 40px;
}

.special-char-item:hover {
    background-color: #eaf7ff;
    border-color: #2271b1;
    transform: scale(1.05);
}

.special-char {
    font-size: 18px;
    line-height: 1;
    display: inline-block;
    text-align: center;
    white-space: nowrap;
}

.recently-used .special-char-item .special-char {
    font-size: 17px;
}

.special-char-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 1000;
    font-size: 14px;
    margin-bottom: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.special-char-item:hover .special-char-tooltip {
    display: block;
}

/* Make the recently used character items larger to match */
.recently-used .special-char-item {
    width: 38px;
    height: 38px;
}

/* Custom scrollbar styles */
.special-chars-panel::-webkit-scrollbar {
    width: 10px;
}

.special-chars-panel::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 5px;
}

.special-chars-panel::-webkit-scrollbar-track {
    background-color: #f9f9f9;
}

/* Feedback message for copy */
.copy-feedback {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 5px;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    z-index: 1001;
    font-size: 16px;
}

.copy-feedback.show {
    opacity: 1;
}

/* Responsive adjustments */
@media screen and (max-width: 920px) {
    .special-chars-container {
        width: 100%;
        flex-direction: column;
    }
    
    .recently-used {
        width: calc(100% - 20px);
        margin: 10px;
        order: 1;
    }
    
    .special-chars-main {
        flex-direction: column;
        margin: 10px;
        width: calc(100% - 20px);
    }
    
    /* Override the critical styles for small screens with stronger specificity */
    .special-chars-container .special-chars-main .special-chars-tabs {
        width: 100% !important; /* Override with stronger specificity */
        max-width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
        height: 200px;
        max-height: 200px;
        overflow-y: auto;
        margin: 0 0 10px 0 !important;
        padding: 15px !important;
        flex: 0 0 100% !important;
    }
    
    .special-chars-content {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    .special-chars-panel {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        height: auto;
        min-height: auto; /* Remove minimum height restriction */
        max-height: none; /* Remove maximum height restriction to show all content */
        overflow-y: visible; /* Change from auto to visible to disable scrolling */
    }
    
    /* Add scrollbar styles for category tabs on small screens */
    .special-chars-tabs::-webkit-scrollbar {
        width: 8px;
    }
    
    .special-chars-tabs::-webkit-scrollbar-thumb {
        background-color: #ccc;
        border-radius: 5px;
    }
    
    .special-chars-tabs::-webkit-scrollbar-track {
        background-color: #f9f9f9;
    }
}

@media screen and (max-width: 680px) {
    .special-chars-grid {
        justify-content: center;
    }
    
    .special-char-item {
        width: 36px;
        height: 36px;
        flex: 0 0 36px;
    }
    
    .special-char {
        font-size: 16px;
    }
    
    .special-chars-tab {
        font-size: 13px;
        padding: 8px 6px;
    }

    /* Adjust tabs height for medium-small screens */
    .special-chars-tabs {
        height: 180px;
        max-height: 180px;
    }

    /* Ensure panel has no height restrictions on smaller screens */
    .special-chars-panel {
        min-height: auto;
        max-height: none;
        overflow-y: visible;
        width: 100%;
        box-sizing: border-box;
    }
}

@media screen and (max-width: 480px) {
    .special-char-item {
        width: 32px;
        height: 32px;
        flex: 0 0 32px;
        margin: 3px;
    }
    
    .special-char {
        font-size: 15px;
    }
    
    .special-chars-panel {
        padding: 15px 10px;
        min-height: auto; /* Remove any remaining height restrictions */
        width: 100%;
    }
    
    .recently-used {
        padding: 10px;
        height: auto;
    }
    
    .special-chars-tab {
        font-size: 12px;
        padding: 7px 5px;
    }
    
    /* Further reduce tabs height for very small screens */
    .special-chars-tabs {
        height: 150px;
        max-height: 150px;
        width: 100%;
    }
}