* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    width: 100%;
}

:root {
    --primary: #d32f2f;
    --primary-hover: #b71c1c;
    --success: #2e7d32;
    --info: #0288d1;
    --warning: #f57c00;
    --danger: #c62828;
    --bg-light: #f4f6f9;
    --text-main: #333;
    --text-muted: #666;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

body {
    background-color: var(--bg-light);
    font-family: 'Outfit', 'Inter', sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    padding: 20px;
    overflow-x: hidden;
    width: 100%;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    width: 100%;
    box-sizing: border-box;
}

.form-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.form-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.divider-primary {
    height: 4px;
    background: var(--primary);
    width: 60px;
    margin-bottom: 30px;
    border-radius: 2px;
}

h3 {
    font-size: 1.4rem;
    color: var(--primary);
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin: 40px 0 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
    box-sizing: border-box;
}

.form-col-full {
    grid-column: span 2;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px 15px;
        border-radius: 15px;
        max-width: 100%;
        width: calc(100vw - 20px);
        overflow-x: hidden;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .form-col-full {
        grid-column: span 1;
    }

    .form-header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .form-title {
        font-size: 1.5rem;
        word-break: break-word;
        line-height: 1.3;
    }

    h3 {
        font-size: 1.2rem;
        margin: 30px 0 15px;
        word-break: break-word;
    }

    .form-group label {
        font-size: 0.9rem;
    }

    .form-group input:not([type="checkbox"]):not([type="radio"]),
    .form-group select,
    .form-group textarea {
        font-size: 0.95rem;
        padding: 10px 12px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .info-box {
        padding: 15px;
        font-size: 0.9rem;
        word-break: break-word;
        margin-left: 0;
        margin-right: 0;
    }

    .info-box ul,
    .info-box ol {
        padding-left: 18px;
    }

    .checkbox-item {
        padding: 14px;
        font-size: 0.9rem;
        flex-wrap: wrap;
    }

    .checkbox-item-content {
        font-size: 0.9rem;
        word-break: break-word;
        flex: 1;
        min-width: 0;
    }

    .btn-submit {
        font-size: 1rem;
        padding: 12px 30px;
        width: 100%;
    }

    .btn-clear {
        font-size: 0.8rem;
        padding: 7px 12px;
    }

    canvas {
        width: 100%;
        max-width: 100%;
        height: 180px;
        box-sizing: border-box;
    }

    .signature-area {
        width: 100%;
        box-sizing: border-box;
    }

    /* Fix for status cards on mobile */
    .status-card {
        padding: 10px;
    }

    .status-icon {
        font-size: 3rem;
    }

    .status-message {
        font-size: 1rem;
        max-width: 100%;
        word-break: break-word;
    }

    .status-card .btn-submit {
        min-width: auto;
        width: 100%;
    }

    /* Success overlay mobile fix */
    .success-content {
        padding: 30px 20px;
        max-width: calc(100vw - 40px);
        box-sizing: border-box;
    }

    /* Creditor info box mobile */
    .creditor-info-box {
        padding: 12px;
        font-size: 0.85rem;
    }

    /* SEPA text mobile */
    .sepa-text {
        padding: 12px !important;
        font-size: 0.8em !important;
    }

    /* Price hint mobile */
    #price_hint,
    #belt_reminder {
        font-size: 0.9rem !important;
        word-break: break-word;
    }

    /* Divider */
    .divider-primary {
        width: 50px;
        margin-bottom: 20px;
    }

    /* Button container */
    .btn-container {
        width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 15px 12px;
        width: calc(100vw - 10px);
        border-radius: 10px;
    }

    .form-title {
        font-size: 1.3rem;
        line-height: 1.2;
    }

    h3 {
        font-size: 1.1rem;
    }

    .form-group input:not([type="checkbox"]):not([type="radio"]),
    .form-group select,
    .form-group textarea {
        font-size: 0.9rem;
        padding: 9px 10px;
    }

    .info-box {
        padding: 12px;
        font-size: 0.85rem;
    }

    .info-box ul,
    .info-box ol {
        padding-left: 16px;
    }

    .info-box li {
        font-size: 0.85rem;
        margin-bottom: 4px;
    }

    .checkbox-item {
        padding: 12px;
        gap: 12px;
    }

    .checkbox-item-content {
        font-size: 0.85rem;
    }

    .checkbox-item-content strong {
        font-size: 0.85rem;
    }

    .checkbox-item-content small {
        font-size: 0.8rem;
    }

    .btn-submit {
        font-size: 0.95rem;
        padding: 11px 25px;
    }

    .btn-clear {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    canvas {
        height: 160px;
    }

    .divider-primary {
        width: 40px;
        height: 3px;
        margin-bottom: 15px;
    }

    .creditor-info-box {
        padding: 10px;
        font-size: 0.8rem;
    }

    .sepa-text {
        padding: 10px !important;
        font-size: 0.75em !important;
    }
}

/* Specific fixes for OnePlus 10T and similar devices (around 412px) */
@media (max-width: 420px) {
    .container {
        padding: 12px 10px;
        width: calc(100vw - 10px);
    }

    .form-title {
        font-size: 1.2rem;
    }

    h3 {
        font-size: 1.05rem;
    }

    .form-group input:not([type="checkbox"]):not([type="radio"]),
    .form-group select,
    .form-group textarea {
        font-size: 0.88rem;
        padding: 8px 9px;
    }

    .info-box {
        padding: 10px;
        font-size: 0.82rem;
    }

    .checkbox-item {
        padding: 10px;
        gap: 10px;
    }

    .btn-submit {
        font-size: 0.9rem;
        padding: 10px 20px;
    }
}

.form-group {
    width: 100%;
    box-sizing: border-box;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(211, 47, 47, 0.1);
}

.info-box {
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 25px;
    border-left: 5px solid;
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.info-box-info {
    background: #e3f2fd;
    border-left-color: var(--info);
}

.info-box-success {
    background: #e8f5e9;
    border-left-color: var(--success);
}

.info-box-warning {
    background: #fff3e0;
    border-left-color: var(--warning);
}

.checkbox-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 18px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.checkbox-item:hover {
    border-color: var(--primary);
    background: #fffcfc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.08);
}

.checkbox-item input[type="checkbox"] {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    flex: 0 0 24px !important;
    border: 2px solid #ccc;
    border-radius: 6px;
    background: white;
    margin: 0 !important;
    margin-top: 2px !important;
    padding: 0 !important;
    display: grid;
    place-content: center;
    transition: all 0.2s;
    cursor: pointer;
    align-self: flex-start;
    box-sizing: border-box !important;
}

.checkbox-item input[type="checkbox"]::before {
    content: "";
    width: 14px;
    height: 14px;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    background-color: var(--primary);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.checkbox-item input[type="checkbox"]:checked {
    border-color: var(--primary);
}

.checkbox-item input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.checkbox-item-content {
    flex: 1;
    font-size: 0.95rem;
}

.checkbox-item-content strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-main);
}

.checkbox-item-content small {
    display: block;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Signature Area - Precise Verification Style */
.signature-area {
    margin-top: 30px;
}

canvas {
    background: white;
    border: 2px solid #ccc;
    border-radius: 8px;
    width: 100%;
    max-width: 100%;
    /* Full width to match inputs */
    height: 200px;
    cursor: crosshair;
    display: block;
    margin-bottom: 10px;
    /* Critical for mobile signing */
    transition: box-shadow 0.2s, border-color 0.2s;
}

canvas:hover {
    border-color: #aaa;
}

/* ERROR STATE (Validation) */
.input-error {
    border-color: var(--danger) !important;
    background-color: #fff8f8 !important;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

.error-text {
    color: var(--danger);
    font-weight: 700;
    text-align: center;
    border-radius: 8px;
}

.btn-submit {
    background: var(--primary);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s;
}

.btn-submit:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(211, 47, 47, 0.3);
}

.btn-clear {
    background: #666;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 10px;
    cursor: pointer;
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 5px;
}

.input-error {
    border-color: var(--danger) !important;
}

/* Status Cards (Closed, Success, etc.) */
.status-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
}

.status-icon {
    font-size: 4rem;
    margin-bottom: 10px;
}

.status-title {
    color: var(--danger);
    margin-bottom: 5px;
}

.status-message {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 500px;
}

.btn-container {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.status-card .btn-submit {
    width: auto;
    min-width: 280px;
    padding: 12px 30px;
}

/* Spinner for Loading State */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    vertical-align: text-bottom;
    border: 0.15em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
    margin-right: 8px;
}

@keyframes spinner-border {
    to {
        transform: rotate(360deg);
    }
}

/* Disabled Button Style */
.btn-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    background: #666 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* SUCCESS OVERLAY */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.4s ease-out;
}

.success-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 500px;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-icon {
    width: 80px;
    height: 80px;
    background: #4CAF50;
    color: white;
    font-size: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Ensure all text elements wrap properly */
p, li, small, strong, span, div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Fix for lists in info boxes */
.info-box ul,
.info-box ol {
    width: 100%;
    box-sizing: border-box;
    padding-left: 20px;
    margin: 10px 0;
}

.info-box li {
    margin-bottom: 5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure form elements don't overflow */
form {
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Fix for long text in select options */
select option {
    word-wrap: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Textarea specific fixes */
textarea {
    resize: vertical;
    max-width: 100%;
    min-height: 80px;
}

/* Price info and inline elements */
.price-info {
    display: inline;
    word-break: break-word;
}

/* Creditor info box (for Gurtprüfung) */
.creditor-info-box {
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #eee;
    font-size: 0.9rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

/* SEPA text box */
.sepa-text {
    width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
/* ============================================
   MULTI-CHILDREN REGISTRATION STYLES
   ============================================ */

.children-container {
    margin: 30px 0;
}

.child-section {
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 25px;
    background: #fafafa;
    transition: all 0.3s ease;
}

.child-section:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(211, 47, 47, 0.1);
}

.child-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary);
}

.child-section-header h4 {
    margin: 0;
    color: var(--primary);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-remove-child {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-remove-child:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
}

.btn-add-child {
    background: #28a745;
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    margin: 25px 0;
    width: 100%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-add-child:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.3);
}

.btn-add-child:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.total-price-container {
    background: linear-gradient(135deg, var(--primary) 0%, #b71c1c 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin: 30px 0;
    text-align: center;
    box-shadow: 0 6px 25px rgba(211, 47, 47, 0.3);
}

.total-price-container h4 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    font-weight: 600;
    opacity: 0.9;
}

#total_price_display {
    font-size: 2.2rem;
    font-weight: bold;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.price-breakdown {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border-left: 4px solid var(--primary);
}

.price-breakdown h5 {
    margin: 0 0 15px 0;
    color: var(--primary);
    font-size: 1rem;
}

.price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.price-item:last-child {
    border-bottom: none;
    font-weight: bold;
    font-size: 1.1rem;
    padding-top: 15px;
    margin-top: 10px;
    border-top: 2px solid var(--primary);
}

.price-label {
    color: var(--text-main);
}

.price-value {
    color: var(--primary);
    font-weight: 600;
}

.contact-info-section {
    background: #f0f8ff;
    padding: 25px;
    border-radius: 12px;
    margin: 30px 0;
    border-left: 4px solid #0288d1;
}

.contact-info-section h3 {
    color: #0288d1;
    margin-top: 0;
}

.info-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 10px;
}

@media (max-width: 768px) {
    .child-section {
        padding: 20px 15px;
    }

    .child-section-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .btn-remove-child {
        width: 100%;
        justify-content: center;
    }

    #total_price_display {
        font-size: 1.8rem;
    }
}
