/* ========= BASE STYLES ========= */
:root {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-card-soft: #f8fafc;
    --text-main: #1e293b;
    --text-sub: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-soft: rgba(59, 130, 246, 0.1);
    --danger: #ef4444;
    --success: #10b981;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --bg-card: rgba(30, 41, 59, 0.95);
    --bg-card-soft: #334155;
    --text-main: #f1f5f9;
    --text-sub: #94a3b8;
    --accent: #60a5fa;
    --accent-hover: #93c5fd;
    --accent-soft: rgba(96, 165, 250, 0.15);
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg-gradient);
    background-attachment: fixed; /* Parallax-like fixed background */
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    transition: color 0.3s ease;
}

/* ========= ANIMATIONS ========= */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.number-pulse {
    animation: pulse 0.2s ease-in-out;
    color: var(--accent);
}

/* ========= LAYOUT ========= */
.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.app-title-block h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(to right, var(--accent), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.app-subtitle {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--text-sub);
}

/* Dark mode toggle */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: 999px;
    box-shadow: var(--shadow-soft);
}

.toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 6px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 999px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--accent);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* ========= CARDS ========= */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 24px;
    border: 1px solid rgba(255,255,255,0.5);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i {
    color: var(--accent);
}

.badge {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========= CONTROLS & TOOLBAR ========= */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px dashed rgba(0,0,0,0.1);
}

.controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    background: var(--bg-card-soft);
    padding: 12px;
    border-radius: var(--radius-md);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-sub);
}

.control-group strong {
    font-weight: 600;
    color: var(--text-main);
}

.control-group input[type="number"] {
    width: 70px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.control-group input[type="number"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Buttons */
.btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    background: var(--bg-card-soft);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    font-family: inherit;
}

.btn i {
    font-size: 14px;
    color: var(--text-sub);
    transition: var(--transition);
}

.btn:hover {
    background: white;
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.btn:hover i {
    color: var(--accent);
}

.btn:active {
    transform: translateY(0);
}

/* Button Variants */
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-hover);
    color: white;
}
.btn-primary i { color: white; }

/* ========= EDITOR ========= */
.editor-wrapper {
    position: relative;
}

textarea {
    width: 100%;
    min-height: 280px;
    resize: vertical;
    padding: 20px;
    padding-bottom: 40px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    font-size: 16px;
    line-height: 1.6;
    background: var(--bg-card-soft);
    color: var(--text-main);
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
}

textarea:focus {
    background: var(--bg-card);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

textarea::placeholder {
    color: #94a3b8;
}

textarea.over-limit {
    border-color: var(--danger);
    background: #fff5f5;
}
body.dark textarea.over-limit {
    background: #451a1a;
}

.limit-warning {
    margin-top: 8px;
    color: var(--danger);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: fadeIn 0.3s;
}

.editor-footer {
    position: absolute;
    right: 16px;
    bottom: 12px;
    font-size: 12px;
    color: var(--text-sub);
    background: rgba(255,255,255,0.8);
    padding: 2px 8px;
    border-radius: 4px;
    pointer-events: none;
}
body.dark .editor-footer {
    background: rgba(0,0,0,0.3);
}

/* ========= STATS GRID ========= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.stat-card {
    background: linear-gradient(145deg, var(--bg-card), var(--bg-card-soft));
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid rgba(0,0,0,0.03);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

/* Decorative icon in background of stat card */
.stat-card::after {
    content: '';
    position: absolute;
    right: -10px;
    top: -10px;
    font-family: 'bootstrap-icons';
    font-size: 60px;
    opacity: 0.05;
    color: var(--text-main);
    transform: rotate(15deg);
    pointer-events: none;
}
/* Specific icons for cards */
.stat-card:nth-child(1)::after { content: '\F639'; } /* Word - type */
.stat-card:nth-child(2)::after { content: '\F52C'; } /* Char - text-left */
.stat-card:nth-child(3)::after { content: '\F47C'; } /* Sentence - list */
.stat-card:nth-child(4)::after { content: '\F4EB'; } /* Para - paragraph */
.stat-card:nth-child(5)::after { content: '\F290'; } /* Time - clock */

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-sub);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.stat-footnote {
    font-size: 11px;
    margin-top: 8px;
    color: var(--text-sub);
    opacity: 0.8;
}

/* ========= PROGRESS & TABLES ========= */
.progress-container {
    margin-top: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 6px;
}

.progress-track {
    height: 8px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}
body.dark .progress-track { background: #334155; }

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: 999px;
    width: 0%;
    transition: width 0.5s ease;
}

/* Keyword Table */
.keyword-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.keyword-table th {
    text-align: left;
    padding: 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-sub);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.keyword-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    color: var(--text-main);
}

.keyword-chip {
    display: inline-block;
    padding: 2px 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    font-weight: 500;
    font-size: 12px;
}

/* Suggestions List */
.suggestions-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.suggestions-list li {
    position: relative;
    padding: 12px 12px 12px 34px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 14px;
    color: var(--text-sub);
    transition: var(--transition);
}

.suggestions-list li:hover {
    background: var(--bg-card-soft);
    color: var(--text-main);
}

.suggestions-list li::before {
    content: '\F4CF'; /* lightbulb */
    font-family: 'bootstrap-icons';
    position: absolute;
    left: 8px;
    top: 12px;
    color: #f59e0b;
}

.suggestions-list li:last-child {
    border-bottom: none;
}

/* ========= HOW TO USE SECTION ========= */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-top: 16px;
}

.info-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.info-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-card-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 20px;
}

.info-content h3 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
}

.info-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 640px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .toolbar {
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 10px;
    }
    .stat-value {
        font-size: 24px;
    }
}