/**
 * Tip Calculator App Styles
 *
 * A production-ready tip calculator with accessible, responsive design
 */

/* ========================================
   App Container
   ======================================== */

.tc-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

/* ========================================
   Tip Calculator Main
   ======================================== */

.tip-calculator {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

/* ========================================
   Section Styling
   ======================================== */

.tc-section {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--color-border);
}

.tc-section:last-of-type {
    border-bottom: none;
}

.tc-section-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ========================================
   Bill Input
   ======================================== */

.tc-bill-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.tc-currency-symbol {
    position: absolute;
    left: var(--space-4);
    font-size: var(--font-size-2xl);
    font-weight: 600;
    color: var(--color-text-muted);
    pointer-events: none;
    z-index: 1;
}

.tc-bill-input {
    width: 100%;
    padding: var(--space-4) var(--space-4) var(--space-4) var(--space-12);
    font-size: var(--font-size-2xl);
    font-family: var(--font-mono);
    font-weight: 600;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-alt);
    color: var(--color-text);
    text-align: right;
}

.tc-bill-input:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--color-primary);
}

.tc-bill-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

/* Remove number input spinners */
.tc-bill-input::-webkit-outer-spin-button,
.tc-bill-input::-webkit-inner-spin-button,
.tc-tax-input::-webkit-outer-spin-button,
.tc-tax-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tc-bill-input[type='number'],
.tc-tax-input[type='number'] {
    -moz-appearance: textfield;
}

.tc-field-error {
    display: block;
    margin-top: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-error);
    min-height: 1.25rem;
}

/* ========================================
   Pre-tax Toggle
   ======================================== */

.tc-pretax-wrapper {
    margin-top: var(--space-4);
}

.tc-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

.tc-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.tc-tax-input-wrapper {
    margin-top: var(--space-3);
    padding: var(--space-3);
    background: var(--color-bg-alt);
    border-radius: var(--radius-md);
}

.tc-tax-label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
}

.tc-tax-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.tc-tax-input-group .tc-currency-symbol {
    left: var(--space-3);
    font-size: var(--font-size-base);
}

.tc-tax-input {
    width: 100%;
    padding: var(--space-2) var(--space-3) var(--space-2) var(--space-8);
    font-size: var(--font-size-base);
    font-family: var(--font-mono);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text);
    text-align: right;
}

.tc-tax-input:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-color: var(--color-primary);
}

/* ========================================
   Tip Presets
   ======================================== */

.tc-preset-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.tc-preset-btn {
    padding: var(--space-3) var(--space-2);
    font-size: var(--font-size-base);
    font-weight: 600;
    background: var(--color-bg-alt);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 48px;
}

.tc-preset-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.tc-preset-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.tc-preset-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* ========================================
   Custom Tip Slider
   ======================================== */

.tc-custom-tip {
    padding-top: var(--space-3);
    border-top: 1px dashed var(--color-border);
}

.tc-custom-label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
}

.tc-slider-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.tc-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: var(--color-bg-alt);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.tc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.tc-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-md);
}

.tc-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.tc-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
}

.tc-slider:focus-visible {
    outline: none;
}

.tc-slider:focus-visible::-webkit-slider-thumb {
    box-shadow: var(--focus-ring);
}

.tc-slider:focus-visible::-moz-range-thumb {
    box-shadow: var(--focus-ring);
}

.tc-slider-value {
    min-width: 60px;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-lg);
    font-weight: 600;
    font-family: var(--font-mono);
    text-align: center;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
}

/* ========================================
   Split Counter
   ======================================== */

.tc-split-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.tc-split-counter {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.tc-split-btn {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xl);
    font-weight: 600;
    background: var(--color-bg-card);
    border: none;
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tc-split-btn:hover {
    background: var(--color-primary);
    color: white;
}

.tc-split-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    z-index: 1;
}

.tc-split-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tc-split-btn:disabled:hover {
    background: var(--color-bg-card);
    color: var(--color-text);
}

.tc-split-value {
    min-width: 48px;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xl);
    font-weight: 600;
    font-family: var(--font-mono);
    text-align: center;
    background: var(--color-bg-alt);
    color: var(--color-text);
}

.tc-people-label {
    font-size: var(--font-size-base);
    color: var(--color-text-muted);
}

/* ========================================
   Rounding Options
   ======================================== */

.tc-rounding-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.tc-rounding-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.tc-rounding-group {
    display: flex;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-1);
}

.tc-rounding-btn {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 36px;
}

.tc-rounding-btn:hover {
    color: var(--color-text);
}

.tc-rounding-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.tc-rounding-btn.active {
    background: var(--color-primary);
    color: white;
}

/* ========================================
   Results Display
   ======================================== */

.tc-results {
    padding: var(--space-5) var(--space-6);
    background: var(--color-bg-alt);
    border-top: 2px solid var(--color-border);
}

.tc-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
}

.tc-result-row:not(:last-child) {
    border-bottom: 1px dashed var(--color-border);
}

.tc-result-label {
    font-size: var(--font-size-base);
    color: var(--color-text-muted);
}

.tc-result-value {
    font-size: var(--font-size-lg);
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--color-text);
}

.tc-result-primary {
    font-size: var(--font-size-xl);
    color: var(--color-primary);
}

.tc-result-highlight {
    font-size: var(--font-size-2xl);
    padding: var(--space-2) var(--space-4);
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-md);
}

.tc-result-split {
    margin-top: var(--space-2);
    padding-top: var(--space-4);
    border-top: 2px solid var(--color-border);
}

#tc-per-person-row[hidden] {
    display: none;
}

/* ========================================
   Action Buttons
   ======================================== */

.tc-actions {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: var(--color-bg-card);
    border-top: 1px solid var(--color-border);
}

.tc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    flex: 1;
    padding: var(--space-3) var(--space-5);
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
}

.tc-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.tc-btn-secondary {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.tc-btn-secondary:hover {
    background: var(--color-border);
}

.tc-btn.copied {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

/* ========================================
   Help Panel (Modal)
   ======================================== */

.help-panel {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.help-panel[hidden] {
    display: none;
}

.help-content {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: var(--color-bg-card);
    z-index: 1;
}

.help-header h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
}

.help-body {
    padding: var(--space-6);
}

.help-section {
    margin-bottom: var(--space-6);
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: var(--color-text);
}

.help-steps,
.help-features {
    padding-left: var(--space-5);
    margin: 0;
}

.help-steps li,
.help-features li {
    margin-bottom: var(--space-2);
    color: var(--color-text-muted);
    line-height: 1.6;
}

.help-steps li:last-child,
.help-features li:last-child {
    margin-bottom: 0;
}

.help-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all var(--transition-fast);
}

.help-close:hover {
    background: var(--color-bg-alt);
    color: var(--color-text);
}

.help-close:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 480px) {
    .tc-section {
        padding: var(--space-4);
    }

    .tc-preset-group {
        grid-template-columns: repeat(2, 1fr);
    }

    .tc-split-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }

    .tc-rounding-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }

    .tc-rounding-group {
        width: 100%;
        justify-content: space-between;
    }

    .tc-rounding-btn {
        flex: 1;
        text-align: center;
    }

    .tc-results {
        padding: var(--space-4);
    }

    .tc-result-highlight {
        font-size: var(--font-size-xl);
    }

    .tc-actions {
        padding: var(--space-4);
    }
}

/* ========================================
   RTL Support
   ======================================== */

[dir="rtl"] .tc-currency-symbol {
    left: auto;
    right: var(--space-4);
}

[dir="rtl"] .tc-bill-input {
    padding-left: var(--space-4);
    padding-right: var(--space-12);
    text-align: left;
}

[dir="rtl"] .tc-tax-input-group .tc-currency-symbol {
    left: auto;
    right: var(--space-3);
}

[dir="rtl"] .tc-tax-input {
    padding-left: var(--space-3);
    padding-right: var(--space-8);
    text-align: left;
}

[dir="rtl"] .tc-result-value {
    direction: ltr;
}

/* ========================================
   Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .tc-preset-btn,
    .tc-split-btn,
    .tc-rounding-btn,
    .tc-btn,
    .tc-slider::-webkit-slider-thumb,
    .tc-slider::-moz-range-thumb,
    .help-close {
        transition: none;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    .tc-actions,
    .help-panel {
        display: none;
    }

    .tip-calculator {
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .tc-section,
    .tc-results {
        background: white;
    }
}
