/* Tool Hero Section - Required by tool-page-structure rules */
.tool-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.hero-text {
    flex: 1;
    min-width: 260px;
}

.hero-text h1 {
    font-size: 40px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-muted);
    max-width: 640px;
    margin-bottom: 1rem;
    margin-top: 0;
}

@media (max-width: 767px) {
    .hero-text h1 {
        font-size: clamp(1.75rem, 5vw, 2.5rem);
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 3vw, 1.125rem);
    }
}

/* Median Calculator Styles */
.median-calculator {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.calculator-card {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    transition: box-shadow 0.3s ease;
}

.calculator-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 767px) {
    .calculator-card {
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    .calculator-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.input-column {
    display: flex;
    flex-direction: column;
}

.results-column {
    display: flex;
    flex-direction: column;
}

/* Input Section */
.input-section {
    margin-bottom: 1.5rem;
}

.input-label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.label-text {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
}

.label-hint {
    font-size: 0.875rem;
    color: #6b7280;
}

.input-wrapper {
    position: relative;
}

.data-input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    line-height: 1.6;
    color: #1a1a1a;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    resize: vertical;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.data-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.data-input::placeholder {
    color: #9ca3af;
}

/* Action Section */
.action-section {
    margin-top: auto;
}

.button-group {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.btn-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 0 0 auto;
    padding: 1rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #6b7280;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear:hover {
    color: #374151;
    border-color: #d1d5db;
    background: #f9fafb;
}

.btn-clear:active {
    transform: scale(0.98);
}

.btn-clear svg {
    flex-shrink: 0;
}

.btn-calculate {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex: 1;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
}

.btn-calculate:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.3);
    transform: translateY(-1px);
}

.btn-calculate:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
}

.btn-calculate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    flex-shrink: 0;
    animation: rotate 2s linear infinite;
    animation-play-state: paused;
}

.btn-calculate:active .btn-icon {
    animation-play-state: running;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    height: 100%;
    animation: fadeIn 0.4s ease;
}

@media (max-width: 767px) {
    .results-section {
        margin-top: 0;
    }
}

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

.result-header {
    margin-bottom: 1.5rem;
}

.result-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0;
}

@media (max-width: 767px) {
    .result-title {
        font-size: 1.25rem;
    }
}

.result-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .result-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .result-grid {
        grid-template-columns: 1fr;
    }
}

.result-card {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s ease;
}

.result-card:hover {
    border-color: #d1d5db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.result-card.primary {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #3b82f6;
}

.result-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.result-card.primary .result-label {
    color: #2563eb;
}

.result-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a1a1a;
}

.result-card.primary .result-value {
    color: #1d4ed8;
    font-size: 2rem;
}

@media (max-width: 767px) {
    .result-value {
        font-size: 1.5rem;
    }
    
    .result-card.primary .result-value {
        font-size: 1.75rem;
    }
}

/* Details Section */
.details-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    overflow-y: auto;
    max-height: 100%;
}

.detail-block {
    background: #f9fafb;
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid #e5e7eb;
}

@media (max-width: 767px) {
    .detail-block {
        padding: 1rem;
    }
}

.detail-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 1rem 0;
}

.sorted-display {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.875rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #1a1a1a;
    word-wrap: break-word;
    overflow-x: auto;
    margin-bottom: 0.75rem;
    max-height: 120px;
    overflow-y: auto;
}

.detail-note {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
    font-style: italic;
}

.steps-display {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step-item {
    padding: 0.875rem;
    background: #ffffff;
    border-left: 4px solid #3b82f6;
    border-radius: 6px;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #374151;
}

.step-item strong {
    color: #1a1a1a;
    font-weight: 600;
}

/* Mobile Optimizations */
@media (max-width: 767px) {
    .input-section {
        margin-bottom: 1.25rem;
    }
    
    .data-input {
        font-size: 0.9375rem;
        padding: 0.875rem;
    }
    
    .button-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-clear,
    .btn-calculate {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 0.9375rem;
    }
    
    .btn-calculate {
        flex: 1;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.btn-calculate:focus-visible,
.btn-clear:focus-visible,
.data-input:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
