/**
 * DVT Calculator Frontend Styles - Version 2.0
 * Using website design system colors, typography, and spacing
 */

/* ===== WRAPPER & CONTAINER ===== */
#dvt-calculator-wrapper {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-m);
    box-sizing: border-box;
    font-family: var(--cf-font-family--inter, 'Inter', sans-serif);
}

/* ===== TYPOGRAPHY ===== */
.dvt-form-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-title);
    margin: 0 0 var(--space-s) 0;
    text-align: center;
    line-height: 1.2;
}

.dvt-form-description {
    font-size: var(--text-m);
    color: var(--text-body);
    margin: 0 0 var(--space-xl) 0;
    text-align: center;
    line-height: 1.4;
}

.dvt-calculator-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-title);
    margin: 0 0 var(--space-m) 0;
    line-height: 1.3;
}

/* ===== FORM STRUCTURE ===== */
.dvt-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-m);
}

.dvt-form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
}

.dvt-label {
    font-size: var(--text-m);
    font-weight: 500;
    color: var(--text-title);
    margin: 0;
    display: block;
    margin-bottom: var(--space-2xs);
}

.dvt-required {
    color: var(--primary);
    font-weight: 600;
}

.dvt-optional {
    color: var(--text-body);
    font-weight: 400;
    font-size: var(--text-xs);
}

/* ===== INPUT STYLING ===== */
.dvt-input {
    width: 100%;
    padding: var(--space-xs) var(--space-s);
    border: 1px solid var(--dark-30);
    border-radius: var(--radius-m);
    font-size: var(--text-m);
    font-weight: 500;
    background: var(--bg-surface);
    color: var(--text-title);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    box-sizing: border-box;
    line-height: 1;
    font-family: inherit;
}

.dvt-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-20);
    background: var(--primary-10);
}

.dvt-input:hover {
    border-color: var(--primary);
    background: var(--bg-surface);
}

.dvt-input::placeholder {
    color: var(--dark-40);
}

.dvt-input.dvt-error {
    border-color: var(--error);
    background: var(--error-10);
}

.dvt-input.dvt-error:focus {
    border-color: var(--error);
    box-shadow: 0 0 0 2px var(--error-20);
}

.dvt-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.4;
}

.dvt-input:disabled {
    cursor: not-allowed;
    opacity: 0.75;
    box-shadow: none;
    background: var(--dark-10);
}

/* Remove browser default required styling */
.dvt-input:required {
    box-shadow: none;
}

.dvt-input:invalid {
    box-shadow: none;
}

/* ===== CUSTOM CHECKBOX ===== */
.dvt-calculator-toggle {
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-m);
    padding: var(--space-m);
    margin: 0;
}

.dvt-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: var(--space-s);
    cursor: pointer;
    position: relative;
    line-height: 1.4;
}

.dvt-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.dvt-checkmark {
    height: 20px;
    width: 20px;
    background-color: var(--bg-surface);
    border: 2px solid var(--dark-30);
    border-radius: var(--radius-s);
    position: relative;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.2s ease;
}

.dvt-checkbox:checked ~ .dvt-checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.dvt-checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.dvt-checkbox:checked ~ .dvt-checkmark:after {
    display: block;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.dvt-checkbox-text {
    font-size: var(--text-s);
    color: var(--text-title);
    font-weight: 500;
    flex: 1;
    line-height: 1.4;
}

/* ===== BUTTON STYLING ===== */
.dvt-submit-btn {
    width: 100%;
    padding: var(--space-xs) var(--space-l);
    background: var(--primary);
    color: #fff;
    border: 2px solid transparent;
    border-radius: var(--radius-full);
    font-size: var(--text-m);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-top: var(--space-2xs);
    box-shadow: var(--shadow-xl);
    text-transform: uppercase;
    line-height: 1;
    font-family: inherit;
}

.dvt-submit-btn:hover:not(:disabled) {
    background: var(--primary-d-1);
    transform: translateY(-0.1rem);
}

.dvt-submit-btn:focus {
    outline: 4px solid var(--primary-l-3);
    outline-offset: 2px;
}

.dvt-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.dvt-add-window-btn {
    padding: var(--space-xs) var(--space-l);
    background: var(--primary);
    color: #fff;
    border: 2px solid transparent;
    border-radius: var(--radius-full);
    font-size: var(--text-m);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    width: 100%;
    box-shadow: var(--shadow-xl);
    text-transform: uppercase;
    line-height: 1;
    font-family: inherit;
}

.dvt-add-window-btn:hover {
    background: var(--primary-d-1);
    transform: translateY(-0.1rem);
}

.dvt-add-window-btn:focus {
    outline: 4px solid var(--primary-l-3);
    outline-offset: 2px;
}

/* ===== CALCULATOR SECTION ===== */
.dvt-calculator-section {
    margin-top: 0;
    margin-bottom: var(--space-m);
}

.dvt-calculator-inner {
    background: var(--bg-surface);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-l);
    padding: var(--space-l);
}

.dvt-calculator-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-m);
    margin-bottom: var(--space-l);
}

/* Calculator two-column row for width/height only */
.dvt-calc-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-s);
}

.dvt-calc-half {
    margin: 0;
}

/* ===== UNIT SELECTOR ===== */
.dvt-unit-selector {
    display: flex;
    background: var(--dark-5);
    border-radius: var(--radius-full);
    padding: var(--space-3xs);
    gap: var(--space-3xs);
}

.dvt-unit-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.unit-label {
    flex: 1;
    text-align: center;
    padding: var(--space-2xs) var(--space-s);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: var(--text-s);
    font-weight: 500;
    color: var(--text-body);
    transition: all 0.2s ease;
    background: transparent;
    font-family: inherit;
}

.dvt-unit-radio:checked + .unit-label {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

/* ===== WINDOW LIST ===== */
.dvt-window-list-card {
    background: var(--bg-body);
    border: 1px solid var(--dark-30);
    border-radius: var(--radius-m);
    padding: var(--space-m);
}

.dvt-window-list-title {
    font-size: var(--text-l);
    font-weight: 600;
    color: var(--text-title);
    margin: 0 0 var(--space-s) 0;
    padding-bottom: var(--space-2xs);
    border-bottom: 1px solid var(--border-primary);
    line-height: 1.3;
}

.dvt-window-list {
    max-height: 16rem;
    overflow-y: auto;
    margin-bottom: var(--space-s);
}

.dvt-empty-message {
    color: var(--text-body);
    text-align: center;
    padding: var(--space-2xl) var(--space-m);
    font-style: italic;
    margin: 0;
    font-size: var(--text-s);
    line-height: 1.4;
}

.window-item {
    background: var(--bg-surface);
    border: 1px solid var(--dark-30);
    border-radius: var(--radius-m);
    padding: var(--space-s);
    margin-bottom: var(--space-2xs);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.window-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-m);
}

.window-item button {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-s);
    padding: var(--space-3xs) var(--space-s);
    font-size: var(--text-s);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

.window-item button:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-1px);
}

.window-item button:focus {
    outline: 3px solid var(--primary-l-3);
    outline-offset: 2px;
}

/* ===== TOTAL AREA ===== */
.dvt-total-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--space-s);
    border-top: 1px solid var(--border-primary);
}

.dvt-total-label {
    font-size: var(--text-l);
    font-weight: 500;
    color: var(--text-body);
    line-height: 1.3;
}

.dvt-total-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

/* ===== SUBMIT SECTION WITH MARGIN ===== */
.dvt-calc-submit-section {
    margin-top: var(--space-m);
    padding-top: var(--space-m);
    border-top: 1px solid var(--border);
}

/* ===== ALERT MESSAGES ===== */
.alert {
    padding: var(--space-s) var(--space-m);
    border-radius: var(--radius-m);
    font-weight: 500;
    margin: var(--space-m) 0;
    font-size: var(--text-m);
    line-height: 1.4;
    font-family: inherit;
}

.alert-success {
    background: var(--success-10);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-error {
    background: var(--error-10);
    color: var(--error);
    border: 1px solid var(--error);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    #dvt-calculator-wrapper {
        padding: var(--space-s);
        max-width: none;
    }
    
    .dvt-form-title {
        font-size: var(--text-xl);
    }
    
    .dvt-calc-row {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-s);
    }
    
    .dvt-unit-selector {
        flex-direction: row;
    }
    
    .unit-label {
        text-align: center;
    }
    
    .dvt-checkbox-text {
        font-size: var(--text-xs);
    }
    
    .dvt-calculator-inner {
        padding: var(--space-s);
    }
}

@media (max-width: 480px) {
    #dvt-calculator-wrapper {
        padding: var(--space-2xs);
    }
    
    .dvt-form {
        gap: var(--space-s);
    }
}

/* ===== UTILITY CLASSES ===== */
.sr-only {
    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 theme support */
:root.cf-theme-dark .dvt-submit-btn {
    color: #fff;
}

:root.cf-theme-dark .dvt-add-window-btn {
    color: #fff;
}

/* Input focus styles */
.dvt-input::-webkit-inner-spin-button,
.dvt-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dvt-input[type=number] {
    -moz-appearance: textfield;
}

/* Ensure proper box-sizing */
#dvt-calculator-wrapper * {
    box-sizing: border-box;
}