/**
 * TEC-D AutoCalc - Frontend Styles
 */

:root {
    --tdac-primary: #2563eb;
    --tdac-primary-hover: #1d4ed8;
    --tdac-primary-light: #eff6ff;
    --tdac-text: #1e293b;
    --tdac-muted: #64748b;
    --tdac-border: #e2e8f0;
    --tdac-bg: #f8fafc;
    --tdac-white: #ffffff;
    --tdac-error: #dc2626;
    --tdac-success: #16a34a;
    --tdac-radius: 8px;
    --tdac-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --tdac-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* ============================================================
   Form Wrapper
   ============================================================ */
.tdac-form-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans JP', 'Hiragino Sans', 'Meiryo', sans-serif;
    font-size: 15px;
    color: var(--tdac-text);
    line-height: 1.6;
    width: 100%;
}

.tdac-form-wrap *,
.tdac-form-wrap *::before,
.tdac-form-wrap *::after {
    box-sizing: border-box;
}

/* ============================================================
   Form Header
   ============================================================ */
.tdac-form-header {
    margin-bottom: 28px;
}

.tdac-form-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--tdac-text);
    margin: 0 0 8px;
}

.tdac-form-description {
    color: var(--tdac-muted);
    margin: 0;
    font-size: 15px;
}

/* ============================================================
   Form Body Layout
   ============================================================ */
.tdac-form-body {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
}

.tdac-fields-area {
    min-width: 0;
}

/* ============================================================
   Customer Section
   ============================================================ */
.tdac-customer-section {
    background: var(--tdac-bg);
    border: 1px solid var(--tdac-border);
    border-radius: var(--tdac-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.tdac-section {
    margin-bottom: 20px;
}

.tdac-section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--tdac-text);
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--tdac-primary);
    display: inline-block;
}

/* ============================================================
   Field Wraps
   ============================================================ */
.tdac-field-wrap {
    margin-bottom: 18px;
}

.tdac-field-wrap.tdac-field-hidden {
    display: none !important;
}

.tdac-field-wrap.tdac-field-heading {
    margin-bottom: 12px;
}

.tdac-field-wrap.tdac-field-separator {
    margin-bottom: 20px;
}

/* ============================================================
   Labels
   ============================================================ */
.tdac-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--tdac-text);
    margin-bottom: 6px;
}

.tdac-required-mark {
    color: var(--tdac-error);
    margin-left: 3px;
    font-weight: 700;
}

/* ============================================================
   Input Controls
   ============================================================ */
.tdac-input,
.tdac-textarea,
.tdac-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--tdac-border);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    color: var(--tdac-text);
    background: var(--tdac-white);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.tdac-input:focus,
.tdac-textarea:focus,
.tdac-select:focus {
    outline: none;
    border-color: var(--tdac-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.tdac-input::placeholder,
.tdac-textarea::placeholder {
    color: #a0aec0;
}

.tdac-textarea {
    min-height: 100px;
    resize: vertical;
}

.tdac-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.tdac-input[type="number"] {
    -moz-appearance: textfield;
}
.tdac-input[type="number"]::-webkit-inner-spin-button,
.tdac-input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}

/* ============================================================
   Number Wrap (with unit hint)
   ============================================================ */
.tdac-number-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tdac-number-wrap .tdac-input {
    flex: 1;
}

.tdac-unit-hint {
    font-size: 13px;
    color: var(--tdac-primary);
    font-weight: 600;
    white-space: nowrap;
    background: var(--tdac-primary-light);
    padding: 4px 10px;
    border-radius: 4px;
}

/* ============================================================
   Radio Groups
   ============================================================ */
.tdac-radio-group,
.tdac-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tdac-radio-option,
.tdac-checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1.5px solid var(--tdac-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.tdac-radio-option:hover,
.tdac-checkbox-option:hover {
    border-color: #93c5fd;
    background: var(--tdac-primary-light);
}

.tdac-radio-option input,
.tdac-checkbox-option input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--tdac-primary);
    flex-shrink: 0;
}

.tdac-radio-option:has(input:checked),
.tdac-checkbox-option:has(input:checked) {
    border-color: var(--tdac-primary);
    background: var(--tdac-primary-light);
}

.tdac-option-label-text {
    flex: 1;
    font-size: 14px;
}

.tdac-option-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--tdac-primary);
    background: var(--tdac-primary-light);
    padding: 2px 8px;
    border-radius: 20px;
}

/* ============================================================
   Field Descriptions and Errors
   ============================================================ */
.tdac-field-description {
    font-size: 12px;
    color: var(--tdac-muted);
    margin: 4px 0 0;
}

.tdac-error {
    display: block;
    font-size: 12px;
    color: var(--tdac-error);
    margin-top: 4px;
    font-weight: 500;
}

.tdac-field-wrap.tdac-has-error .tdac-input,
.tdac-field-wrap.tdac-has-error .tdac-textarea,
.tdac-field-wrap.tdac-has-error .tdac-select {
    border-color: var(--tdac-error);
}

/* ============================================================
   Section heading/description/separator
   ============================================================ */
.tdac-heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--tdac-text);
    margin: 8px 0 4px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--tdac-primary);
    display: inline-block;
}

.tdac-description-text {
    color: var(--tdac-muted);
    font-size: 14px;
    margin: 0;
    padding: 10px 14px;
    background: var(--tdac-bg);
    border-left: 3px solid var(--tdac-primary);
    border-radius: 0 4px 4px 0;
}

.tdac-separator {
    border: none;
    border-top: 1px solid var(--tdac-border);
    margin: 8px 0;
}

/* ============================================================
   Calculation Panel
   ============================================================ */
.tdac-calc-panel {
    background: var(--tdac-white);
    border: 1px solid var(--tdac-border);
    border-radius: var(--tdac-radius);
    padding: 20px;
    position: sticky;
    top: 20px;
    box-shadow: var(--tdac-shadow);
}

.tdac-calc-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--tdac-text);
    margin: 0 0 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--tdac-primary);
}

.tdac-calc-empty {
    color: var(--tdac-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
    margin: 0;
}

/* ============================================================
   Line Items
   ============================================================ */
.tdac-line-items {
    margin-bottom: 16px;
    min-height: 40px;
}

.tdac-line-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
}

.tdac-line-item:last-child {
    border-bottom: none;
}

.tdac-line-item-label {
    flex: 1;
    color: var(--tdac-text);
}

.tdac-line-item-detail {
    font-size: 11px;
    color: var(--tdac-muted);
    margin-top: 1px;
}

.tdac-line-item-amount {
    font-weight: 600;
    color: var(--tdac-text);
    white-space: nowrap;
}

/* ============================================================
   Totals Section
   ============================================================ */
.tdac-totals {
    border-top: 1px solid var(--tdac-border);
    padding-top: 12px;
}

.tdac-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 14px;
}

.tdac-total-label {
    color: var(--tdac-muted);
}

.tdac-total-value {
    font-weight: 600;
    color: var(--tdac-text);
}

.tdac-grand-total-row {
    border-top: 2px solid var(--tdac-primary);
    margin-top: 8px;
    padding-top: 12px;
}

.tdac-grand-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--tdac-text);
}

.tdac-grand-total {
    font-size: 22px;
    font-weight: 800;
    color: var(--tdac-primary);
}

/* ============================================================
   Form Actions
   ============================================================ */
.tdac-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--tdac-border);
}

/* ============================================================
   Buttons
   ============================================================ */
.tdac-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 24px;
    background: var(--tdac-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1;
}

.tdac-btn-primary:hover {
    background: var(--tdac-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    color: #fff;
    text-decoration: none;
}

.tdac-btn-primary:active {
    transform: translateY(0);
    box-shadow: none;
}

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

.tdac-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--tdac-white);
    color: var(--tdac-muted);
    border: 1.5px solid var(--tdac-border);
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1;
}

.tdac-btn-secondary:hover {
    background: var(--tdac-bg);
    color: var(--tdac-text);
    border-color: #94a3b8;
}

.tdac-btn-print {
    background: #059669;
	color: #ffffff!important;
	text-decoration: none!important;
}

.tdac-btn-print:hover {
    background: #047857;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

/* ============================================================
   Hidden utility
   ============================================================ */
.tdac-hidden {
    display: none !important;
}

/* ============================================================
   Estimate Modal
   ============================================================ */
.tdac-estimate-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tdac-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.tdac-modal-box {
    position: relative;
    background: var(--tdac-white);
    border-radius: 12px;
    box-shadow: var(--tdac-shadow-lg);
    width: 90vw;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: tdacModalIn 0.25s ease;
}

@keyframes tdacModalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tdac-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--tdac-border);
}

.tdac-modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--tdac-text);
    margin: 0;
}

.tdac-modal-close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--tdac-muted);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

.tdac-modal-close:hover {
    color: var(--tdac-text);
}

.tdac-modal-body {
    padding: 24px;
}

.tdac-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--tdac-border);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ============================================================
   Estimate Summary
   ============================================================ */
.tdac-estimate-number-display {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--tdac-primary-light);
    border-radius: 6px;
    border: 1px solid #bfdbfe;
}

.tdac-estimate-number-label {
    font-size: 12px;
    color: var(--tdac-muted);
}

.tdac-estimate-number-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--tdac-primary);
    font-family: monospace;
}

.tdac-estimate-summary {
    margin-bottom: 16px;
}

.tdac-result-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: var(--tdac-primary-light);
    border-radius: 8px;
    border: 1px solid #bfdbfe;
}

.tdac-result-total span {
    font-size: 14px;
    color: var(--tdac-muted);
}

.tdac-result-total .tdac-grand-total {
    font-size: 26px;
    font-weight: 800;
    color: var(--tdac-primary);
}

/* ============================================================
   Loading Spinner
   ============================================================ */
.tdac-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: tdacSpin 0.7s linear infinite;
    vertical-align: middle;
}

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

.tdac-calc-loading {
    text-align: center;
    padding: 10px;
    color: var(--tdac-muted);
    font-size: 13px;
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
    .tdac-form-wrap {
        display: none !important;
    }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .tdac-form-body {
        grid-template-columns: 1fr;
    }

    .tdac-calc-panel {
        position: static;
        margin-top: 20px;
    }

    .tdac-form-actions {
        flex-direction: column;
    }

    .tdac-btn-primary,
    .tdac-btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .tdac-grand-total {
        font-size: 18px;
    }

    .tdac-result-total .tdac-grand-total {
        font-size: 22px;
    }

    .tdac-modal-footer {
        flex-direction: column;
    }

    .tdac-modal-footer .tdac-btn-primary,
    .tdac-modal-footer .tdac-btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .tdac-radio-group,
    .tdac-checkbox-group {
        gap: 6px;
    }

    .tdac-radio-option,
    .tdac-checkbox-option {
        padding: 8px 10px;
    }

    .tdac-form-title {
        font-size: 20px;
    }
}
