/* ============================================
   STATS CALCULATOR PRO - CALCULATOR STYLES
   Version: 1.0.0
   For Plain PHP/HTML Implementation
   ============================================ */

/* ============================================
   CALCULATOR PAGE LAYOUT
   ============================================ */

.calculator-page {
    max-width: 900px;
    margin: 0 auto;
}

.calculator-intro {
    background: white;
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.calculator-intro h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 1rem;
}

.calculator-intro p {
    font-size: 1.1rem;
    color: var(--gray-600);
    line-height: 1.7;
    margin-bottom: 0;
}

.calculator-breadcrumb {
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.calculator-breadcrumb a {
    color: var(--primary-blue);
    text-decoration: none;
}

.calculator-breadcrumb a:hover {
    text-decoration: underline;
}

.calculator-breadcrumb span {
    color: var(--gray-500);
    margin: 0 0.5rem;
}

/* ============================================
   CALCULATOR WRAPPER & CARD
   ============================================ */

.stats-calculator-wrapper {
    max-width: 850px;
    margin: 2rem auto;
    font-family: var(--font-sans);
    line-height: 1.6;
}

.stats-calculator-wrapper * {
    box-sizing: border-box;
}

.stats-calc-card {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.3s;
}

.stats-calc-card:hover {
    box-shadow: var(--shadow-lg);
}

/* ============================================
   CALCULATOR HEADER
   ============================================ */

.stats-calc-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gray-100);
}

.stats-calc-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-calc-title-icon {
    font-size: 2rem;
}

.stats-calc-description {
    color: var(--gray-600);
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
}

.stats-calc-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--primary-blue);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    margin-top: 0.5rem;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

.stats-form-group {
    margin-bottom: 1.5rem;
}

.stats-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stats-label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.stats-label-required::after {
    content: ' *';
    color: var(--danger-red);
}

.stats-label-description {
    display: block;
    font-weight: 400;
    color: var(--gray-500);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.stats-input,
.stats-textarea,
.stats-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    transition: all 0.2s;
    background: white;
}

.stats-input:focus,
.stats-textarea:focus,
.stats-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.stats-input:disabled,
.stats-textarea:disabled,
.stats-select:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
    opacity: 0.6;
}

.stats-input[type="number"] {
    font-family: var(--font-mono);
}

.stats-textarea {
    min-height: 120px;
    font-family: var(--font-mono);
    resize: vertical;
    line-height: 1.5;
}

.stats-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234b5563' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.stats-input-hint {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    line-height: 1.4;
}

.stats-input-hint-success {
    color: var(--success-green);
}

.stats-input-hint-warning {
    color: var(--warning-orange);
}

.stats-input-hint-error {
    color: var(--danger-red);
}

/* Input with icon */
.stats-input-group {
    position: relative;
}

.stats-input-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    pointer-events: none;
}

.stats-input-group .stats-input {
    padding-left: 2.5rem;
}

/* Checkbox and Radio */
.stats-checkbox-group,
.stats-radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stats-checkbox-label,
.stats-radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 400;
}

.stats-checkbox,
.stats-radio {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ============================================
   BUTTONS
   ============================================ */

.stats-button-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.stats-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
}

.stats-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.stats-btn-primary {
    background: var(--primary-blue);
    color: white;
    flex: 1;
    min-width: 150px;
}

.stats-btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.stats-btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.stats-btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.stats-btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
}

.stats-btn-success {
    background: var(--success-green);
    color: white;
}

.stats-btn-success:hover:not(:disabled) {
    background: #059669;
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.stats-btn-danger {
    background: var(--danger-red);
    color: white;
}

.stats-btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.stats-btn-outline {
    background: transparent;
    border: 2px solid var(--primary-blue);
    color: var(--primary-blue);
}

.stats-btn-outline:hover:not(:disabled) {
    background: var(--primary-blue);
    color: white;
}

.stats-btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.stats-btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.stats-btn-icon {
    font-size: 1.1rem;
}

/* ============================================
   ALERTS & MESSAGES
   ============================================ */

.stats-alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.stats-alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stats-alert-info {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    color: #1e40af;
}

.stats-alert-success {
    background: #d1fae5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.stats-alert-warning {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.stats-alert-error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.stats-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
    font-size: 0.9rem;
    display: none;
}

.stats-error.active {
    display: block;
    animation: shake 0.4s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ============================================
   RESULTS SECTION
   ============================================ */

.stats-results {
    margin-top: 2rem;
    display: none;
}

.stats-results.active {
    display: block;
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats-results-header {
    background: linear-gradient(135deg, var(--success-green) 0%, #059669 100%);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    font-weight: 600;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-results-header-icon {
    font-size: 1.5rem;
}

.stats-results-body {
    border: 1px solid var(--gray-200);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    padding: 1.5rem;
    background: var(--gray-50);
}

.stats-results-section {
    margin-bottom: 2rem;
}

.stats-results-section:last-child {
    margin-bottom: 0;
}

.stats-results-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-result-item {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-blue);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stats-result-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stats-result-item.highlight {
    border-left-color: var(--success-green);
    background: #f0fdf4;
}

.stats-result-item.warning {
    border-left-color: var(--warning-orange);
    background: #fffbeb;
}

.stats-result-item.danger {
    border-left-color: var(--danger-red);
    background: #fef2f2;
}

.stats-result-label {
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stats-result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1.2;
}

.stats-result-value-sm {
    font-size: 1.25rem;
}

.stats-result-value-lg {
    font-size: 1.75rem;
}

.stats-result-unit {
    font-size: 0.9rem;
    color: var(--gray-500);
    font-weight: 400;
    margin-left: 0.25rem;
}

/* ============================================
   INTERPRETATION BOX
   ============================================ */

.stats-interpretation {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--success-green);
    margin-top: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.stats-interpretation-title {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.75rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stats-interpretation-text {
    color: var(--gray-700);
    line-height: 1.8;
    font-size: 0.95rem;
}

.stats-interpretation-text strong {
    color: var(--gray-900);
    font-weight: 600;
}

.stats-interpretation-text ul {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.stats-interpretation-text li {
    margin-bottom: 0.5rem;
}

/* ============================================
   TABLES (for contingency tables, etc.)
   ============================================ */

.stats-table-wrapper {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.contingency-table,
.stats-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.contingency-table th,
.contingency-table td,
.stats-table th,
.stats-table td {
    padding: 0.75rem;
    text-align: center;
    border: 1px solid var(--gray-300);
}

.contingency-table th,
.stats-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.contingency-table input {
    width: 90px;
    padding: 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.95rem;
    font-family: var(--font-mono);
    transition: border-color 0.2s;
}

.contingency-table input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.table-totals {
    background: #fef3c7 !important;
    font-weight: 600;
    color: var(--gray-900);
}

.table-header-row {
    background: var(--primary-blue) !important;
    color: white !important;
}

/* ============================================
   TABS (for multiple input methods)
   ============================================ */

.stats-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--gray-200);
}

.stats-tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--gray-600);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.stats-tab:hover {
    color: var(--primary-blue);
    background: var(--gray-50);
}

.stats-tab.active {
    color: var(--primary-blue);
    border-bottom-color: var(--primary-blue);
    font-weight: 600;
}

.stats-tab-content {
    display: none;
}

.stats-tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   COLLAPSIBLE SECTIONS
   ============================================ */

.stats-collapsible {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    background: white;
}

.stats-collapsible-header {
    padding: 1rem 1.25rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--gray-700);
    transition: background 0.2s;
}

.stats-collapsible-header:hover {
    background: var(--gray-50);
}

.stats-collapsible-icon {
    transition: transform 0.3s;
}

.stats-collapsible.active .stats-collapsible-icon {
    transform: rotate(180deg);
}

.stats-collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.stats-collapsible.active .stats-collapsible-content {
    max-height: 1000px;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
}

/* ============================================
   PROGRESS INDICATORS
   ============================================ */

.stats-progress {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 1rem 0;
}

.stats-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-blue), var(--primary-light));
    transition: width 0.3s ease;
}

.stats-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   BADGES & TAGS
   ============================================ */

.stats-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-badge-primary {
    background: var(--primary-blue);
    color: white;
}

.stats-badge-success {
    background: var(--success-green);
    color: white;
}

.stats-badge-warning {
    background: var(--warning-orange);
    color: white;
}

.stats-badge-danger {
    background: var(--danger-red);
    color: white;
}

.stats-badge-info {
    background: var(--accent-teal);
    color: white;
}

.stats-badge-secondary {
    background: var(--gray-500);
    color: white;
}

/* ============================================
   TOOLTIPS
   ============================================ */

.stats-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    border-bottom: 1px dotted var(--gray-400);
}

.stats-tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: var(--gray-900);
    color: white;
    text-align: center;
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    line-height: 1.4;
}

.stats-tooltip:hover .stats-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ============================================
   FORMULA DISPLAY
   ============================================ */

.stats-formula {
    background: var(--gray-50);
    padding: 1rem;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--accent-teal);
    margin: 1rem 0;
    font-family: var(--font-mono);
    overflow-x: auto;
}

.stats-formula-title {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
    font-family: var(--font-sans);
}

.stats-formula-content {
    font-size: 1.1rem;
    color: var(--gray-700);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .stats-calculator-wrapper {
        padding: 0;
        margin: 1rem 0;
    }
    
    .stats-calc-card {
        padding: 1.5rem;
        border-radius: var(--radius-md);
    }
    
    .stats-calc-title {
        font-size: 1.5rem;
    }
    
    .stats-form-row {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-results-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-button-group {
        flex-direction: column;
    }
    
    .stats-btn {
        width: 100%;
    }
    
    .contingency-table,
    .stats-table {
        font-size: 0.85rem;
    }
    
    .contingency-table th,
    .contingency-table td,
    .stats-table th,
    .stats-table td {
        padding: 0.5rem;
    }
    
    .contingency-table input {
        width: 70px;
        padding: 0.4rem;
    }
    
    .stats-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .stats-tab {
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .stats-calc-card {
        padding: 1rem;
    }
    
    .stats-results-header {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
    
    .stats-results-body {
        padding: 1rem;
    }
    
    .stats-result-value {
        font-size: 1.25rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .stats-button-group,
    .stats-btn,
    .stats-collapsible-icon {
        display: none !important;
    }
    
    .stats-collapsible-content {
        max-height: none !important;
        display: block !important;
    }
    
    .stats-results {
        display: block !important;
    }
    
    .stats-calc-card {
        box-shadow: none;
        border: 1px solid #000;
    }
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

.stats-input:focus-visible,
.stats-textarea:focus-visible,
.stats-select:focus-visible,
.stats-btn:focus-visible {
    outline: 3px solid var(--primary-blue);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
    /* For now, we'll keep light mode only for clarity */
}
