/* Tool-specific overrides */
textarea {
    min-height: 280px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
}

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

.textarea-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.results-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
}

.results-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}

.stat-card .stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.model-estimates {
    background: var(--dropzone-bg);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.model-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.model-row:last-child {
    border-bottom: none;
}

.model-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

.model-vocab {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.model-tokens {
    text-align: right;
}

.token-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-color);
}

.token-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Collapsible Model Rows */
.model-row.collapsible {
    opacity: 1;
    max-height: 200px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.model-estimates.collapsed .model-row.collapsible {
    opacity: 0;
    max-height: 0;
    padding: 0;
    margin: 0;
    border: none;
}

.model-toggle-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.model-toggle-btn:hover {
    background: rgba(94, 92, 230, 0.05);
}

.model-toggle-chevron {
    transition: transform 0.3s ease;
}

.model-estimates:not(.collapsed) .model-toggle-chevron {
    transform: rotate(180deg);
}

/* Optimization Section */
.optimization-wrapper {
    margin-top: 24px;
    background: var(--card-bg);
    border: 1px solid rgba(94, 92, 230, 0.15);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
}

.optimization-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--accent-color) 0%, #8B5CF6 100%);
    opacity: 0.8;
}

.optimization-wrapper:hover {
    box-shadow: 0 8px 30px rgba(94, 92, 230, 0.12);
    transform: translateY(-2px);
    border-color: rgba(94, 92, 230, 0.3);
}

.opt-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(to right, #ffffff, #fafaff);
    border: none;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.opt-toggle>span {
    display: flex;
    align-items: center;
    gap: 12px;
}

.opt-toggle:hover {
    background: linear-gradient(to right, #f8fafc, #f1f5f9);
}

.opt-text-label {
    background: linear-gradient(90deg, var(--text-main) 0%, var(--text-main) 40%, #818cf8 50%, var(--text-main) 60%, var(--text-main) 100%);
    background-size: 200% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: opt-shimmer 8s linear infinite;
    display: inline-block;
}

@keyframes opt-shimmer {
    0% {
        background-position: 200% center;
    }

    100% {
        background-position: -200% center;
    }
}

.opt-icon-box {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(94, 92, 230, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-radius: 8px;
    color: var(--accent-color);
}

.opt-star {
    font-size: 1.25rem;
    line-height: 1;
    background: linear-gradient(90deg, #8B5CF6, #5E5CE6, #C7B9FF, #8B5CF6);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: star-flow 8s linear infinite;
    display: inline-block;
}

@keyframes star-flow {
    0% {
        background-position: 200% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.opt-chevron {
    transition: transform 0.3s ease;
    color: var(--text-secondary);
}

.opt-toggle[aria-expanded="true"] .opt-chevron {
    transform: rotate(180deg);
}

.opt-content {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease;
}

.opt-inner {
    padding: 16px;
}

.opt-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.opt-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.opt-checkbox:hover {
    border-color: var(--accent-color);
    background: #FAFAFF;
}

.opt-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 0;
}

.opt-checkbox .opt-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.opt-checkbox .opt-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.opt-checkbox .opt-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.optimization-stats {
    background: #E1F8E8;
    border: 1px solid #86EFAC;
    padding: 16px;
    border-radius: 10px;
    margin-top: 16px;
    display: none;
}

.optimization-stats.visible {
    display: block;
}

.stats-comparison {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.stat-item .label {
    font-size: 0.8rem;
    color: #166534;
    font-weight: 600;
}

.stat-item .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #15803D;
}

.stat-arrow {
    font-size: 1.25rem;
    color: #166534;
}

.stat-saved {
    margin-left: auto;
    background: white;
    padding: 6px 12px;
    border-radius: 6px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.stat-saved .label {
    font-size: 0.8rem;
    color: #166534;
    font-weight: 600;
}

.stat-saved .value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #16A34A;
}

/* Context Window */
.context-window {
    margin-top: 16px;
}

.context-window h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 12px;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.model-selector label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.model-selector select {
    width: auto;
    padding: 8px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.context-bar-item {
    margin-bottom: 12px;
}

.context-bar-item:last-child {
    margin-bottom: 0;
}

.context-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.context-bar-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.context-bar-percentage {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.context-bar-track {
    height: 8px;
    background: var(--tag-bg);
    border-radius: 4px;
    overflow: hidden;
}

.context-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color) 0%, #7B79F0 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.context-bar-fill.warning {
    background: linear-gradient(90deg, #F59E0B 0%, #D97706 100%);
}

.context-bar-fill.danger {
    background: linear-gradient(90deg, #EF4444 0%, #DC2626 100%);
}

.context-bar-fill.over {
    background: linear-gradient(90deg, #991B1B 0%, #7F1D1D 100%);
}

/* Tips Section */
.tips-panel {
    background: #FEF3C7;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.tips-panel h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #92400E;
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.tips-panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
    color: #78350F;
    font-size: 0.9rem;
}

.tips-panel li {
    padding: 6px 0 6px 20px;
    position: relative;
}

.tips-panel li::before {
    content: "→";
    position: absolute;
    left: 0;
    font-weight: 700;
}

.tips-content {
    display: none;
}

.tips-content.visible {
    display: block;
}

.tips-toggle {
    transition: transform 0.2s;
}

.tips-toggle.expanded {
    transform: rotate(180deg);
}

/* Download dropdown */
.download-dropdown {
    position: relative;
}

.download-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: var(--shadow-hover);
    min-width: 140px;
    z-index: 100;
    overflow: hidden;
}

.download-menu.show {
    display: block;
}

.download-option {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.15s;
}

.download-option:hover {
    background: var(--bg-color);
    color: var(--accent-color);
}

#downloadBtn svg {
    transition: transform 0.2s ease;
}

#downloadBtn.expanded svg {
    transform: rotate(180deg);
}

/* Dark mode overrides */
@media (prefers-color-scheme: dark) {
    .opt-toggle {
        background: linear-gradient(to right, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    }

    .opt-toggle:hover {
        background: linear-gradient(to right, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.05));
    }

    .opt-checkbox:hover {
        background: rgba(255, 255, 255, 0.05);
    }
}

/* Responsive */
@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .opt-list {
        grid-template-columns: 1fr;
    }

    .textarea-header {
        flex-direction: column;
        align-items: stretch;
    }

    .textarea-actions {
        justify-content: space-between;
    }

    .stats-comparison {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-saved {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }
}

/* Mobile Layout Optimizations */
@media (max-width: 640px) {
    .app-shell {
        padding-left: 0;
        padding-right: 0;
        padding-top: 20px;
    }

    .tool-container {
        padding: 0;
        max-width: 100% !important;
    }

    .card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 20px !important;
    }

    .guide-wrapper {
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-top: 24px;
    }

    .hero-compact {
        margin-bottom: 4px !important;
        padding: 0;
    }

    .hero-compact h1 {
        font-size: 1.75rem;
        margin-bottom: 6px;
        padding: 0 16px;
    }

    .hero-compact p {
        font-size: 0.9rem;
        line-height: 1.4;
        padding: 0 16px;
    }
}