@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;700&display=swap');

:root {
    --primary-color: #0037ff; /* Modern Blue */
    --secondary-color: #f0f4ff; /* Light Blue Background */
    --text-color: #060709;
    --light-text: #576c6e;
    --bg-color: #374fea;
    --box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    --border-radius: 10px;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    /* display: flex; */
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    margin: 0;
    /* min-height: 100vh; */
    color: var(--text-color);
}

.container {
    background-color: #faf9f9;
    padding: 35px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 900px;
}

h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 30px;
    font-weight: 700;
    font-size: 28px;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
}

/* --- Input Area with Clear Button --- */
.input-area {
    position: relative;
    margin-bottom: 30px;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 16px;
    line-height: 1.6;
    box-sizing: border-box;
    resize: vertical;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: inherit;
}

textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(90, 125, 255, 0.15);
    outline: none;
}

#clearBtn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    opacity: 0.9;
    transition: background-color 0.2s, opacity 0.2s, transform 0.2s;
}

#clearBtn:hover {
    background-color: #c0392b;
    opacity: 1;
    transform: scale(1.05);
}


/* --- Main Stats Grid (Modern Layout) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 35px;
    border: 1px solid var(--secondary-color);
    border-radius: var(--border-radius);
    padding: 15px;
}

.stat-box {
    background-color: var(--secondary-color);
    padding: 18px 10px;
    border-radius: 8px;
    text-align: center;
    transition: transform 0.2s;
    cursor: default;
}

.stat-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.stat-box .label {
    font-size: 13px;
    color: var(--light-text);
    display: block;
    font-weight: 400;
    margin-top: 5px;
}

.stat-box .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    line-height: 1;
}

/* Value Update Animation (subtle bounce) */
.stat-box .value.updated {
    animation: bounce-in 0.3s ease-out;
}

@keyframes bounce-in {
    0% { transform: scale(0.9); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

/* --- Character Frequency Section --- */
.frequency-section {
    padding: 20px;
    border-radius: var(--border-radius);
    background-color: #f7f9fb;
    border: 1px solid #e1e8ed;
}

.frequency-section h2 {
    color: var(--text-color);
    font-size: 20px;
    margin-top: 0;
    margin-bottom: 15px;
    font-weight: 600;
}

.frequency-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.frequency-item {
    display: flex;
    align-items: center;
    background-color: var(--primary-color);
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 14px;
    min-width: 60px;
    font-weight: 400;
    transition: background-color 0.2s;
}

.frequency-item .char {
    font-weight: 700;
    margin-right: 5px;
}

.frequency-item .count {
    font-weight: 300;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 1px 5px;
    border-radius: 3px;
}

.no-data {
    color: var(--light-text);
    text-align: center;
    font-style: italic;
    padding: 10px 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr); /* Two columns on tablets */
    }
    #clearBtn {
        top: auto;
        bottom: 20px; 
        right: 20px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr; /* Single column on phones */
    }
    h1 {
        font-size: 22px;
    }
    .stat-box .value {
        font-size: 28px;
    }
}