/* ==========================================================================
   Savings Goal Calculator - Complete CSS
   Mobile-First, Production-Ready Stylesheet
   ========================================================================== */

/* CSS Reset and Base Styles */
.sgc-calculator-container,
.sgc-calculator-container *,
.sgc-calculator-container *::before,
.sgc-calculator-container *::after {
    box-sizing: border-box;
}

/* Root Variables for Easy Customization */
.sgc-calculator-container {
    --sgc-primary: #3498db;
    --sgc-primary-dark: #2980b9;
    --sgc-secondary: #27ae60;
    --sgc-danger: #e74c3c;
    --sgc-warning: #f39c12;
    --sgc-light: #f8f9fa;
    --sgc-dark: #2c3e50;
    --sgc-gray: #6c757d;
    --sgc-border: #dee2e6;
    --sgc-radius: 8px;
    --sgc-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    --sgc-transition: all 0.3s ease;
    --sgc-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Main Container */
.sgc-calculator-container {
    max-width: 100%;
    margin: 0 auto;
    font-family: var(--sgc-font-family);
    line-height: 1.6;
    color: var(--sgc-dark);
    position: relative;
}

/* AdSense Sections */
.sgc-adsense-top,
.sgc-adsense-bottom {
    margin: 20px 0;
    text-align: center;
    min-height: 250px;
    background: var(--sgc-light);
    border: 1px dashed var(--sgc-border);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--sgc-radius);
    position: relative;
    overflow: hidden;
}

.sgc-adsense-top::before,
.sgc-adsense-bottom::before {
    content: "Advertisement";
    color: var(--sgc-gray);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.sgc-adsense-top.has-content::before,
.sgc-adsense-bottom.has-content::before {
    display: none;
}

/* Main Calculator Container */
.sgc-calculator {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px 20px;
    box-shadow: var(--sgc-shadow);
    border: 1px solid var(--sgc-border);
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.sgc-calculator::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--sgc-primary), var(--sgc-secondary));
}

/* Title Styling */
.sgc-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--sgc-dark);
    margin: 0 0 24px 0;
    text-align: center;
    border-bottom: 2px solid var(--sgc-primary);
    padding-bottom: 12px;
    position: relative;
}

.sgc-title::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: var(--sgc-secondary);
}

/* Form Styling */
.sgc-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Field Styling */
.sgc-field {
    position: relative;
    margin-bottom: 4px;
}

.sgc-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--sgc-dark);
    font-size: 14px;
    position: relative;
    transition: var(--sgc-transition);
}

.sgc-field.focused label {
    color: var(--sgc-primary);
    transform: scale(1.02);
}

/* Input Styling */
.sgc-field input,
.sgc-field select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--sgc-border);
    border-radius: var(--sgc-radius);
    font-size: 16px;
    background: #ffffff;
    transition: var(--sgc-transition);
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-family: inherit;
}

.sgc-field input:focus,
.sgc-field select:focus {
    outline: none;
    border-color: var(--sgc-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
    transform: translateY(-1px);
}

.sgc-field input:valid:not(:placeholder-shown) {
    border-color: var(--sgc-secondary);
    box-shadow: 0 0 0 1px rgba(39, 174, 96, 0.2);
}

.sgc-field input:invalid:not(:placeholder-shown) {
    border-color: var(--sgc-danger);
    box-shadow: 0 0 0 1px rgba(231, 76, 60, 0.2);
}

.sgc-field input::placeholder {
    color: var(--sgc-gray);
    opacity: 0.8;
}

/* Select Dropdown Styling */
.sgc-field select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

.sgc-field select option {
    padding: 8px 12px;
    background: white;
    color: var(--sgc-dark);
}

/* Input Group with Prefix/Suffix */
.sgc-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.sgc-input-prefix,
.sgc-input-suffix {
    position: absolute;
    color: var(--sgc-gray);
    font-weight: 600;
    pointer-events: none;
    z-index: 1;
    font-size: 16px;
}

.sgc-input-prefix {
    left: 12px;
}

.sgc-input-suffix {
    right: 12px;
}

.sgc-field .sgc-input-prefix + input {
    padding-left: 36px;
}

.sgc-field input + .sgc-input-suffix {
    padding-right: 36px;
}

/* Tooltip Styling */
.sgc-tooltip {
    display: inline-block;
    width: 18px;
    height: 18px;
    background: var(--sgc-primary);
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 12px;
    line-height: 18px;
    margin-left: 8px;
    cursor: help;
    position: relative;
    transition: var(--sgc-transition);
}

.sgc-tooltip:hover {
    background: var(--sgc-primary-dark);
    transform: scale(1.1);
}

.sgc-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--sgc-dark);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: var(--sgc-transition);
    pointer-events: none;
}

.sgc-tooltip::before {
    content: '';
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--sgc-dark);
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    transition: var(--sgc-transition);
}

.sgc-tooltip:hover::after,
.sgc-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Toggle Switch */
.sgc-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    gap: 12px;
    padding: 8px 0;
    transition: var(--sgc-transition);
}

.sgc-toggle:hover {
    color: var(--sgc-primary);
}

.sgc-toggle input[type="checkbox"] {
    display: none;
}

.sgc-toggle-slider {
    width: 48px;
    height: 24px;
    background: #ccc;
    border-radius: 24px;
    position: relative;
    transition: var(--sgc-transition);
    flex-shrink: 0;
}

.sgc-toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--sgc-transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.sgc-toggle input[type="checkbox"]:checked + .sgc-toggle-slider {
    background: var(--sgc-primary);
}

.sgc-toggle input[type="checkbox"]:checked + .sgc-toggle-slider::before {
    transform: translateX(24px);
}

.sgc-toggle input[type="checkbox"]:focus + .sgc-toggle-slider {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* Button Styling */
.sgc-button {
    background: linear-gradient(135deg, var(--sgc-primary), var(--sgc-primary-dark));
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: var(--sgc-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--sgc-transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 4px;
    min-height: 48px;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.sgc-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.sgc-button:hover {
    background: linear-gradient(135deg, var(--sgc-primary-dark), #21618c);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.sgc-button:hover::before {
    left: 100%;
}

.sgc-button:active {
    transform: translateY(0);
}

.sgc-button:focus {
    outline: 2px solid var(--sgc-primary);
    outline-offset: 2px;
}

.sgc-button-secondary {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
}

.sgc-button-secondary:hover {
    background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
    box-shadow: 0 4px 12px rgba(149, 165, 166, 0.3);
}

.sgc-button-outline {
    background: transparent;
    border: 2px solid var(--sgc-primary);
    color: var(--sgc-primary);
}

.sgc-button-outline:hover {
    background: var(--sgc-primary);
    color: white;
}

.sgc-button-text {
    background: transparent;
    border: none;
    color: var(--sgc-primary);
    text-decoration: underline;
    padding: 8px 16px;
    text-transform: none;
    letter-spacing: normal;
}

.sgc-button-text:hover {
    color: var(--sgc-primary-dark);
    background: rgba(52, 152, 219, 0.1);
    text-decoration: none;
}

.sgc-button-small {
    padding: 8px 16px;
    font-size: 14px;
    min-height: auto;
}

.sgc-button-large {
    padding: 16px 32px;
    font-size: 18px;
    min-height: 56px;
}

/* Button Groups */
.sgc-button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
}

/* Loading States */
.sgc-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.sgc-loading .sgc-button {
    color: transparent;
}

.sgc-loading .sgc-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Input Error States */
.sgc-input-error {
    border-color: var(--sgc-danger) !important;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1) !important;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Message States */
.sgc-error,
.sgc-success,
.sgc-warning,
.sgc-info {
    border-radius: var(--sgc-radius);
    padding: 12px 16px;
    margin: 12px 0;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sgc-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-left: 4px solid var(--sgc-danger);
}

.sgc-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-left: 4px solid var(--sgc-secondary);
}

.sgc-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-left: 4px solid var(--sgc-warning);
}

.sgc-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    border-left: 4px solid #17a2b8;
}

/* Results Section */
.sgc-results {
    background: linear-gradient(135deg, var(--sgc-light), #e9ecef);
    border-radius: 12px;
    padding: 24px;
    margin-top: 24px;
    border: 1px solid var(--sgc-border);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sgc-results h4 {
    color: var(--sgc-dark);
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    border-bottom: 2px solid var(--sgc-secondary);
    padding-bottom: 12px;
    position: relative;
}

.sgc-results h4::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 2px;
    background: var(--sgc-primary);
}

.sgc-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--sgc-border);
    flex-wrap: wrap;
    gap: 8px;
    transition: var(--sgc-transition);
}

.sgc-result-item:hover {
    background: rgba(52, 152, 219, 0.05);
    padding: 12px 16px;
    margin: 0 -16px;
    border-radius: var(--sgc-radius);
}

.sgc-result-item:last-child {
    border-bottom: none;
}

.sgc-result-label {
    font-weight: 600;
    color: var(--sgc-dark);
    font-size: 14px;
    flex: 1;
    min-width: 160px;
}

.sgc-result-value {
    font-weight: 700;
    color: var(--sgc-secondary);
    font-size: 18px;
    text-align: right;
    flex-shrink: 0;
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Progress Chart */
.sgc-progress-chart {
    margin: 24px 0;
    text-align: center;
    background: white;
    border-radius: var(--sgc-radius);
    padding: 16px;
    border: 1px solid var(--sgc-border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sgc-progress-chart h5 {
    margin: 0 0 16px 0;
    color: var(--sgc-dark);
    font-size: 16px;
    font-weight: 600;
}

.sgc-progress-chart canvas {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

/* Actions */
.sgc-actions {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--sgc-border);
}

/* Affiliate Content */
.sgc-affiliate-content {
    background: var(--sgc-light);
    border: 1px solid var(--sgc-border);
    border-radius: 12px;
    padding: 24px;
    margin-top: 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.sgc-affiliate-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--sgc-warning), #e67e22);
}

.sgc-affiliate-content h4 {
    color: var(--sgc-dark);
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 700;
}

.sgc-affiliate-content p {
    margin: 12px 0;
    color: var(--sgc-gray);
    line-height: 1.6;
}

.sgc-affiliate-content .button,
.sgc-affiliate-content a.button {
    display: inline-block;
    background: linear-gradient(135deg, var(--sgc-danger), #c0392b);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: var(--sgc-radius);
    font-weight: 600;
    margin: 8px;
    transition: var(--sgc-transition);
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.sgc-affiliate-content .button:hover,
.sgc-affiliate-content a.button:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* Notification System */
.sgc-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 300px;
    padding: 16px;
    border-radius: var(--sgc-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    font-weight: 500;
}

.sgc-notification.show {
    transform: translateX(0);
}

.sgc-notification.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid var(--sgc-secondary);
}

.sgc-notification.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid var(--sgc-danger);
}

.sgc-notification.info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.sgc-notification-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--sgc-transition);
}

.sgc-notification-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

/* Modal System */
.sgc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: var(--sgc-transition);
}

.sgc-modal.show {
    opacity: 1;
    visibility: visible;
}

.sgc-modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    transition: var(--sgc-transition);
}

.sgc-modal.show .sgc-modal-content {
    transform: scale(1);
}

.sgc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--sgc-border);
}

.sgc-modal-title {
    margin: 0;
    font-size: 20px;
    color: var(--sgc-dark);
    font-weight: 700;
}

.sgc-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--sgc-gray);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--sgc-transition);
}

.sgc-modal-close:hover {
    background: var(--sgc-light);
    color: var(--sgc-dark);
}

/* Skeleton Loading */
.sgc-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.sgc-skeleton-text {
    height: 16px;
    margin: 8px 0;
}

.sgc-skeleton-button {
    height: 48px;
    width: 120px;
}

.sgc-skeleton-field {
    height: 48px;
    margin: 16px 0;
}

/* Progress Indicators */
.sgc-progress-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0;
    padding: 0 4px;
}

.sgc-progress-step {
    flex: 1;
    text-align: center;
    position: relative;
    font-size: 12px;
    color: var(--sgc-gray);
    font-weight: 500;
}

.sgc-progress-step::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--sgc-border);
    z-index: 1;
    transition: var(--sgc-transition);
}

.sgc-progress-step.active::before {
    background: var(--sgc-primary);
}

.sgc-progress-step.completed::before {
    background: var(--sgc-secondary);
}

.sgc-progress-step.active,
.sgc-progress-step.completed {
    color: var(--sgc-dark);
}

.sgc-progress-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 60%;
    width: 80%;
    height: 2px;
    background: var(--sgc-border);
    z-index: 0;
    transition: var(--sgc-transition);
}

.sgc-progress-step.completed:not(:last-child)::after {
    background: var(--sgc-secondary);
}

/* Data Tables */
.sgc-results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    background: white;
    border-radius: var(--sgc-radius);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sgc-results-table th,
.sgc-results-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--sgc-border);
}

.sgc-results-table th {
    background: var(--sgc-light);
    font-weight: 600;
    color: var(--sgc-dark);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.sgc-results-table tr:last-child td {
    border-bottom: none;
}

.sgc-results-table tbody tr:hover {
    background: rgba(52, 152, 219, 0.05);
}

.sgc-results-table .number {
    text-align: right;
    font-weight: 600;
    color: var(--sgc-secondary);
}

/* Collapsible Sections */
.sgc-collapsible {
    border: 1px solid var(--sgc-border);
    border-radius: var(--sgc-radius);
    margin: 16px 0;
    overflow: hidden;
}

.sgc-collapsible-header {
    background: var(--sgc-light);
    padding: 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--sgc-transition);
    border: none;
    width: 100%;
    font-family: inherit;
}

.sgc-collapsible-header:hover {
    background: #e9ecef;
}

.sgc-collapsible-header h4 {
    margin: 0;
    font-size: 16px;
    color: var(--sgc-dark);
    font-weight: 600;
}

.sgc-collapsible-icon {
    transition: transform 0.3s ease;
    font-size: 18px;
    color: var(--sgc-gray);
}

.sgc-collapsible.open .sgc-collapsible-icon {
    transform: rotate(180deg);
}

.sgc-collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
}

.sgc-collapsible.open .sgc-collapsible-content {
    max-height: 500px;
    padding: 16px;
}

/* Screen Reader Only */
.sgc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Management */
.sgc-calculator *:focus {
    outline: 2px solid var(--sgc-primary);
    outline-offset: 2px;
}

.sgc-calculator *:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced Theme Support */
.sgc-calculator-container[data-theme="modern"] {
    --sgc-primary: #667eea;
    --sgc-primary-dark: #5a67d8;
    --sgc-secondary: #f093fb;
}

.sgc-calculator-container[data-theme="minimal"] {
    --sgc-primary: #4a5568;
    --sgc-primary-dark: #2d3748;
    --sgc-secondary: #68d391;
}

.sgc-calculator-container[data-theme="dark"] {
    --sgc-primary: #63b3ed;
    --sgc-primary-dark: #4299e1;
    --sgc-secondary: #68d391;
    --sgc-light: #2d3748;
    --sgc-dark: #f7fafc;
    --sgc-border: #4a5568;
}

.sgc-calculator-container[data-theme="dark"] .sgc-calculator {
    background: #1a202c;
    color: #f7fafc;
}

.sgc-calculator-container[data-theme="dark"] .sgc-field input,
.sgc-calculator-container[data-theme="dark"] .sgc-field select {
    background: #2d3748;
    color: #f7fafc;
    border-color: #4a5568;
}

.sgc-calculator-container[data-theme="dark"] .sgc-results {
    background: linear-gradient(135deg, #2d3748, #1a202c);
}

/* Responsive Design - Mobile First */
@media (max-width: 480px) {
    .sgc-calculator {
        padding: 16px;
        margin: 10px;
        border-radius: var(--sgc-radius);
    }
    
    .sgc-title {
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .sgc-field label {
        font-size: 13px;
    }
    
    .sgc-field input,
    .sgc-field select {
        padding: 10px 12px;
        font-size: 15px;
    }
    
    .sgc-button {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        margin: 4px 0;
    }
    
    .sgc-result-value {
        font-size: 16px;
    }
    
    .sgc-button-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sgc-modal-content {
        margin: 20px;
        padding: 20px;
    }
    
    .sgc-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .sgc-tooltip::after {
        left: 10px;
        transform: none;
        white-space: normal;
        width: 200px;
    }
    
    .sgc-tooltip::before {
        left: 20px;
        transform: none;
    }
}

/* Tablet Styles */
@media (min-width: 768px) {
    .sgc-calculator-container {
        max-width: 600px;
    }
    
    .sgc-calculator {
        padding: 32px;
    }
    
    .sgc-title {
        font-size: 28px;
    }
    
    .sgc-form {
        gap: 24px;
    }
    
    .sgc-field {
        display: grid;
        grid-template-columns: 1fr 2fr;
        gap: 16px;
        align-items: center;
    }
    
    .sgc-field label {
        margin-bottom: 0;
        text-align: right;
    }
    
    .sgc-toggle {
        grid-column: 2;
        justify-self: start;
    }
    
    .sgc-result-item {
        flex-wrap: nowrap;
    }
    
    .sgc-result-label {
        min-width: auto;
    }
    
    .sgc-adsense-top,
    .sgc-adsense-bottom {
        min-height: 280px;
    }
    
    .sgc-button {
        width: auto;
        margin: 8px 4px;
    }
    
    .sgc-button-group {
        flex-direction: row;
    }
}

/* Desktop Styles */
@media (min-width: 1024px) {
    .sgc-calculator-container {
        max-width: 800px;
    }
    
    .sgc-calculator {
        padding: 40px;
    }
    
    .sgc-title {
        font-size: 32px;
    }
    
    .sgc-results {
        padding: 32px;
    }
    
    .sgc-adsense-top,
    .sgc-adsense-bottom {
        min-height: 320px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .sgc-calculator-container:not([data-theme]) {
        --sgc-light: #2d3748;
        --sgc-dark: #f7fafc;
        --sgc-border: #4a5568;
    }
    
    .sgc-calculator {
        background: #1a202c;
        color: #f7fafc;
    }
    
    .sgc-field input,
    .sgc-field select {
        background: #2d3748;
        color: #f7fafc;
        border-color: #4a5568;
    }
    
    .sgc-results {
        background: linear-gradient(135deg, #2d3748, #1a202c);
    }
    
    .sgc-adsense-top,
    .sgc-adsense-bottom {
        background: #2d3748;
        border-color: #4a5568;
    }
}

/* Print Styles */
@media print {
    .sgc-adsense-top,
    .sgc-adsense-bottom,
    .sgc-affiliate-content,
    .sgc-actions,
    .sgc-button,
    .sgc-tooltip {
        display: none !important;
    }
    
    .sgc-calculator {
        box-shadow: none;
        border: 2px solid #000;
        page-break-inside: avoid;
    }
    
    .sgc-title {
        color: #000;
        border-bottom-color: #000;
    }
    
    .sgc-result-value {
        color: #000;
        font-weight: bold;
    }
    
    .sgc-results {
        background: white;
        border: 1px solid #000;
    }
    
    .sgc-progress-chart canvas {
        max-height: 300px;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .sgc-calculator {
        border: 3px solid #000;
    }
    
    .sgc-field input,
    .sgc-field select {
        border: 3px solid #000;
    }
    
    .sgc-button {
        border: 2px solid #000;
        background: #000;
        color: #fff;
    }
    
    .sgc-button:hover {
        background: #333;
    }
    
    .sgc-button:focus {
        outline: 3px solid #000;
        outline-offset: 2px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .sgc-calculator-container * {
        animation: none !important;
        transition: none !important;
    }
}

/* RTL Language Support */
[dir="rtl"] .sgc-calculator-container {
    text-align: right;
}

[dir="rtl"] .sgc-field input,
[dir="rtl"] .sgc-field select {
    text-align: right;
}

[dir="rtl"] .sgc-input-prefix {
    left: auto;
    right: 12px;
}

[dir="rtl"] .sgc-input-suffix {
    right: auto;
    left: 12px;
}

[dir="rtl"] .sgc-field .sgc-input-prefix + input {
    padding-left: 16px;
    padding-right: 36px;
}

[dir="rtl"] .sgc-tooltip {
    margin-left: 0;
    margin-right: 8px;
}

[dir="rtl"] .sgc-toggle-slider::before {
    left: auto;
    right: 2px;
}

[dir="rtl"] .sgc-toggle input[type="checkbox"]:checked + .sgc-toggle-slider::before {
    transform: translateX(-24px);
}

[dir="rtl"] .sgc-result-value {
    text-align: left;
}

[dir="rtl"] .sgc-notification {
    right: auto;
    left: 20px;
}

[dir="rtl"] .sgc-notification {
    transform: translateX(-100%);
}

[dir="rtl"] .sgc-notification.show {
    transform: translateX(0);
}

/* Container Queries (Future-proofing) */
@container (max-width: 400px) {
    .sgc-field {
        grid-template-columns: 1fr !important;
    }
    
    .sgc-field label {
        text-align: left !important;
        margin-bottom: 8px !important;
    }
}

/* Accessibility Enhancements */
@media (forced-colors: active) {
    .sgc-calculator {
        border: 2px solid ButtonText;
    }
    
    .sgc-button {
        border: 2px solid ButtonText;
    }
}

/* Performance Optimizations */
.sgc-calculator-container * {
    will-change: auto;
}

.sgc-calculator-container.sgc-animating * {
    will-change: transform, opacity;
}

/* Micro-interactions and Polish */
.sgc-calculator:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.sgc-field:focus-within {
    transform: translateY(-1px);
}

.sgc-calculator-container:hover .sgc-title {
    animation: subtle-glow 2s ease-in-out infinite alternate;
}

@keyframes subtle-glow {
    from { text-shadow: 0 0 5px rgba(52, 152, 219, 0.3); }
    to { text-shadow: 0 0 10px rgba(52, 152, 219, 0.5); }
}

/* Custom Scrollbar */
.sgc-modal-content::-webkit-scrollbar {
    width: 8px;
}

.sgc-modal-content::-webkit-scrollbar-track {
    background: var(--sgc-light);
    border-radius: 4px;
}

.sgc-modal-content::-webkit-scrollbar-thumb {
    background: var(--sgc-gray);
    border-radius: 4px;
}

.sgc-modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--sgc-primary);
}

/* Selection Styling */
.sgc-calculator-container ::selection {
    background: rgba(52, 152, 219, 0.2);
    color: var(--sgc-dark);
}

/* Final Polish */
.sgc-calculator-container {
    position: relative;
    z-index: 1;
}

.sgc-calculator-container::before {
    content: '';
    position: absolute;
    top: -50px;
    left: -50px;
    right: -50px;
    bottom: -50px;
    background: radial-gradient(circle at 50% 50%, rgba(52, 152, 219, 0.02) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
}